diff --git a/test/unit/cms_helper_test.rb b/test/unit/cms_helper_test.rb index 9bc0626..3b6fe1d 100644 --- a/test/unit/cms_helper_test.rb +++ b/test/unit/cms_helper_test.rb @@ -1,22 +1,21 @@ require File.dirname(__FILE__) + '/../test_helper' -class CmsHelperTest < ActiveSupport::TestCase +class CmsHelperTest < ActionView::TestCase include CmsHelper include BlogHelper include ApplicationHelper include ActionView::Helpers::UrlHelper + include Noosfero::Plugin::HotSpot should 'show default options for article' do - CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) - result = options_for_article(RssFeed.new(:profile => Profile.new)) + result = options_for_article(build(RssFeed, :profile => Profile.new)) assert_match /id="article_published_true" name="article\[published\]" type="radio" value="true"/, result assert_match /id="article_published_false" name="article\[published\]" type="radio" value="false"/, result assert_match /id="article_accept_comments" name="article\[accept_comments\]" type="checkbox" value="1"/, result end should 'show custom options for blog' do - CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) result = options_for_article(Blog.new) assert_tag_in_string result, :tag => 'input', :attributes => { :name => 'article[published]' , :type => "hidden", :value => "1" } assert_tag_in_string result, :tag => 'input', :attributes => { :name => "article[accept_comments]", :type => "hidden", :value => "0" } @@ -40,7 +39,7 @@ class CmsHelperTest < ActiveSupport::TestCase should 'display image and link if article is an image' do profile = fast_create(Profile) - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) + file = create(UploadedFile, :profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) icon = icon_for_article(file) expects(:image_tag).with(icon).returns('icon') @@ -49,8 +48,7 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'display spread button when profile is a person' do - @controller = ApplicationController.new - @plugins.stubs(:dispatch).returns([]) + plugins.stubs(:dispatch).returns([]) profile = fast_create(Person) article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) expects(:link_to).with('Spread this', {:action => 'publish', :id => article.id}, :class => 'button with-text icon-spread', :title => nil) @@ -59,8 +57,7 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'display spread button when profile is a community and env has portal_community' do - @controller = ApplicationController.new - @plugins.stubs(:dispatch).returns([]) + plugins.stubs(:dispatch).returns([]) env = fast_create(Environment) env.expects(:portal_community).returns(true) profile = fast_create(Community, :environment_id => env.id) @@ -74,8 +71,7 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'not display spread button when profile is a community and env has not portal_community' do - @controller = ApplicationController.new - @plugins.stubs(:dispatch).returns([]) + plugins.stubs(:dispatch).returns([]) env = fast_create(Environment) env.expects(:portal_community).returns(nil) profile = fast_create(Community, :environment_id => env.id) @@ -89,8 +85,7 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'display delete_button to folder' do - @controller = ApplicationController.new - @plugins.stubs(:dispatch).returns([]) + plugins.stubs(:dispatch).returns([]) profile = fast_create(Profile) name = 'My folder' folder = fast_create(Folder, :name => name, :profile_id => profile.id) @@ -101,8 +96,7 @@ class CmsHelperTest < ActiveSupport::TestCase end should 'display delete_button to article' do - @controller = ApplicationController.new - @plugins.stubs(:dispatch).returns([]) + plugins.stubs(:dispatch).returns([]) profile = fast_create(Profile) name = 'My article' article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) @@ -114,6 +108,10 @@ class CmsHelperTest < ActiveSupport::TestCase def link_to(text, *args); puts text; puts args.inspect; text; end + def environment + Environment.default + end + end module RssFeedHelper -- libgit2 0.21.2