Commit e803bf2cded88ced20cc815d65d69d2147eb3c88

Authored by Rodrigo Souto
1 parent 18bbe445

rails3: fix blog_helper tests

Showing 1 changed file with 7 additions and 7 deletions   Show diff stats
test/unit/blog_helper_test.rb
1 require File.dirname(__FILE__) + '/../test_helper' 1 require File.dirname(__FILE__) + '/../test_helper'
2 2
3 -class BlogHelperTest < ActiveSupport::TestCase 3 +class BlogHelperTest < ActionView::TestCase
4 4
5 include BlogHelper 5 include BlogHelper
6 include ContentViewerHelper 6 include ContentViewerHelper
@@ -21,7 +21,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase @@ -21,7 +21,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase
21 def h(s); s; end 21 def h(s); s; end
22 22
23 should 'list published posts with class blog-post' do 23 should 'list published posts with class blog-post' do
24 - blog.children << published_post = TextileArticle.create!(:name => 'Post', :profile => profile, :parent => blog, :published => true) 24 + blog.children << published_post = create(TextileArticle, :name => 'Post', :profile => profile, :parent => blog, :published => true)
25 25
26 expects(:display_post).with(anything, anything).returns('POST') 26 expects(:display_post).with(anything, anything).returns('POST')
27 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last odd-post-inner', :id => "post-#{published_post.id}").returns('POST') 27 expects(:content_tag).with('div', "POST<br style=\"clear:both\"/>", :class => 'blog-post position-1 first last odd-post-inner', :id => "post-#{published_post.id}").returns('POST')
@@ -31,9 +31,9 @@ class BlogHelperTest &lt; ActiveSupport::TestCase @@ -31,9 +31,9 @@ class BlogHelperTest &lt; ActiveSupport::TestCase
31 end 31 end
32 32
33 should 'list even/odd posts with a different class' do 33 should 'list even/odd posts with a different class' do
34 - blog.children << older_post = TextileArticle.create!(:name => 'First post', :profile => profile, :parent => blog, :published => true) 34 + blog.children << older_post = create(TextileArticle, :name => 'First post', :profile => profile, :parent => blog, :published => true)
35 35
36 - blog.children << newer_post = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 36 + blog.children << newer_post = create(TextileArticle, :name => 'Second post', :profile => profile, :parent => blog, :published => true)
37 37
38 expects(:display_post).with(anything, anything).returns('POST').times(2) 38 expects(:display_post).with(anything, anything).returns('POST').times(2)
39 39
@@ -48,7 +48,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase @@ -48,7 +48,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase
48 48
49 49
50 should 'display post' do 50 should 'display post' do
51 - blog.children << article = TextileArticle.create!(:name => 'Second post', :profile => profile, :parent => blog, :published => true) 51 + blog.children << article = create(TextileArticle, :name => 'Second post', :profile => profile, :parent => blog, :published => true)
52 expects(:article_title).with(article, anything).returns('TITLE') 52 expects(:article_title).with(article, anything).returns('TITLE')
53 expects(:content_tag).with('p', article.to_html).returns(' TO_HTML') 53 expects(:content_tag).with('p', article.to_html).returns(' TO_HTML')
54 self.stubs(:params).returns({:npage => nil}) 54 self.stubs(:params).returns({:npage => nil})
@@ -92,7 +92,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase @@ -92,7 +92,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase
92 92
93 93
94 should 'display link to file if post is an uploaded_file' do 94 should 'display link to file if post is an uploaded_file' do
95 - file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => profile, :published => true, :parent => blog) 95 + file = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain'), :profile => profile, :published => true, :parent => blog)
96 96
97 expects(:article_to_html).with(file).returns('TO HTML') 97 expects(:article_to_html).with(file).returns('TO HTML')
98 98
@@ -101,7 +101,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase @@ -101,7 +101,7 @@ class BlogHelperTest &lt; ActiveSupport::TestCase
101 end 101 end
102 102
103 should 'display image if post is an image' do 103 should 'display image if post is an image' do
104 - file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile, :published => true, :parent => blog) 104 + file = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile, :published => true, :parent => blog)
105 105
106 self.stubs(:params).returns({:npage => nil}) 106 self.stubs(:params).returns({:npage => nil})
107 107