Skip to content

Commit

Permalink
Merge pull request #17436 from d-m-u/excluding_values_from_serializer
Browse files Browse the repository at this point in the history
Removes last call to automate from dialog_field serializer
  • Loading branch information
gmcculloug authored May 21, 2018
2 parents 79305c7 + 5415cc1 commit 1009681
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/dialog_field_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def serialize(dialog_field, all_attributes = false)
dialog_field.options[:force_single_value] = dialog_field.options[:force_single_value] || category.single_value
end
end
included_attributes(dialog_field.as_json(:methods => [:type, :values]), all_attributes).merge(extra_attributes)
json_options = dialog_field.dynamic? ? {:methods => [:type], :except => [:values]} : {:methods => %i(type values)}
included_attributes(dialog_field.as_json(json_options), all_attributes).merge(extra_attributes)
end
end
13 changes: 13 additions & 0 deletions spec/models/dialog_field_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

describe "#serialize" do
let(:dialog_field) { DialogFieldTextBox.new(expected_serialized_values.merge(:resource_action => resource_action, :dialog_field_responders => dialog_field_responders)) }
let(:dialog_field_with_values) { DialogFieldTextBox.new(expected_serialized_values.merge(:resource_action => resource_action, :dialog_field_responders => dialog_field_responders, :values => "drew")) }
let(:type) { "DialogFieldTextBox" }
let(:resource_action) { ResourceAction.new }
let(:dialog_field_responders) { [] }
Expand Down Expand Up @@ -80,6 +81,18 @@
))
end
end

let(:all_attributes) { true }

it 'does not call values' do
expect(dialog_field_serializer.serialize(dialog_field_with_values, all_attributes))
.to include(expected_serialized_values.merge(
'id' => dialog_field.id,
'resource_action' => 'serialized resource action',
'dialog_field_responders' => [],
'values' => nil
))
end
end

context "when the dialog_field is not dynamic" do
Expand Down

0 comments on commit 1009681

Please sign in to comment.