Skip to content

Commit 13f4194

Browse files
committed
fix wrapping plugins
previous change to replace belongs_to relationship with a has_one relationship did not include autosave autosave causes the related object to be saved automatically when the main object is saved this is necessary for our delegation code.
1 parent c714248 commit 13f4194

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/models/embeddable/embeddable_plugin.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def self.table_name
1010
attr_accessible :plugin, :approved_script_id, :description, :author_data,
1111
:is_full_width, :is_hidden, :component_label
1212

13-
has_one :plugin, as: :plugin_scope
13+
has_one :plugin, as: :plugin_scope, autosave: true
1414

1515
has_many :page_items, :as => :embeddable, :dependent => :destroy
1616
has_many :interactive_pages, :through => :page_items

spec/models/embeddable/embeddable_plugin_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,14 @@
8787
end
8888

8989
end
90+
91+
describe 'delegated to plugin methods' do
92+
it 'should save value after a simple create, set, save, reload' do
93+
embeddable = Embeddable::EmbeddablePlugin.create!
94+
embeddable.approved_script_id = "123"
95+
embeddable.save!
96+
embeddable.reload
97+
expect(embeddable.approved_script_id).to eq("123")
98+
end
99+
end
90100
end

0 commit comments

Comments
 (0)