Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes last call to automate from dialog_field serializer #17436

Merged
merged 1 commit into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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