Commit c6849e53ab093bbbbd619c49d9f5ed7657b11f31

Authored by Antonio Terceiro
1 parent fb87711e

rails3: fix AbuseReport tests

All task email notifications are disabled for now; TaskMailer will
probably need to be rewritten.
app/models/abuse_report.rb
1 class AbuseReport < ActiveRecord::Base 1 class AbuseReport < ActiveRecord::Base
2 2
  3 + attr_accessible :content, :reason
  4 +
3 belongs_to :reporter, :class_name => 'Person' 5 belongs_to :reporter, :class_name => 'Person'
4 belongs_to :abuse_complaint 6 belongs_to :abuse_complaint
5 has_many :reported_images, :dependent => :destroy 7 has_many :reported_images, :dependent => :destroy
app/models/task.rb
@@ -57,7 +57,8 @@ class Task &lt; ActiveRecord::Base @@ -57,7 +57,8 @@ class Task &lt; ActiveRecord::Base
57 after_create do |task| 57 after_create do |task|
58 unless task.status == Task::Status::HIDDEN 58 unless task.status == Task::Status::HIDDEN
59 begin 59 begin
60 - task.send(:send_notification, :created) 60 + # FIXME
  61 + # task.send(:send_notification, :created)
61 rescue NotImplementedError => ex 62 rescue NotImplementedError => ex
62 RAILS_DEFAULT_LOGGER.info ex.to_s 63 RAILS_DEFAULT_LOGGER.info ex.to_s
63 end 64 end
@@ -65,7 +66,8 @@ class Task &lt; ActiveRecord::Base @@ -65,7 +66,8 @@ class Task &lt; ActiveRecord::Base
65 begin 66 begin
66 target_msg = task.target_notification_message 67 target_msg = task.target_notification_message
67 if target_msg && task.target && !task.target.notification_emails.empty? 68 if target_msg && task.target && !task.target.notification_emails.empty?
68 - TaskMailer.deliver_target_notification(task, target_msg) 69 + # FIXME
  70 + # TaskMailer.deliver_target_notification(task, target_msg)
69 end 71 end
70 rescue NotImplementedError => ex 72 rescue NotImplementedError => ex
71 RAILS_DEFAULT_LOGGER.info ex.to_s 73 RAILS_DEFAULT_LOGGER.info ex.to_s
@@ -220,7 +222,8 @@ class Task &lt; ActiveRecord::Base @@ -220,7 +222,8 @@ class Task &lt; ActiveRecord::Base
220 self.status = Task::Status::ACTIVE 222 self.status = Task::Status::ACTIVE
221 save! 223 save!
222 begin 224 begin
223 - self.send(:send_notification, :activated) 225 + # FIXME
  226 + # self.send(:send_notification, :activated)
224 rescue NotImplementedError => ex 227 rescue NotImplementedError => ex
225 RAILS_DEFAULT_LOGGER.info ex.to_s 228 RAILS_DEFAULT_LOGGER.info ex.to_s
226 end 229 end
@@ -228,7 +231,8 @@ class Task &lt; ActiveRecord::Base @@ -228,7 +231,8 @@ class Task &lt; ActiveRecord::Base
228 begin 231 begin
229 target_msg = target_notification_message 232 target_msg = target_notification_message
230 if target_msg && self.target && !self.target.notification_emails.empty? 233 if target_msg && self.target && !self.target.notification_emails.empty?
231 - TaskMailer.deliver_target_notification(self, target_msg) 234 + # FIXME
  235 + # TaskMailer.deliver_target_notification(self, target_msg)
232 end 236 end
233 rescue NotImplementedError => ex 237 rescue NotImplementedError => ex
234 RAILS_DEFAULT_LOGGER.info ex.to_s 238 RAILS_DEFAULT_LOGGER.info ex.to_s
@@ -261,7 +265,8 @@ class Task &lt; ActiveRecord::Base @@ -261,7 +265,8 @@ class Task &lt; ActiveRecord::Base
261 def send_notification(action) 265 def send_notification(action)
262 if sends_email? 266 if sends_email?
263 if self.requestor 267 if self.requestor
264 - TaskMailer.send("deliver_task_#{action}", self) 268 + # FIXME
  269 + # TaskMailer.send("deliver_task_#{action}", self)
265 end 270 end
266 end 271 end
267 end 272 end
test/unit/abuse_report_test.rb
@@ -14,8 +14,8 @@ class AbuseReportTest &lt; ActiveSupport::TestCase @@ -14,8 +14,8 @@ class AbuseReportTest &lt; ActiveSupport::TestCase
14 abuse_report = AbuseReport.new(:reason => 'some reason') 14 abuse_report = AbuseReport.new(:reason => 'some reason')
15 15
16 assert !abuse_report.valid? 16 assert !abuse_report.valid?
17 - assert abuse_report.errors.invalid?(:reporter)  
18 - assert abuse_report.errors.invalid?(:abuse_complaint) 17 + assert abuse_report.invalid?(:reporter)
  18 + assert abuse_report.invalid?(:abuse_complaint)
19 19
20 abuse_report.reporter = reporter 20 abuse_report.reporter = reporter
21 abuse_report.abuse_complaint = abuse_complaint 21 abuse_report.abuse_complaint = abuse_complaint
@@ -24,9 +24,15 @@ class AbuseReportTest &lt; ActiveSupport::TestCase @@ -24,9 +24,15 @@ class AbuseReportTest &lt; ActiveSupport::TestCase
24 end 24 end
25 25
26 should 'not allow more than one report by a user to the same complaint' do 26 should 'not allow more than one report by a user to the same complaint' do
27 - abuse_report = AbuseReport.create!(:reporter => reporter, :abuse_complaint => abuse_complaint, :reason => 'some reason') 27 + abuse_report = AbuseReport.new(:reason => 'some reason')
  28 + abuse_report.reporter = reporter
  29 + abuse_report.abuse_complaint = abuse_complaint
  30 + abuse_report.save!
28 assert_raise ActiveRecord::RecordInvalid do 31 assert_raise ActiveRecord::RecordInvalid do
29 - another_abuse = AbuseReport.create!(:reporter => reporter, :abuse_complaint => abuse_complaint, :reason => 'some reason') 32 + another_abuse = AbuseReport.new(:reason => 'some reason')
  33 + another_abuse.reporter = reporter
  34 + another_abuse.abuse_complaint = abuse_complaint
  35 + another_abuse.save!
30 end 36 end
31 end 37 end
32 end 38 end