Test ModerationModel methods

master
Guillaume DOTT 2013-11-28 09:26:02 +01:00
parent d9b99bb6e7
commit 7612d2f45e
2 changed files with 49 additions and 1 deletions

View File

@ -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

View File

@ -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