Commit 92bbe720ef4c20de8d7214a9da388e97c8d7dd84
1 parent
e016d4cd
Exists in
master
and in
29 other branches
rails3: fix mass-assignment on approve_article
Showing
1 changed file
with
56 additions
and
56 deletions
Show diff stats
test/unit/approve_article_test.rb
... | ... | @@ -13,20 +13,20 @@ class ApproveArticleTest < ActiveSupport::TestCase |
13 | 13 | attr_reader :profile, :article, :community |
14 | 14 | |
15 | 15 | should 'have name, reference article and profile' do |
16 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
16 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
17 | 17 | |
18 | 18 | assert_equal article, a.article |
19 | 19 | assert_equal community, a.target |
20 | 20 | end |
21 | 21 | |
22 | 22 | should 'have abstract and body' do |
23 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
23 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
24 | 24 | |
25 | 25 | assert_equal ['Lead of article', 'This is my article'], [a.abstract, a.body] |
26 | 26 | end |
27 | 27 | |
28 | 28 | should 'create an article with the same class as original when finished' do |
29 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
29 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
30 | 30 | |
31 | 31 | assert_difference article.class, :count do |
32 | 32 | a.finish |
... | ... | @@ -36,28 +36,28 @@ class ApproveArticleTest < ActiveSupport::TestCase |
36 | 36 | should 'override target notification message method from Task' do |
37 | 37 | p1 = profile |
38 | 38 | p2 = create_user('testuser2').person |
39 | - task = AddFriend.new(:person => p1, :friend => p2) | |
39 | + task = build(AddFriend, :person => p1, :friend => p2) | |
40 | 40 | assert_nothing_raised NotImplementedError do |
41 | 41 | task.target_notification_message |
42 | 42 | end |
43 | 43 | end |
44 | 44 | |
45 | 45 | should 'have parent if defined' do |
46 | - folder = profile.articles.create!(:name => 'test folder', :type => 'Folder') | |
46 | + folder = create(Folder, :name => 'test folder', :profile => profile) | |
47 | 47 | |
48 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile, :article_parent_id => folder.id) | |
48 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => profile, :requestor => profile, :article_parent_id => folder.id) | |
49 | 49 | |
50 | 50 | assert_equal folder, a.article_parent |
51 | 51 | end |
52 | 52 | |
53 | 53 | should 'not have parent if not defined' do |
54 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile) | |
54 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => profile, :requestor => profile) | |
55 | 55 | |
56 | 56 | assert_nil a.article_parent |
57 | 57 | end |
58 | 58 | |
59 | 59 | should 'alert when reference article is removed' do |
60 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => profile) | |
60 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => profile, :requestor => profile) | |
61 | 61 | |
62 | 62 | article.destroy |
63 | 63 | a.reload |
... | ... | @@ -66,13 +66,13 @@ class ApproveArticleTest < ActiveSupport::TestCase |
66 | 66 | end |
67 | 67 | |
68 | 68 | should 'preserve article_parent' do |
69 | - a = ApproveArticle.new(:article_parent => article) | |
69 | + a = build(ApproveArticle, :article_parent => article) | |
70 | 70 | |
71 | 71 | assert_equal article, a.article_parent |
72 | 72 | end |
73 | 73 | |
74 | 74 | should 'handle blank names' do |
75 | - a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile) | |
75 | + a = create(ApproveArticle, :name => '', :article => article, :target => community, :requestor => profile) | |
76 | 76 | |
77 | 77 | assert_difference article.class, :count do |
78 | 78 | a.finish |
... | ... | @@ -84,7 +84,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
84 | 84 | community.save |
85 | 85 | community.stubs(:notification_emails).returns(['adm@example.com']) |
86 | 86 | |
87 | - a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile) | |
87 | + a = create(ApproveArticle, :name => '', :article => article, :target => community, :requestor => profile) | |
88 | 88 | assert !ActionMailer::Base.deliveries.empty? |
89 | 89 | end |
90 | 90 | |
... | ... | @@ -92,7 +92,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
92 | 92 | community.moderated_articles = false |
93 | 93 | community.save |
94 | 94 | |
95 | - a = ApproveArticle.create!(:name => '', :article => article, :target => community, :requestor => profile) | |
95 | + a = create(ApproveArticle, :name => '', :article => article, :target => community, :requestor => profile) | |
96 | 96 | assert ActionMailer::Base.deliveries.empty? |
97 | 97 | end |
98 | 98 | |
... | ... | @@ -100,14 +100,14 @@ class ApproveArticleTest < ActiveSupport::TestCase |
100 | 100 | article.source = 'sample-feed.com' |
101 | 101 | article.save |
102 | 102 | |
103 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
103 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
104 | 104 | a.finish |
105 | 105 | |
106 | 106 | assert_equal article.class.last.source, article.source |
107 | 107 | end |
108 | 108 | |
109 | 109 | should 'have a reference article and profile on published article' do |
110 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
110 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
111 | 111 | a.finish |
112 | 112 | |
113 | 113 | published = article.class.last |
... | ... | @@ -115,14 +115,14 @@ class ApproveArticleTest < ActiveSupport::TestCase |
115 | 115 | end |
116 | 116 | |
117 | 117 | should 'copy name from original article' do |
118 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
118 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
119 | 119 | a.finish |
120 | 120 | |
121 | 121 | assert_equal 'test name', article.class.last.name |
122 | 122 | end |
123 | 123 | |
124 | 124 | should 'be able to edit name of generated article' do |
125 | - a = ApproveArticle.create!(:name => 'Other name', :article => article, :target => community, :requestor => profile) | |
125 | + a = create(ApproveArticle, :name => 'Other name', :article => article, :target => community, :requestor => profile) | |
126 | 126 | a.abstract = 'Abstract edited';a.save |
127 | 127 | a.finish |
128 | 128 | |
... | ... | @@ -130,14 +130,14 @@ class ApproveArticleTest < ActiveSupport::TestCase |
130 | 130 | end |
131 | 131 | |
132 | 132 | should 'copy abstract from original article' do |
133 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
133 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
134 | 134 | a.finish |
135 | 135 | |
136 | 136 | assert_equal 'Lead of article', article.class.last.abstract |
137 | 137 | end |
138 | 138 | |
139 | 139 | should 'be able to edit abstract of generated article' do |
140 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
140 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
141 | 141 | a.abstract = 'Abstract edited';a.save |
142 | 142 | a.finish |
143 | 143 | |
... | ... | @@ -145,14 +145,14 @@ class ApproveArticleTest < ActiveSupport::TestCase |
145 | 145 | end |
146 | 146 | |
147 | 147 | should 'copy body from original article' do |
148 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
148 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
149 | 149 | a.finish |
150 | 150 | |
151 | 151 | assert_equal 'This is my article', article.class.last.body |
152 | 152 | end |
153 | 153 | |
154 | 154 | should 'be able to edit body of generated article' do |
155 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
155 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
156 | 156 | a.body = 'Body edited';a.save |
157 | 157 | a.finish |
158 | 158 | |
... | ... | @@ -164,7 +164,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
164 | 164 | article.parent = profile_blog |
165 | 165 | article.save |
166 | 166 | |
167 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
167 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
168 | 168 | a.finish |
169 | 169 | |
170 | 170 | assert !community.has_blog? |
... | ... | @@ -177,7 +177,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
177 | 177 | article.save |
178 | 178 | |
179 | 179 | community.articles << Blog.new(:profile => community) |
180 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
180 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
181 | 181 | a.finish |
182 | 182 | |
183 | 183 | assert_equal community.blog, article.class.last.parent |
... | ... | @@ -189,7 +189,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
189 | 189 | article.save |
190 | 190 | |
191 | 191 | blog = fast_create(Blog, :profile_id => community.id) |
192 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
192 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
193 | 193 | a.finish |
194 | 194 | |
195 | 195 | assert_nil article.class.last.parent |
... | ... | @@ -203,7 +203,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
203 | 203 | community.articles << Blog.new(:profile => community) |
204 | 204 | community_folder = fast_create(Folder, :profile_id => profile.id) |
205 | 205 | |
206 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile, :article_parent => community_folder) | |
206 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile, :article_parent => community_folder) | |
207 | 207 | a.finish |
208 | 208 | |
209 | 209 | assert_equal community_folder, article.class.last.parent |
... | ... | @@ -211,7 +211,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
211 | 211 | |
212 | 212 | should 'use author from original article on published' do |
213 | 213 | article.class.any_instance.stubs(:author).returns(profile) |
214 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) | |
214 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => community, :requestor => profile) | |
215 | 215 | a.finish |
216 | 216 | |
217 | 217 | assert_equal profile, article.class.last.author |
... | ... | @@ -219,7 +219,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
219 | 219 | |
220 | 220 | should 'use original article author even if article is destroyed' do |
221 | 221 | article.class.any_instance.stubs(:author).returns(profile) |
222 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
222 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
223 | 223 | a.finish |
224 | 224 | |
225 | 225 | article.destroy |
... | ... | @@ -229,14 +229,14 @@ class ApproveArticleTest < ActiveSupport::TestCase |
229 | 229 | |
230 | 230 | should 'the published article have parent if defined' do |
231 | 231 | folder = fast_create(Folder, :profile_id => community.id) |
232 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile, :article_parent => folder) | |
232 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile, :article_parent => folder) | |
233 | 233 | a.finish |
234 | 234 | |
235 | 235 | assert_equal folder, article.class.last.parent |
236 | 236 | end |
237 | 237 | |
238 | 238 | should 'copy to_html from reference_article' do |
239 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
239 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
240 | 240 | a.finish |
241 | 241 | |
242 | 242 | assert_equal article.to_html, article.class.last.to_html |
... | ... | @@ -244,7 +244,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
244 | 244 | |
245 | 245 | should 'notify activity on creating published' do |
246 | 246 | ActionTracker::Record.delete_all |
247 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
247 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
248 | 248 | a.finish |
249 | 249 | |
250 | 250 | assert_equal 1, ActionTracker::Record.count |
... | ... | @@ -254,16 +254,16 @@ class ApproveArticleTest < ActiveSupport::TestCase |
254 | 254 | ActionTracker::Record.delete_all |
255 | 255 | |
256 | 256 | article = fast_create(TextileArticle) |
257 | - a = ApproveArticle.create!(:name => 'bar', :article => article, :target => community, :requestor => profile) | |
257 | + a = create(ApproveArticle, :name => 'bar', :article => article, :target => community, :requestor => profile) | |
258 | 258 | a.finish |
259 | 259 | |
260 | 260 | article = fast_create(TextileArticle) |
261 | - a = ApproveArticle.create!(:name => 'another bar', :article => article, :target => community, :requestor => profile) | |
261 | + a = create(ApproveArticle, :name => 'another bar', :article => article, :target => community, :requestor => profile) | |
262 | 262 | a.finish |
263 | 263 | |
264 | 264 | article = fast_create(TextileArticle) |
265 | 265 | other_community = fast_create(Community) |
266 | - a = ApproveArticle.create!(:name => 'another bar', :article => article, :target => other_community, :requestor => profile) | |
266 | + a = create(ApproveArticle, :name => 'another bar', :article => article, :target => other_community, :requestor => profile) | |
267 | 267 | a.finish |
268 | 268 | assert_equal 3, ActionTracker::Record.count |
269 | 269 | end |
... | ... | @@ -271,12 +271,12 @@ class ApproveArticleTest < ActiveSupport::TestCase |
271 | 271 | should 'not create trackers activity when updating articles' do |
272 | 272 | ActionTracker::Record.delete_all |
273 | 273 | article1 = fast_create(TextileArticle) |
274 | - a = ApproveArticle.create!(:name => 'bar', :article => article1, :target => community, :requestor => profile) | |
274 | + a = create(ApproveArticle, :name => 'bar', :article => article1, :target => community, :requestor => profile) | |
275 | 275 | a.finish |
276 | 276 | |
277 | 277 | article2 = fast_create(TinyMceArticle) |
278 | 278 | other_community = fast_create(Community) |
279 | - a = ApproveArticle.create!(:name => 'another bar', :article => article2, :target => other_community, :requestor => profile) | |
279 | + a = create(ApproveArticle, :name => 'another bar', :article => article2, :target => other_community, :requestor => profile) | |
280 | 280 | a.finish |
281 | 281 | assert_equal 2, ActionTracker::Record.count |
282 | 282 | |
... | ... | @@ -294,7 +294,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
294 | 294 | person = fast_create(Person) |
295 | 295 | community.add_member(person) |
296 | 296 | |
297 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
297 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
298 | 298 | a.finish |
299 | 299 | |
300 | 300 | approved_article = community.articles.find_by_name(article.name) |
... | ... | @@ -306,7 +306,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
306 | 306 | ActionTracker::Record.delete_all |
307 | 307 | person = fast_create(Person) |
308 | 308 | |
309 | - a = ApproveArticle.create!(:article => article, :target => person, :requestor => profile) | |
309 | + a = create(ApproveArticle, :article => article, :target => person, :requestor => profile) | |
310 | 310 | a.finish |
311 | 311 | |
312 | 312 | approved_article = person.articles.find_by_name(article.name) |
... | ... | @@ -315,7 +315,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
315 | 315 | end |
316 | 316 | |
317 | 317 | should "have the same is_trackable method as original article" do |
318 | - a = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
318 | + a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
319 | 319 | a.finish |
320 | 320 | |
321 | 321 | assert_equal article.is_trackable?, article.class.last.is_trackable? |
... | ... | @@ -323,13 +323,13 @@ class ApproveArticleTest < ActiveSupport::TestCase |
323 | 323 | |
324 | 324 | should 'not have target notification message if it is not a moderated oganization' do |
325 | 325 | community.moderated_articles = false; community.save |
326 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
326 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
327 | 327 | |
328 | 328 | assert_nil task.target_notification_message |
329 | 329 | end |
330 | 330 | |
331 | 331 | should 'have target notification message if is organization and not moderated' do |
332 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
332 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
333 | 333 | |
334 | 334 | community.expects(:moderated_articles?).returns(['true']) |
335 | 335 | |
... | ... | @@ -338,52 +338,52 @@ class ApproveArticleTest < ActiveSupport::TestCase |
338 | 338 | |
339 | 339 | should 'have target notification description' do |
340 | 340 | community.moderated_articles = false; community.save |
341 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
341 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
342 | 342 | |
343 | 343 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, task.target_notification_description) |
344 | 344 | end |
345 | 345 | |
346 | 346 | should 'deliver target notification message' do |
347 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
347 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
348 | 348 | |
349 | 349 | community.expects(:notification_emails).returns(['target@example.com']) |
350 | 350 | community.expects(:moderated_articles?).returns(['true']) |
351 | 351 | |
352 | - email = TaskMailer.deliver_target_notification(task, task.target_notification_message) | |
352 | + email = TaskMailer.target_notification(task, task.target_notification_message).deliver | |
353 | 353 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) |
354 | 354 | end |
355 | 355 | |
356 | 356 | should 'deliver target finished message' do |
357 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
357 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
358 | 358 | |
359 | - email = TaskMailer.deliver_task_finished(task) | |
359 | + email = task.send(:send_notification, :finished).deliver | |
360 | 360 | |
361 | 361 | assert_match(/#{task.requestor.name} wants to publish the article: #{article.name}/, email.subject) |
362 | 362 | end |
363 | 363 | |
364 | 364 | should 'deliver target finished message about article deleted' do |
365 | - task = ApproveArticle.new(:article => article, :target => community, :requestor => profile) | |
365 | + task = build(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
366 | 366 | article.destroy |
367 | 367 | |
368 | - email = TaskMailer.deliver_task_finished(task) | |
368 | + email = task.send(:send_notification, :finished).deliver | |
369 | 369 | |
370 | 370 | assert_match(/#{task.requestor.name} wanted to publish an article but it was removed/, email.subject) |
371 | 371 | end |
372 | 372 | |
373 | 373 | should 'approve an event' do |
374 | 374 | event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') |
375 | - task = ApproveArticle.create!(:name => 'Event test', :article => event, :target => community, :requestor => profile) | |
375 | + task = create(ApproveArticle, :name => 'Event test', :article => event, :target => community, :requestor => profile) | |
376 | 376 | assert_difference event.class, :count do |
377 | 377 | task.finish |
378 | 378 | end |
379 | 379 | end |
380 | 380 | |
381 | 381 | should 'approve same article twice changing its name' do |
382 | - task1 = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
382 | + task1 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
383 | 383 | assert_difference article.class, :count do |
384 | 384 | task1.finish |
385 | 385 | end |
386 | - task2 = ApproveArticle.create!(:name => article.name + ' v2', :article => article, :target => community, :requestor => profile) | |
386 | + task2 = create(ApproveArticle, :name => article.name + ' v2', :article => article, :target => community, :requestor => profile) | |
387 | 387 | assert_difference article.class, :count do |
388 | 388 | assert_nothing_raised ActiveRecord::RecordInvalid do |
389 | 389 | task2.finish |
... | ... | @@ -392,11 +392,11 @@ class ApproveArticleTest < ActiveSupport::TestCase |
392 | 392 | end |
393 | 393 | |
394 | 394 | should 'not approve same article twice if not changing its name' do |
395 | - task1 = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
395 | + task1 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
396 | 396 | assert_difference article.class, :count do |
397 | 397 | task1.finish |
398 | 398 | end |
399 | - task2 = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
399 | + task2 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
400 | 400 | assert_no_difference article.class, :count do |
401 | 401 | assert_raises ActiveRecord::RecordInvalid do |
402 | 402 | task2.finish |
... | ... | @@ -405,18 +405,18 @@ class ApproveArticleTest < ActiveSupport::TestCase |
405 | 405 | end |
406 | 406 | |
407 | 407 | should 'return reject message even without reject explanation' do |
408 | - task = ApproveArticle.new(:name => 'My Article') | |
408 | + task = build(ApproveArticle, :name => 'My Article') | |
409 | 409 | assert_not_nil task.task_cancelled_message |
410 | 410 | end |
411 | 411 | |
412 | 412 | should 'show the name of the article in the reject message' do |
413 | - task = ApproveArticle.new(:name => 'My Article') | |
413 | + task = build(ApproveArticle, :name => 'My Article') | |
414 | 414 | assert_match /My Article/, task.task_cancelled_message |
415 | 415 | end |
416 | 416 | |
417 | 417 | should 'not save 4 on the new article\'s last_changed_by_ud after approval if author is nil' do |
418 | 418 | article = fast_create(Article) |
419 | - task = ApproveArticle.create!(:article => article, :target => community, :requestor => profile) | |
419 | + task = create(ApproveArticle, :article => article, :target => community, :requestor => profile) | |
420 | 420 | task.finish |
421 | 421 | new_article = Article.last |
422 | 422 | assert_nil new_article.last_changed_by_id |
... | ... | @@ -424,9 +424,9 @@ class ApproveArticleTest < ActiveSupport::TestCase |
424 | 424 | |
425 | 425 | should 'not crash if target has its own domain' do |
426 | 426 | article = fast_create(Article) |
427 | - profile.domains << Domain.create(:name => 'example.org') | |
427 | + profile.domains << create(Domain, :name => 'example.org') | |
428 | 428 | assert_nothing_raised do |
429 | - ApproveArticle.create!(:article => article, :target => profile, :requestor => community) | |
429 | + create(ApproveArticle, :article => article, :target => profile, :requestor => community) | |
430 | 430 | end |
431 | 431 | end |
432 | 432 | ... | ... |