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 1 class AbuseReport < ActiveRecord::Base
2 2  
  3 + attr_accessible :content, :reason
  4 +
3 5 belongs_to :reporter, :class_name => 'Person'
4 6 belongs_to :abuse_complaint
5 7 has_many :reported_images, :dependent => :destroy
... ...
app/models/task.rb
... ... @@ -57,7 +57,8 @@ class Task &lt; ActiveRecord::Base
57 57 after_create do |task|
58 58 unless task.status == Task::Status::HIDDEN
59 59 begin
60   - task.send(:send_notification, :created)
  60 + # FIXME
  61 + # task.send(:send_notification, :created)
61 62 rescue NotImplementedError => ex
62 63 RAILS_DEFAULT_LOGGER.info ex.to_s
63 64 end
... ... @@ -65,7 +66,8 @@ class Task &lt; ActiveRecord::Base
65 66 begin
66 67 target_msg = task.target_notification_message
67 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 71 end
70 72 rescue NotImplementedError => ex
71 73 RAILS_DEFAULT_LOGGER.info ex.to_s
... ... @@ -220,7 +222,8 @@ class Task &lt; ActiveRecord::Base
220 222 self.status = Task::Status::ACTIVE
221 223 save!
222 224 begin
223   - self.send(:send_notification, :activated)
  225 + # FIXME
  226 + # self.send(:send_notification, :activated)
224 227 rescue NotImplementedError => ex
225 228 RAILS_DEFAULT_LOGGER.info ex.to_s
226 229 end
... ... @@ -228,7 +231,8 @@ class Task &lt; ActiveRecord::Base
228 231 begin
229 232 target_msg = target_notification_message
230 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 236 end
233 237 rescue NotImplementedError => ex
234 238 RAILS_DEFAULT_LOGGER.info ex.to_s
... ... @@ -261,7 +265,8 @@ class Task &lt; ActiveRecord::Base
261 265 def send_notification(action)
262 266 if sends_email?
263 267 if self.requestor
264   - TaskMailer.send("deliver_task_#{action}", self)
  268 + # FIXME
  269 + # TaskMailer.send("deliver_task_#{action}", self)
265 270 end
266 271 end
267 272 end
... ...
test/unit/abuse_report_test.rb
... ... @@ -14,8 +14,8 @@ class AbuseReportTest &lt; ActiveSupport::TestCase
14 14 abuse_report = AbuseReport.new(:reason => 'some reason')
15 15  
16 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 20 abuse_report.reporter = reporter
21 21 abuse_report.abuse_complaint = abuse_complaint
... ... @@ -24,9 +24,15 @@ class AbuseReportTest &lt; ActiveSupport::TestCase
24 24 end
25 25  
26 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 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 36 end
31 37 end
32 38 end
... ...