public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, spec/support/
@ 2011-02-22 15:55 Petteri Räty
  0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2011-02-22 15:55 UTC (permalink / raw
  To: gentoo-commits

commit:     4396a16a976a46b11ecf281b5be054a0379ff35b
Author:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 20 19:33:44 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Feb 22 15:53:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=4396a16a

Fix deprecation warnings from delayed_job

---
 app/models/answer.rb                   |    4 ++--
 app/models/comment.rb                  |    2 +-
 app/models/email_answer.rb             |    2 +-
 app/models/question.rb                 |    2 +-
 spec/models/answer_spec.rb             |    4 ++--
 spec/models/comment_spec.rb            |    2 +-
 spec/models/email_answer_spec.rb       |    4 ++--
 spec/models/question_spec.rb           |    4 ++--
 spec/support/delayed_should_receive.rb |   11 +++++++++++
 9 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/app/models/answer.rb b/app/models/answer.rb
index d477e26..73e7750 100644
--- a/app/models/answer.rb
+++ b/app/models/answer.rb
@@ -149,12 +149,12 @@ class Answer < ActiveRecord::Base
   protected
     # Sends email notification about new answer to mentor of owner
     def notify_new_answer
-      UserMailer.send_later(:deliver_new_answer, owner.mentor, self) unless owner._?.mentor.nil?
+      UserMailer.delay.deliver_new_answer(owner.mentor, self) unless owner._?.mentor.nil?
     end
 
     # Sends email notification about changed answer to mentor of owner
     def notify_changed_answer
-      UserMailer.send_later(:deliver_changed_answer, owner.mentor, self) unless owner._?.mentor.nil?
+      UserMailer.delay.deliver_changed_answer(owner.mentor, self) unless owner._?.mentor.nil?
     end
 
 end

diff --git a/app/models/comment.rb b/app/models/comment.rb
index c10a8f2..cfbf1c1 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -47,6 +47,6 @@ class Comment < ActiveRecord::Base
   protected
     # Sends notification about new comment to owner of mentor
     def notify_new_comment
-      UserMailer.send_later(:deliver_new_comment, answer.owner, self)
+      UserMailer.delay.deliver_new_comment(answer.owner, self)
     end
 end

diff --git a/app/models/email_answer.rb b/app/models/email_answer.rb
index ffec1ac..5db9b97 100644
--- a/app/models/email_answer.rb
+++ b/app/models/email_answer.rb
@@ -36,7 +36,7 @@ class EmailAnswer < Answer
     question      = Question.first :conditions => { :id => subject.captures[0] }
 
     if(question.nil? || !question.content.is_a?(QuestionContentEmail))
-      UserMailer.send_later(:deliver_unrecognized_email, user, email)
+      UserMailer.delay.deliver_unrecognized_email(user, email)
       return
     end
 

diff --git a/app/models/question.rb b/app/models/question.rb
index c377d5e..b8cfed6 100644
--- a/app/models/question.rb
+++ b/app/models/question.rb
@@ -186,7 +186,7 @@ class Question < ActiveRecord::Base
       # If question category isn't assigned don't try to access it
       if question_category && approved
         for user in question_category.users
-          UserMailer.send_later(:deliver_new_question, user, self)
+          UserMailer.delay.deliver_new_question(user, self)
         end
       end
     end

diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb
index 200077d..de72393 100644
--- a/spec/models/answer_spec.rb
+++ b/spec/models/answer_spec.rb
@@ -141,14 +141,14 @@ describe Answer do
     #can't use Factory Girl here, because we want to save it after setting expectation to get email
     answer    = Answer.new(:owner => recruit, :question => question, :content => "Some answer.")
 
-    UserMailer.should_receive(:send_later).with(:deliver_new_answer, recruit.mentor, answer)
+    UserMailer.should_receive_delayed(:deliver_new_answer, recruit.mentor, answer)
 
     answer.save!
   end
 
   it "should send email notification to mentor when changed" do
     answer = Factory(:answer)
-    UserMailer.should_receive(:send_later).with(:deliver_changed_answer, answer.owner.mentor, answer)
+    UserMailer.should_receive_delayed(:deliver_changed_answer, answer.owner.mentor, answer)
     answer.content = "changed"
     answer.save!
   end

diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index 8a071c6..7b5e5d9 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -49,7 +49,7 @@ describe Comment do
     answer  = Factory(:answer)
     comment = Comment.new(:owner => answer.owner.mentor, :answer => answer, :content => "some comment")
 
-    UserMailer.should_receive(:send_later).with(:deliver_new_comment, answer.owner, comment)
+    UserMailer.should_receive_delayed(:deliver_new_comment, answer.owner, comment)
 
     comment.save!
   end

diff --git a/spec/models/email_answer_spec.rb b/spec/models/email_answer_spec.rb
index b452a19..3e7096f 100644
--- a/spec/models/email_answer_spec.rb
+++ b/spec/models/email_answer_spec.rb
@@ -7,7 +7,7 @@ describe EmailAnswer do
     mail.subject  = "#{question.id + 1}-#{recruit.token}"
     mail.from     = recruit.email_address
 
-    UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail)
+    UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail)
     EmailAnswer.answer_from_email(mail)
   end
 
@@ -18,7 +18,7 @@ describe EmailAnswer do
     mail.subject  = "#{question.id}-#{recruit.token}"
     mail.from     = recruit.email_address
 
-    UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail)
+    UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail)
     EmailAnswer.answer_from_email(mail)
   end
 

diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb
index b8ff206..0489be4 100644
--- a/spec/models/question_spec.rb
+++ b/spec/models/question_spec.rb
@@ -71,7 +71,7 @@ describe Question do
     question  = Question.new(:title => "new question",
       :question_category => category)
 
-    UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question)
+    UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
 
     question.save!
   end
@@ -82,7 +82,7 @@ describe Question do
     question  = Factory(:question, :title => "new question",
       :question_category => category, :user => Factory(:recruit))
 
-    UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question)
+    UserMailer.should_receive_delayed(:deliver_new_question, recruit, question)
     question.approved = true
     question.save!
   end

diff --git a/spec/support/delayed_should_receive.rb b/spec/support/delayed_should_receive.rb
new file mode 100644
index 0000000..c3a333e
--- /dev/null
+++ b/spec/support/delayed_should_receive.rb
@@ -0,0 +1,11 @@
+class Object
+  def should_receive_delayed(method, *args)
+    m = Spec::Mocks::Mock.new('proxy')
+    if args.empty?
+      m.should_receive(method)
+    else
+      m.should_receive(method).with(*args)
+    end
+    self.should_receive(:delay).and_return(m)
+  end
+end



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-02-22 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 15:55 [gentoo-commits] proj/recruiting-webapp:master commit in: app/models/, spec/models/, spec/support/ Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox