From 9e2a68d1ae65e43aab142abe8bcccf188194f9cd Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Tue, 23 Sep 2014 15:09:30 +0200 Subject: [PATCH] Add spec for has_many associations --- spec/the_moderator/model_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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