diff --git a/spec/mailers/report_spec.rb b/spec/mailers/report_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..e5d1b1608e5e4e8893844b2c6e64f1d40636f4e5 --- /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 d3ec0815f7ad5c6ec72e348affaab6fa50faf581..061fab8e40d775ed9d95edd9f96a18cd1b454714 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