Replaced fake post/comment with existing one
That fixed the correct validation whether a post/comment is gone after the report was marked as deleted
This commit is contained in:
parent
9d3af93c7d
commit
8ae89a443b
1 changed files with 23 additions and 18 deletions
|
|
@ -8,13 +8,16 @@ 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
|
@user = bob
|
||||||
@valid_post = {
|
@bob_post = @user.post(:status_message, :text => "hello", :to => @user.aspects.first.id)
|
||||||
:post_id => 666,
|
@bob_comment = @user.comment!(@bob_post, "welcome")
|
||||||
|
|
||||||
|
@valid_post_report = {
|
||||||
|
:post_id => @bob_post.id,
|
||||||
:post_type => 'post',
|
:post_type => 'post',
|
||||||
:text => 'offensive content'
|
:text => 'offensive content'
|
||||||
}
|
}
|
||||||
@valid_comment = {
|
@valid_comment_report = {
|
||||||
:post_id => 666,
|
:post_id => @bob_comment.id,
|
||||||
:post_type => 'comment',
|
:post_type => 'comment',
|
||||||
:text => 'offensive content'
|
:text => 'offensive content'
|
||||||
}
|
}
|
||||||
|
|
@ -30,44 +33,46 @@ describe Report do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates that entry does not exist' do
|
it 'validates that entry does not exist' do
|
||||||
@user.reports.build(@valid_post).should be_valid
|
@user.reports.build(@valid_post_report).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'validates that entry does exist' do
|
it 'validates that entry does exist' do
|
||||||
@user.reports.create(@valid_post)
|
@user.reports.create(@valid_post_report)
|
||||||
@user.reports.build(@valid_post).should_not be_valid
|
@user.reports.build(@valid_post_report).should_not be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#destroy_reported_item' do
|
describe '#destroy_reported_item' do
|
||||||
before do
|
before(:each) do
|
||||||
@post = @user.reports.create(@valid_post)
|
@post_report = @user.reports.create(@valid_post_report)
|
||||||
@comment = @user.reports.create(@valid_comment)
|
@comment_report = @user.reports.create(@valid_comment_report)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.post' do
|
describe '.post' do
|
||||||
it 'should destroy it' do
|
it 'should destroy it' do
|
||||||
@post.destroy_reported_item.should be_true
|
expect {
|
||||||
expect { Post.find(@post) }.to raise_error(ActiveRecord::RecordNotFound)
|
@post_report.destroy_reported_item
|
||||||
|
}.to change { Post.count }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be marked' do
|
it 'should be marked' do
|
||||||
expect {
|
expect {
|
||||||
@post.destroy_reported_item
|
@post_report.destroy_reported_item
|
||||||
}.to change{ Report.where(@valid_post).first.reviewed }.to(true).from(false)
|
}.to change { Report.where(@valid_post_report).first.reviewed }.to(true).from(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.comment' do
|
describe '.comment' do
|
||||||
it 'should destroy it' do
|
it 'should destroy it' do
|
||||||
@comment.destroy_reported_item.should be_true
|
expect {
|
||||||
expect { Comment.find(@comment) }.to raise_error(ActiveRecord::RecordNotFound)
|
@comment_report.destroy_reported_item
|
||||||
|
}.to change { Comment.count }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be marked' do
|
it 'should be marked' do
|
||||||
expect {
|
expect {
|
||||||
@comment.destroy_reported_item
|
@comment_report.destroy_reported_item
|
||||||
}.to change{ Report.where(@valid_comment).first.reviewed }.to(true).from(false)
|
}.to change { Report.where(@valid_comment_report).first.reviewed }.to(true).from(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue