1 |
commit: 4396a16a976a46b11ecf281b5be054a0379ff35b |
2 |
Author: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Feb 20 19:33:44 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 22 15:53:53 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/recruiting-webapp.git;a=commit;h=4396a16a |
7 |
|
8 |
Fix deprecation warnings from delayed_job |
9 |
|
10 |
--- |
11 |
app/models/answer.rb | 4 ++-- |
12 |
app/models/comment.rb | 2 +- |
13 |
app/models/email_answer.rb | 2 +- |
14 |
app/models/question.rb | 2 +- |
15 |
spec/models/answer_spec.rb | 4 ++-- |
16 |
spec/models/comment_spec.rb | 2 +- |
17 |
spec/models/email_answer_spec.rb | 4 ++-- |
18 |
spec/models/question_spec.rb | 4 ++-- |
19 |
spec/support/delayed_should_receive.rb | 11 +++++++++++ |
20 |
9 files changed, 23 insertions(+), 12 deletions(-) |
21 |
|
22 |
diff --git a/app/models/answer.rb b/app/models/answer.rb |
23 |
index d477e26..73e7750 100644 |
24 |
--- a/app/models/answer.rb |
25 |
+++ b/app/models/answer.rb |
26 |
@@ -149,12 +149,12 @@ class Answer < ActiveRecord::Base |
27 |
protected |
28 |
# Sends email notification about new answer to mentor of owner |
29 |
def notify_new_answer |
30 |
- UserMailer.send_later(:deliver_new_answer, owner.mentor, self) unless owner._?.mentor.nil? |
31 |
+ UserMailer.delay.deliver_new_answer(owner.mentor, self) unless owner._?.mentor.nil? |
32 |
end |
33 |
|
34 |
# Sends email notification about changed answer to mentor of owner |
35 |
def notify_changed_answer |
36 |
- UserMailer.send_later(:deliver_changed_answer, owner.mentor, self) unless owner._?.mentor.nil? |
37 |
+ UserMailer.delay.deliver_changed_answer(owner.mentor, self) unless owner._?.mentor.nil? |
38 |
end |
39 |
|
40 |
end |
41 |
|
42 |
diff --git a/app/models/comment.rb b/app/models/comment.rb |
43 |
index c10a8f2..cfbf1c1 100644 |
44 |
--- a/app/models/comment.rb |
45 |
+++ b/app/models/comment.rb |
46 |
@@ -47,6 +47,6 @@ class Comment < ActiveRecord::Base |
47 |
protected |
48 |
# Sends notification about new comment to owner of mentor |
49 |
def notify_new_comment |
50 |
- UserMailer.send_later(:deliver_new_comment, answer.owner, self) |
51 |
+ UserMailer.delay.deliver_new_comment(answer.owner, self) |
52 |
end |
53 |
end |
54 |
|
55 |
diff --git a/app/models/email_answer.rb b/app/models/email_answer.rb |
56 |
index ffec1ac..5db9b97 100644 |
57 |
--- a/app/models/email_answer.rb |
58 |
+++ b/app/models/email_answer.rb |
59 |
@@ -36,7 +36,7 @@ class EmailAnswer < Answer |
60 |
question = Question.first :conditions => { :id => subject.captures[0] } |
61 |
|
62 |
if(question.nil? || !question.content.is_a?(QuestionContentEmail)) |
63 |
- UserMailer.send_later(:deliver_unrecognized_email, user, email) |
64 |
+ UserMailer.delay.deliver_unrecognized_email(user, email) |
65 |
return |
66 |
end |
67 |
|
68 |
|
69 |
diff --git a/app/models/question.rb b/app/models/question.rb |
70 |
index c377d5e..b8cfed6 100644 |
71 |
--- a/app/models/question.rb |
72 |
+++ b/app/models/question.rb |
73 |
@@ -186,7 +186,7 @@ class Question < ActiveRecord::Base |
74 |
# If question category isn't assigned don't try to access it |
75 |
if question_category && approved |
76 |
for user in question_category.users |
77 |
- UserMailer.send_later(:deliver_new_question, user, self) |
78 |
+ UserMailer.delay.deliver_new_question(user, self) |
79 |
end |
80 |
end |
81 |
end |
82 |
|
83 |
diff --git a/spec/models/answer_spec.rb b/spec/models/answer_spec.rb |
84 |
index 200077d..de72393 100644 |
85 |
--- a/spec/models/answer_spec.rb |
86 |
+++ b/spec/models/answer_spec.rb |
87 |
@@ -141,14 +141,14 @@ describe Answer do |
88 |
#can't use Factory Girl here, because we want to save it after setting expectation to get email |
89 |
answer = Answer.new(:owner => recruit, :question => question, :content => "Some answer.") |
90 |
|
91 |
- UserMailer.should_receive(:send_later).with(:deliver_new_answer, recruit.mentor, answer) |
92 |
+ UserMailer.should_receive_delayed(:deliver_new_answer, recruit.mentor, answer) |
93 |
|
94 |
answer.save! |
95 |
end |
96 |
|
97 |
it "should send email notification to mentor when changed" do |
98 |
answer = Factory(:answer) |
99 |
- UserMailer.should_receive(:send_later).with(:deliver_changed_answer, answer.owner.mentor, answer) |
100 |
+ UserMailer.should_receive_delayed(:deliver_changed_answer, answer.owner.mentor, answer) |
101 |
answer.content = "changed" |
102 |
answer.save! |
103 |
end |
104 |
|
105 |
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb |
106 |
index 8a071c6..7b5e5d9 100644 |
107 |
--- a/spec/models/comment_spec.rb |
108 |
+++ b/spec/models/comment_spec.rb |
109 |
@@ -49,7 +49,7 @@ describe Comment do |
110 |
answer = Factory(:answer) |
111 |
comment = Comment.new(:owner => answer.owner.mentor, :answer => answer, :content => "some comment") |
112 |
|
113 |
- UserMailer.should_receive(:send_later).with(:deliver_new_comment, answer.owner, comment) |
114 |
+ UserMailer.should_receive_delayed(:deliver_new_comment, answer.owner, comment) |
115 |
|
116 |
comment.save! |
117 |
end |
118 |
|
119 |
diff --git a/spec/models/email_answer_spec.rb b/spec/models/email_answer_spec.rb |
120 |
index b452a19..3e7096f 100644 |
121 |
--- a/spec/models/email_answer_spec.rb |
122 |
+++ b/spec/models/email_answer_spec.rb |
123 |
@@ -7,7 +7,7 @@ describe EmailAnswer do |
124 |
mail.subject = "#{question.id + 1}-#{recruit.token}" |
125 |
mail.from = recruit.email_address |
126 |
|
127 |
- UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail) |
128 |
+ UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail) |
129 |
EmailAnswer.answer_from_email(mail) |
130 |
end |
131 |
|
132 |
@@ -18,7 +18,7 @@ describe EmailAnswer do |
133 |
mail.subject = "#{question.id}-#{recruit.token}" |
134 |
mail.from = recruit.email_address |
135 |
|
136 |
- UserMailer.should_receive(:send_later).with(:deliver_unrecognized_email, recruit, mail) |
137 |
+ UserMailer.should_receive_delayed(:deliver_unrecognized_email, recruit, mail) |
138 |
EmailAnswer.answer_from_email(mail) |
139 |
end |
140 |
|
141 |
|
142 |
diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb |
143 |
index b8ff206..0489be4 100644 |
144 |
--- a/spec/models/question_spec.rb |
145 |
+++ b/spec/models/question_spec.rb |
146 |
@@ -71,7 +71,7 @@ describe Question do |
147 |
question = Question.new(:title => "new question", |
148 |
:question_category => category) |
149 |
|
150 |
- UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question) |
151 |
+ UserMailer.should_receive_delayed(:deliver_new_question, recruit, question) |
152 |
|
153 |
question.save! |
154 |
end |
155 |
@@ -82,7 +82,7 @@ describe Question do |
156 |
question = Factory(:question, :title => "new question", |
157 |
:question_category => category, :user => Factory(:recruit)) |
158 |
|
159 |
- UserMailer.should_receive(:send_later).with(:deliver_new_question, recruit, question) |
160 |
+ UserMailer.should_receive_delayed(:deliver_new_question, recruit, question) |
161 |
question.approved = true |
162 |
question.save! |
163 |
end |
164 |
|
165 |
diff --git a/spec/support/delayed_should_receive.rb b/spec/support/delayed_should_receive.rb |
166 |
new file mode 100644 |
167 |
index 0000000..c3a333e |
168 |
--- /dev/null |
169 |
+++ b/spec/support/delayed_should_receive.rb |
170 |
@@ -0,0 +1,11 @@ |
171 |
+class Object |
172 |
+ def should_receive_delayed(method, *args) |
173 |
+ m = Spec::Mocks::Mock.new('proxy') |
174 |
+ if args.empty? |
175 |
+ m.should_receive(method) |
176 |
+ else |
177 |
+ m.should_receive(method).with(*args) |
178 |
+ end |
179 |
+ self.should_receive(:delay).and_return(m) |
180 |
+ end |
181 |
+end |