Changed report spec
* Removed ActiveRecord tests (that is handled in the controller spec) * Added Mailer tests * Added validation tests
This commit is contained in:
parent
435f659467
commit
1a4ab274a3
2 changed files with 34 additions and 33 deletions
26
spec/mailers/report_spec.rb
Normal file
26
spec/mailers/report_spec.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Report do
|
||||
describe '#make_notification' do
|
||||
before do
|
||||
@user = bob
|
||||
Role.add_admin(@user)
|
||||
end
|
||||
|
||||
it "should deliver successfully" do
|
||||
expect {
|
||||
ReportMailer.new_report('post', 666)
|
||||
}.to_not raise_error
|
||||
end
|
||||
|
||||
it "should be added to the delivery queue" do
|
||||
expect {
|
||||
ReportMailer.new_report('post', 666)
|
||||
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -17,49 +17,24 @@ describe Report do
|
|||
:post_type => 'comment',
|
||||
:text => 'offensive content'
|
||||
}
|
||||
@report_post = bob.reports.new(@valid_post)
|
||||
@report_comment = bob.reports.new(@valid_comment)
|
||||
end
|
||||
|
||||
describe '#validation' do
|
||||
it 'validates that post ID is required' do
|
||||
report = bob.reports.new(:post_type => 'post', :text => 'blub')
|
||||
report.save.should_not be_true
|
||||
bob.reports.build(:post_type => 'post', :text => 'blub').should_not be_valid
|
||||
end
|
||||
|
||||
it 'validates that post type is required' do
|
||||
report = bob.reports.new(:post_id => 666, :text => 'blub')
|
||||
report.save.should_not be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#insert' do
|
||||
it 'post successfully' do
|
||||
@report_post.save.should be_true
|
||||
bob.reports.build(:post_id => 666, :text => 'blub').should_not be_valid
|
||||
end
|
||||
|
||||
it 'comment successfully' do
|
||||
@report_comment.save.should be_true
|
||||
it 'validates that entry does not exist' do
|
||||
bob.reports.build(@valid_post).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe '#delete' do
|
||||
it 'post' do
|
||||
@report_post.destroy_reported_item.should be_true
|
||||
end
|
||||
|
||||
it 'comment' do
|
||||
@report_comment.destroy_reported_item.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe '.check_database' do
|
||||
it 'post' do
|
||||
Report.where(:reviewed => true, :post_id => 666, :post_type => 'post').should be_true
|
||||
end
|
||||
|
||||
it 'comment' do
|
||||
Report.where(:reviewed => true, :post_id => 666, :post_type => 'comment').should be_true
|
||||
|
||||
it 'validates that entry does exist' do
|
||||
bob.reports.create(@valid_post)
|
||||
bob.reports.build(@valid_post).should_not be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue