diff --git a/app/models/resource_action.rb b/app/models/resource_action.rb index 625ca9eb99d..8c601cddc4d 100644 --- a/app/models/resource_action.rb +++ b/app/models/resource_action.rb @@ -1,5 +1,6 @@ class ResourceAction < ApplicationRecord belongs_to :resource, :polymorphic => true + belongs_to :configuration_template, :polymorphic => true belongs_to :dialog serialize :ae_attributes, Hash diff --git a/app/models/resource_action_serializer.rb b/app/models/resource_action_serializer.rb index 7aa1c5101b5..f288a263528 100644 --- a/app/models/resource_action_serializer.rb +++ b/app/models/resource_action_serializer.rb @@ -1,5 +1,6 @@ class ResourceActionSerializer < Serializer - EXCLUDED_ATTRIBUTES = %w(created_at updated_at id dialog_id resource_id) + EXCLUDED_ATTRIBUTES = %w(created_at updated_at id dialog_id resource_id + configuration_template_id configuration_template_type).freeze def serialize(resource_action) included_attributes(resource_action.attributes) diff --git a/db/migrate/20170118140522_add_configuration_template_to_resource_actions.rb b/db/migrate/20170118140522_add_configuration_template_to_resource_actions.rb new file mode 100644 index 00000000000..6b88b8cb071 --- /dev/null +++ b/db/migrate/20170118140522_add_configuration_template_to_resource_actions.rb @@ -0,0 +1,6 @@ +class AddConfigurationTemplateToResourceActions < ActiveRecord::Migration[5.0] + def change + add_column :resource_actions, :configuration_template_id, :bigint + add_column :resource_actions, :configuration_template_type, :string + end +end diff --git a/db/schema.yml b/db/schema.yml index bfe2467bd08..87175c3d3a0 100644 --- a/db/schema.yml +++ b/db/schema.yml @@ -6221,6 +6221,8 @@ resource_actions: - ae_instance - ae_message - ae_attributes +- configuration_template_id +- configuration_template_type resource_groups: - id - name diff --git a/spec/models/resource_action_serializer_spec.rb b/spec/models/resource_action_serializer_spec.rb index 4176203697f..d1dda123d7c 100644 --- a/spec/models/resource_action_serializer_spec.rb +++ b/spec/models/resource_action_serializer_spec.rb @@ -2,33 +2,22 @@ let(:resource_action_serializer) { described_class.new } describe "#serialize" do - let(:resource_action) do - ResourceAction.new( - :dialog_id => 123, - :resource_id => 321, - :created_at => Time.now, - :updated_at => Time.now, - :resource_type => "DialogField", - :ae_namespace => "Customer/Sample", - :ae_class => "Methods", - :ae_instance => "Testing" - ) - end + let(:resource_action) { ResourceAction.new(expected_serialized_values) } let(:expected_serialized_values) do { - "action" => nil, "resource_type" => "DialogField", "ae_namespace" => "Customer/Sample", "ae_class" => "Methods", "ae_instance" => "Testing", - "ae_message" => nil, - "ae_attributes" => {} } end it "serializes the resource_action" do - expect(resource_action_serializer.serialize(resource_action)).to eq(expected_serialized_values) + serialized = resource_action_serializer.serialize(resource_action) + expect(serialized).to have_attributes(expected_serialized_values) + expect(serialized.keys).to include("action", "ae_attributes", "ae_message") + expect(serialized.keys).not_to include(*described_class::EXCLUDED_ATTRIBUTES) end end end