Added destroy_reported_item to report model spec
This commit is contained in:
parent
6f65ef8437
commit
f6eba7966d
1 changed files with 40 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ require 'spec_helper'
|
||||||
describe Report do
|
describe Report do
|
||||||
before do
|
before do
|
||||||
#:report => { :post_id => @message.id, :post_type => 'post', :text => 'offensive content' }
|
#:report => { :post_id => @message.id, :post_type => 'post', :text => 'offensive content' }
|
||||||
|
@user = bob
|
||||||
@valid_post = {
|
@valid_post = {
|
||||||
:post_id => 666,
|
:post_id => 666,
|
||||||
:post_type => 'post',
|
:post_type => 'post',
|
||||||
|
|
@ -21,20 +22,54 @@ describe Report do
|
||||||
|
|
||||||
describe '#validation' do
|
describe '#validation' do
|
||||||
it 'validates that post ID is required' do
|
it 'validates that post ID is required' do
|
||||||
bob.reports.build(:post_type => 'post', :text => 'blub').should_not be_valid
|
@user.reports.build(:post_type => 'post', :text => 'blub').should_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates that post type is required' do
|
it 'validates that post type is required' do
|
||||||
bob.reports.build(:post_id => 666, :text => 'blub').should_not be_valid
|
@user.reports.build(:post_id => 666, :text => 'blub').should_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates that entry does not exist' do
|
it 'validates that entry does not exist' do
|
||||||
bob.reports.build(@valid_post).should be_valid
|
@user.reports.build(@valid_post).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates that entry does exist' do
|
it 'validates that entry does exist' do
|
||||||
bob.reports.create(@valid_post)
|
@user.reports.create(@valid_post)
|
||||||
bob.reports.build(@valid_post).should_not be_valid
|
@user.reports.build(@valid_post).should_not be_valid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#destroy_reported_item' do
|
||||||
|
before do
|
||||||
|
@post = @user.reports.create(@valid_post)
|
||||||
|
@comment = @user.reports.create(@valid_comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.post' do
|
||||||
|
it 'should destroy it' do
|
||||||
|
@post.destroy_reported_item.should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be marked' do
|
||||||
|
expect {
|
||||||
|
@post.destroy_reported_item
|
||||||
|
}.to change{ Report.where(@valid_post).first.reviewed }.to(true).from(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.comment' do
|
||||||
|
it 'should destroy it' do
|
||||||
|
@comment.destroy_reported_item.should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
xit 'nothing' do
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be marked' do
|
||||||
|
expect {
|
||||||
|
@comment.destroy_reported_item
|
||||||
|
}.to change{ Report.where(@valid_comment).first.reviewed }.to(true).from(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue