Skip to content

Commit

Permalink
Merge pull request #16555 from jntullo/parse_default_values
Browse files Browse the repository at this point in the history
Parse default value in Service Dialog
  • Loading branch information
gmcculloug authored Dec 1, 2017
2 parents d06daa5 + a613395 commit 10a0148
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/models/dialog_field_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def serialize(dialog_field, all_attributes = false)
"dialog_field_responders" => dialog_field.dialog_field_responders.map(&:name)
}

if dialog_field.try(:force_multi_value) && dialog_field.default_value.present?
extra_attributes["default_value"] = dialog_field.default_value.split(",")
end

if dialog_field.dynamic?
dynamic_values = dialog_field.trigger_automate_value_updates
extra_attributes["values"] = dynamic_values
Expand Down
8 changes: 6 additions & 2 deletions spec/models/dialog_field_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@
allow(dialog_field).to receive(:values).and_return("values")
end

it "serializes the category name and description" do
it "serializes the category name, description and default value" do
default_values = "one,two"
dialog_field.update_attributes(:default_value => default_values)

expect(dialog_field_serializer.serialize(dialog_field))
.to eq(expected_serialized_values.merge(
"resource_action" => "serialized resource action",
Expand All @@ -147,7 +150,8 @@
:category_id => "123",
:category_name => "best category ever",
:category_description => "best category ever"
}
},
"default_value" => %w(one two)
))
end
end
Expand Down

0 comments on commit 10a0148

Please sign in to comment.