diff --git a/spec/the_moderator/model_spec.rb b/spec/the_moderator/model_spec.rb index 9532b27..01aeb64 100644 --- a/spec/the_moderator/model_spec.rb +++ b/spec/the_moderator/model_spec.rb @@ -26,6 +26,20 @@ describe TheModerator::Model do .to include(page_attributes: {name: 'name', id: category.page.id}) expect(category.page.name).to be_nil end + + it 'moderates has_many associations' do + page = Page.new(name: 'page') + page.save + link = page.links.create + + page.attributes = {links_attributes: [{id: link.id, name: 'link'}]} + page.moderate(links: [:name]) + + expect(page.moderations).to have(1).moderation + expect(page.moderations.first.data[:attributes]) + .to include(links_attributes: {link.id => {name: 'link', id: link.id}}) + expect(link.name).to be_nil + end end describe '#moderated?' do