diff --git a/spec/the_moderator/model_spec.rb b/spec/the_moderator/model_spec.rb index b62d55d..aefa92f 100644 --- a/spec/the_moderator/model_spec.rb +++ b/spec/the_moderator/model_spec.rb @@ -8,7 +8,7 @@ describe TheModerator::Model do subject.moderate(:name) expect(subject.moderations).to have(1).moderation - expect(subject.name).to eq(nil) + expect(subject.name).to be_nil expect(subject.content).to eq('Content') end end diff --git a/spec/the_moderator/moderation_model_spec.rb b/spec/the_moderator/moderation_model_spec.rb new file mode 100644 index 0000000..167d9de --- /dev/null +++ b/spec/the_moderator/moderation_model_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe TheModerator::ModerationModel do + subject do + page = Page.new(name: 'Name', content: 'Content') + moderation = page.moderate(:name) + page.save + + moderation + end + + describe '#accept' do + it 'accepts moderated data' do + expect(subject.moderatable.name).to be_nil + subject.accept + + expect(subject.moderatable.name).to eq('Name') + expect(subject.destroyed?).to be_true + end + end + + describe '#discard' do + it 'discards moderated data' do + expect(subject.moderatable.name).to be_nil + subject.discard + + expect(subject.moderatable.name).to be_nil + expect(subject.destroyed?).to be_true + end + end + + describe '#preview' do + it 'previews moderated data' do + expect(subject.moderatable.name).to be_nil + preview = subject.preview + + expect(preview.frozen?).to be_true + expect(preview.name).to eq('Name') + end + end + + describe '#include?' do + it 'includes name' do + expect(subject.include?(:name)).to be_true + expect(subject.include?(:content)).to be_false + end + end +end