diff options
author | Lukas Matt <lukas@zauberstuhl.de> | 2014-03-31 17:27:51 +0400 |
---|---|---|
committer | Lukas Matt <lukas@zauberstuhl.de> | 2014-05-15 15:23:43 +0400 |
commit | 1a4ab274a348f970bcb5d146b41ee08f208817e0 (patch) | |
tree | 16b052236227a6357e95c88bc8daec28aabaf06b | |
parent | 435f6594675a0f6b9e1dfc0342fcda4ade864482 (diff) |
Changed report spec
* Removed ActiveRecord tests (that is handled in the controller spec)
* Added Mailer tests
* Added validation tests
-rw-r--r-- | spec/mailers/report_spec.rb | 26 | ||||
-rw-r--r-- | spec/models/report_spec.rb | 41 |
2 files changed, 34 insertions, 33 deletions
diff --git a/spec/mailers/report_spec.rb b/spec/mailers/report_spec.rb new file mode 100644 index 000000000..e5d1b1608 --- /dev/null +++ b/spec/mailers/report_spec.rb @@ -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 diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index d3ec0815f..061fab8e4 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -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 + bob.reports.build(:post_id => 666, :text => 'blub').should_not be_valid 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 'post' do - Report.where(:reviewed => true, :post_id => 666, :post_type => 'post').should be_true + it 'validates that entry does not exist' do + bob.reports.build(@valid_post).should be_valid 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 |