Skip to content

Commit

Permalink
Needed another example to deal with defaults correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
powersurge360 committed Feb 24, 2025
1 parent a9f8483 commit f62d721
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion spec/forms/concerns/form_attributes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
require 'rails_helper'

class ExampleModel
# This was copied from OutgoingEmail to have a real example, but not literally tie to an existing model (which may change)
# This was copied from OutgoingEmail to have a real example, but not literally
# tie to an existing model (which may change)
def self.column_defaults
{
"id" => nil,
"body" => "some body text",
"client_id" => nil,
"created_at" => nil,
"mailgun_status" => "sending",
"message_id" => nil,
"sent_at" => nil,
"subject" => nil,
"to" => nil,
"updated_at" => nil,
"user_id" => nil
}
end
end

class SecondExampleModel
# This was copied from OutgoingEmail to have a real example, but not literally
# tie to an existing model (which may change)
def self.column_defaults
{
"id" => nil,
Expand Down Expand Up @@ -48,6 +69,9 @@ class ModelExampleForm
defaults: {
mailgun_status: "not_sent",
}

set_attributes_for SecondExampleModel,
:body
end

class MixedExampleForm
Expand Down

0 comments on commit f62d721

Please sign in to comment.