Commit f2ad43c7f26a2c5491e7357ec1da32f5ed808f10

Authored by Antonio Terceiro
1 parent 7d11a564

ActionItem1049: fixing tests

test/unit/application_helper_test.rb
@@ -178,13 +178,9 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -178,13 +178,9 @@ class ApplicationHelperTest < Test::Unit::TestCase
178 assert_equal 'sampleuser', theme_owner 178 assert_equal 'sampleuser', theme_owner
179 end 179 end
180 180
181 - should 'use default template when no profile' do 181 + should 'use default template when there is no profile' do
182 stubs(:profile).returns(nil) 182 stubs(:profile).returns(nil)
183 -  
184 - foo = mock  
185 - expects(:stylesheet_link_tag).with('/designs/templates/default/stylesheets/style.css').returns(foo)  
186 -  
187 - assert_same foo, template_stylesheet_tag 183 + assert_equal "@import url(/designs/templates/default/stylesheets/style.css);", template_stylesheet_tag
188 end 184 end
189 185
190 should 'use template from profile' do 186 should 'use template from profile' do
@@ -193,7 +189,7 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -193,7 +189,7 @@ class ApplicationHelperTest < Test::Unit::TestCase
193 stubs(:profile).returns(profile) 189 stubs(:profile).returns(profile)
194 190
195 foo = mock 191 foo = mock
196 - expects(:stylesheet_link_tag).with('/designs/templates/mytemplate/stylesheets/style.css').returns(foo) 192 + expects(:stylesheet_import).with('/designs/templates/mytemplate/stylesheets/style.css').returns(foo)
197 193
198 assert_same foo, template_stylesheet_tag 194 assert_same foo, template_stylesheet_tag
199 end 195 end
@@ -232,6 +228,8 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -232,6 +228,8 @@ class ApplicationHelperTest < Test::Unit::TestCase
232 end 228 end
233 229
234 should 'create rss feed link to blog' do 230 should 'create rss feed link to blog' do
  231 + @controller = mock
  232 + @controller.stubs(:controller_name).returns('content_viewer')
235 p = create_user('testuser').person 233 p = create_user('testuser').person
236 b = Blog.create!(:profile => p, :name => 'blog_feed_test') 234 b = Blog.create!(:profile => p, :name => 'blog_feed_test')
237 assert_tag_in_string meta_tags_for_article(b), :tag => 'link', :attributes => {:type => 'application/rss+xml', :title => 'feed'} 235 assert_tag_in_string meta_tags_for_article(b), :tag => 'link', :attributes => {:type => 'application/rss+xml', :title => 'feed'}
@@ -464,7 +462,7 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -464,7 +462,7 @@ class ApplicationHelperTest < Test::Unit::TestCase
464 e = Environment.default 462 e = Environment.default
465 e.icon_theme = 'something-very-unlikely' 463 e.icon_theme = 'something-very-unlikely'
466 stubs(:environment).returns(e) 464 stubs(:environment).returns(e)
467 - assert_equal "<!-- Not included: /designs/icons/something-very-unlikely/style.css -->\n/designs/icons/default/style.css", icon_theme_stylesheet_tag 465 + assert_equal "@import url(/designs/icons/default/style.css);", icon_theme_stylesheet_tag
468 end 466 end
469 467
470 protected 468 protected
test/unit/blog_helper_test.rb
@@ -20,7 +20,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -20,7 +20,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
20 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true) 20 blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true)
21 21
22 expects(:display_post).with(anything).returns('POST') 22 expects(:display_post).with(anything).returns('POST')
23 - expects(:content_tag).with('div', 'POST', :class => 'blog-post', :id => "post-#{published_post.id}").returns('RESULT') 23 + expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last', :id => "post-#{published_post.id}").returns('RESULT')
24 24
25 assert_equal 'RESULT', list_posts(profile, blog.posts) 25 assert_equal 'RESULT', list_posts(profile, blog.posts)
26 end 26 end
@@ -29,7 +29,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -29,7 +29,7 @@ class BlogHelperTest &lt; Test::Unit::TestCase
29 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false) 29 blog.children << unpublished_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => false)
30 30
31 expects(:display_post).with(anything).returns('POST') 31 expects(:display_post).with(anything).returns('POST')
32 - expects(:content_tag).with('div', 'POST', :class => 'blog-post-not-published', :id => "post-#{unpublished_post.id}").returns('RESULT') 32 + expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first last not-published', :id => "post-#{unpublished_post.id}").returns('RESULT')
33 33
34 assert_equal 'RESULT', list_posts(profile, blog.posts) 34 assert_equal 'RESULT', list_posts(profile, blog.posts)
35 end 35 end
@@ -40,8 +40,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase @@ -40,8 +40,8 @@ class BlogHelperTest &lt; Test::Unit::TestCase
40 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 40 blog.children << published_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true)
41 41
42 expects(:display_post).with(anything).returns('POST') 42 expects(:display_post).with(anything).returns('POST')
43 - expects(:content_tag).with('div', 'POST', :class => 'blog-post', :id => "post-#{published_post.id}").returns('RESULT')  
44 - expects(:content_tag).with('div', 'POST', :class => 'blog-post-not-published', :id => "post-#{unpublished_post.id}").never 43 + expects(:content_tag).with('div', 'POST', :class => 'blog-post position-2 last', :id => "post-#{published_post.id}").returns('RESULT')
  44 + expects(:content_tag).with('div', 'POST', :class => 'blog-post position-1 first', :id => "post-#{unpublished_post.id}").never
45 45
46 assert_equal 'RESULT', list_posts(nil, blog.posts) 46 assert_equal 'RESULT', list_posts(nil, blog.posts)
47 end 47 end
test/unit/blog_test.rb
@@ -51,9 +51,9 @@ class BlogTest &lt; ActiveSupport::TestCase @@ -51,9 +51,9 @@ class BlogTest &lt; ActiveSupport::TestCase
51 assert_equal 7, p.blog.feed.limit 51 assert_equal 7, p.blog.feed.limit
52 end 52 end
53 53
54 - should 'list 20 posts per page by default' do 54 + should 'list 5 posts per page by default' do
55 blog = Blog.new 55 blog = Blog.new
56 - assert_equal 20, blog.posts_per_page 56 + assert_equal 5, blog.posts_per_page
57 end 57 end
58 58
59 should 'update posts per page setting' do 59 should 'update posts per page setting' do
test/unit/communities_block_test.rb
@@ -7,6 +7,7 @@ class CommunitiesBlockTest &lt; Test::Unit::TestCase @@ -7,6 +7,7 @@ class CommunitiesBlockTest &lt; Test::Unit::TestCase
7 end 7 end
8 8
9 should 'declare its default title' do 9 should 'declare its default title' do
  10 + CommunitiesBlock.any_instance.stubs(:profile_count).returns(0)
10 assert_not_equal ProfileListBlock.new.default_title, CommunitiesBlock.new.default_title 11 assert_not_equal ProfileListBlock.new.default_title, CommunitiesBlock.new.default_title
11 end 12 end
12 13
test/unit/enterprises_block_test.rb
@@ -7,6 +7,7 @@ class EnterprisesBlockTest &lt; Test::Unit::TestCase @@ -7,6 +7,7 @@ class EnterprisesBlockTest &lt; Test::Unit::TestCase
7 end 7 end
8 8
9 should 'declare its default title' do 9 should 'declare its default title' do
  10 + EnterprisesBlock.any_instance.stubs(:profile_count).returns(0)
10 assert_not_equal ProfileListBlock.new.default_title, EnterprisesBlock.new.default_title 11 assert_not_equal ProfileListBlock.new.default_title, EnterprisesBlock.new.default_title
11 end 12 end
12 13
test/unit/friends_block_test.rb
@@ -7,6 +7,7 @@ class FriendsBlockTest &lt; ActiveSupport::TestCase @@ -7,6 +7,7 @@ class FriendsBlockTest &lt; ActiveSupport::TestCase
7 end 7 end
8 8
9 should 'declare its default title' do 9 should 'declare its default title' do
  10 + FriendsBlock.any_instance.stubs(:profile_count).returns(0)
10 assert_not_equal ProfileListBlock.new.default_title, FriendsBlock.new.default_title 11 assert_not_equal ProfileListBlock.new.default_title, FriendsBlock.new.default_title
11 end 12 end
12 13
test/unit/profile_image_block_test.rb
@@ -9,12 +9,12 @@ class ProfileImageBlockTest &lt; Test::Unit::TestCase @@ -9,12 +9,12 @@ class ProfileImageBlockTest &lt; Test::Unit::TestCase
9 should 'display profile image' do 9 should 'display profile image' do
10 block = ProfileImageBlock.new 10 block = ProfileImageBlock.new
11 11
12 - self.expects(:render).with(:file => 'blocks/profile_image', :locals => { :block => block}) 12 + self.expects(:render).with(:file => 'blocks/profile_image', :locals => { :block => block, :show_name => false})
13 instance_eval(& block.content) 13 instance_eval(& block.content)
14 end 14 end
15 15
16 should 'not be editable' do 16 should 'not be editable' do
17 - assert !ProfileImageBlock.new.editable? 17 + assert ProfileImageBlock.new.editable?
18 end 18 end
19 19
20 end 20 end