Skip to content
Extraits de code Groupes Projets
Valider 1a4ab274 rédigé par Lukas Matt's avatar Lukas Matt
Parcourir les fichiers

Changed report spec

* Removed ActiveRecord tests (that is handled in the controller spec)
* Added Mailer tests
* Added validation tests
parent 435f6594
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# 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 ...@@ -17,49 +17,24 @@ describe Report do
:post_type => 'comment', :post_type => 'comment',
:text => 'offensive content' :text => 'offensive content'
} }
@report_post = bob.reports.new(@valid_post)
@report_comment = bob.reports.new(@valid_comment)
end end
describe '#validation' do describe '#validation' do
it 'validates that post ID is required' do it 'validates that post ID is required' do
report = bob.reports.new(:post_type => 'post', :text => 'blub') bob.reports.build(:post_type => 'post', :text => 'blub').should_not be_valid
report.save.should_not be_true
end end
it 'validates that post type is required' do it 'validates that post type is required' do
report = bob.reports.new(:post_id => 666, :text => 'blub') bob.reports.build(:post_id => 666, :text => 'blub').should_not be_valid
report.save.should_not be_true
end end
end
describe '#insert' do
it 'post successfully' do
@report_post.save.should be_true
end
it 'comment successfully' do
@report_comment.save.should be_true
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 'validates that entry does not exist' do
it 'post' do bob.reports.build(@valid_post).should be_valid
Report.where(:reviewed => true, :post_id => 666, :post_type => 'post').should be_true
end end
it 'comment' do it 'validates that entry does exist' do
Report.where(:reviewed => true, :post_id => 666, :post_type => 'comment').should be_true bob.reports.create(@valid_post)
bob.reports.build(@valid_post).should_not be_valid
end end
end end
end end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter