Commit 631b96a015bb5226ecd5bccf956f21e06e8cc9d6
1 parent
d9680fb6
Exists in
master
and in
29 other branches
rails3: fix rss_feed tests
Showing
3 changed files
with
19 additions
and
18 deletions
Show diff stats
app/models/article.rb
app/models/rss_feed.rb
test/unit/rss_feed_test.rb
... | ... | @@ -29,7 +29,7 @@ class RssFeedTest < ActiveSupport::TestCase |
29 | 29 | a2 = profile.articles.build(:name => 'article 2'); a2.save! |
30 | 30 | a3 = profile.articles.build(:name => 'article 3'); a3.save! |
31 | 31 | |
32 | - feed = RssFeed.new(:name => 'testfeed') | |
32 | + feed = build(RssFeed, :name => 'testfeed') | |
33 | 33 | feed.profile = profile |
34 | 34 | feed.save! |
35 | 35 | |
... | ... | @@ -45,7 +45,7 @@ class RssFeedTest < ActiveSupport::TestCase |
45 | 45 | a2 = profile.articles.build(:name => 'article 2'); a2.save! |
46 | 46 | a3 = profile.articles.build(:name => 'article 3'); a3.save! |
47 | 47 | |
48 | - feed = RssFeed.new(:name => 'testfeed') | |
48 | + feed = build(RssFeed, :name => 'testfeed') | |
49 | 49 | feed.profile = profile |
50 | 50 | feed.save! |
51 | 51 | |
... | ... | @@ -73,7 +73,7 @@ class RssFeedTest < ActiveSupport::TestCase |
73 | 73 | a3_2_1 = a3_2.children.build(:name => 'article 3.2.1', :parent => a3_2, :profile => profile); a3_2_1.save! |
74 | 74 | |
75 | 75 | a3.reload |
76 | - feed = RssFeed.new(:name => 'testfeed') | |
76 | + feed = build(RssFeed, :name => 'testfeed') | |
77 | 77 | feed.parent = a3 |
78 | 78 | feed.profile = profile |
79 | 79 | feed.include = 'parent_and_children' |
... | ... | @@ -91,7 +91,7 @@ class RssFeedTest < ActiveSupport::TestCase |
91 | 91 | |
92 | 92 | should 'list blog posts with more recent first and respecting limit' do |
93 | 93 | profile = create_user('testuser').person |
94 | - blog = Blog.create!(:name => 'blog-test', :profile => profile) | |
94 | + blog = create(Blog, :name => 'blog-test', :profile => profile) | |
95 | 95 | posts = [] |
96 | 96 | 6.times do |i| |
97 | 97 | posts << fast_create(TextArticle, :name => "post #{i}", :profile_id => profile.id, :parent_id => blog.id) |
... | ... | @@ -105,7 +105,7 @@ class RssFeedTest < ActiveSupport::TestCase |
105 | 105 | |
106 | 106 | should 'list only published posts from blog' do |
107 | 107 | profile = create_user('testuser').person |
108 | - blog = Blog.create!(:name => 'blog-test', :profile => profile) | |
108 | + blog = create(Blog, :name => 'blog-test', :profile => profile) | |
109 | 109 | posts = [] |
110 | 110 | 5.times do |i| |
111 | 111 | posts << fast_create(TextArticle, :name => "post #{i}", :profile_id => profile.id, :parent_id => blog.id) |
... | ... | @@ -119,17 +119,17 @@ class RssFeedTest < ActiveSupport::TestCase |
119 | 119 | |
120 | 120 | should 'provide link to profile' do |
121 | 121 | profile = create_user('testuser').person |
122 | - feed = RssFeed.new(:name => 'testfeed') | |
122 | + feed = build(RssFeed, :name => 'testfeed') | |
123 | 123 | feed.profile = profile |
124 | 124 | feed.save! |
125 | 125 | |
126 | - assert_match "<link>http://#{profile.environment.default_hostname}/testuser</link>", feed.data | |
126 | + assert_match "<link>http://#{profile.environment.default_hostname}/testuser/homepage</link>", feed.data | |
127 | 127 | end |
128 | 128 | |
129 | 129 | should 'provide link to each article' do |
130 | 130 | profile = create_user('testuser').person |
131 | 131 | art = profile.articles.build(:name => 'myarticle'); art.save! |
132 | - feed = RssFeed.new(:name => 'testfeed') | |
132 | + feed = build(RssFeed, :name => 'testfeed') | |
133 | 133 | feed.profile = profile |
134 | 134 | feed.save! |
135 | 135 | |
... | ... | @@ -144,7 +144,7 @@ class RssFeedTest < ActiveSupport::TestCase |
144 | 144 | a2 = profile.articles.build(:name => 'article 2'); a2.save! |
145 | 145 | a3 = profile.articles.build(:name => 'article 3'); a3.save! |
146 | 146 | |
147 | - feed = RssFeed.new(:name => 'testfeed') | |
147 | + feed = build(RssFeed, :name => 'testfeed') | |
148 | 148 | feed.profile = profile |
149 | 149 | feed.save! |
150 | 150 | |
... | ... | @@ -195,13 +195,13 @@ class RssFeedTest < ActiveSupport::TestCase |
195 | 195 | |
196 | 196 | should 'advertise is false before create' do |
197 | 197 | profile = create_user('testuser').person |
198 | - feed = RssFeed.create!(:name => 'testfeed', :profile => profile) | |
198 | + feed = create(RssFeed, :name => 'testfeed', :profile => profile) | |
199 | 199 | assert !feed.advertise? |
200 | 200 | end |
201 | 201 | |
202 | 202 | should 'can display hits' do |
203 | 203 | p = create_user('testuser').person |
204 | - a = RssFeed.create!(:name => 'Test article', :profile => p) | |
204 | + a = create(RssFeed, :name => 'Test article', :profile => p) | |
205 | 205 | assert_equal false, a.can_display_hits? |
206 | 206 | end |
207 | 207 | |
... | ... | @@ -209,14 +209,15 @@ class RssFeedTest < ActiveSupport::TestCase |
209 | 209 | article = fast_create(TextileArticle, :body => 'This is the content of the Sample Article.', :profile_id => fast_create(Person).id) |
210 | 210 | profile = fast_create(Profile) |
211 | 211 | blog = fast_create(Blog, :profile_id => profile.id) |
212 | - a = ApproveArticle.create!(:name => 'test name', :article => article, :target => profile, :requestor => fast_create(Person)) | |
212 | + a = create(ApproveArticle, :name => 'test name', :article => article, :target => profile, :requestor => fast_create(Person)) | |
213 | + a.requestor.stubs(:notification_emails).returns(['random@example.org']) | |
213 | 214 | a.finish |
214 | 215 | |
215 | 216 | published_article = article.class.last |
216 | 217 | published_article.parent = blog |
217 | 218 | published_article.save |
218 | 219 | |
219 | - feed = RssFeed.new(:parent => blog, :profile => profile) | |
220 | + feed = build(RssFeed, :parent => blog, :profile => profile) | |
220 | 221 | |
221 | 222 | assert_match "This is the content of the Sample Article", feed.data |
222 | 223 | end |
... | ... | @@ -229,7 +230,7 @@ class RssFeedTest < ActiveSupport::TestCase |
229 | 230 | a2 = profile.articles.build(:name => 'article 2'); a2.save! |
230 | 231 | a3 = profile.articles.build(:name => 'article 3'); a3.save! |
231 | 232 | |
232 | - feed = RssFeed.new(:name => 'testfeed') | |
233 | + feed = build(RssFeed, :name => 'testfeed') | |
233 | 234 | feed.profile = profile |
234 | 235 | feed.save! |
235 | 236 | |
... | ... | @@ -245,7 +246,7 @@ class RssFeedTest < ActiveSupport::TestCase |
245 | 246 | |
246 | 247 | should 'include posts from all languages' do |
247 | 248 | profile = create_user('testuser').person |
248 | - blog = Blog.create!(:name => 'blog-test', :profile => profile, :language => nil) | |
249 | + blog = create(Blog, :name => 'blog-test', :profile => profile, :language => nil) | |
249 | 250 | blog.posts << en_post = fast_create(TextArticle, :name => "English", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'en') |
250 | 251 | blog.posts << es_post = fast_create(TextArticle, :name => "Spanish", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'es') |
251 | 252 | |
... | ... | @@ -255,7 +256,7 @@ class RssFeedTest < ActiveSupport::TestCase |
255 | 256 | |
256 | 257 | should 'include only posts from some language' do |
257 | 258 | profile = create_user('testuser').person |
258 | - blog = Blog.create!(:name => 'blog-test', :profile => profile) | |
259 | + blog = create(Blog, :name => 'blog-test', :profile => profile) | |
259 | 260 | blog.feed.update_attributes! :language => 'es' |
260 | 261 | blog.posts << en_post = fast_create(TextArticle, :name => "English", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'en') |
261 | 262 | blog.posts << es_post = fast_create(TextArticle, :name => "Spanish", :profile_id => profile.id, :parent_id => blog.id, :published => true, :language => 'es') | ... | ... |