Commit bff86e47093019ee034e7fc11b5a8d7a87407016
1 parent
b827a3e8
Exists in
staging
and in
42 other branches
rails3: fix cms_helper tests
PS: there is still one test failing due to deprecated observe_field.
Showing
1 changed file
with
13 additions
and
15 deletions
Show diff stats
test/unit/cms_helper_test.rb
| 1 | 1 | require File.dirname(__FILE__) + '/../test_helper' |
| 2 | 2 | |
| 3 | -class CmsHelperTest < ActiveSupport::TestCase | |
| 3 | +class CmsHelperTest < ActionView::TestCase | |
| 4 | 4 | |
| 5 | 5 | include CmsHelper |
| 6 | 6 | include BlogHelper |
| 7 | 7 | include ApplicationHelper |
| 8 | 8 | include ActionView::Helpers::UrlHelper |
| 9 | + include Noosfero::Plugin::HotSpot | |
| 9 | 10 | |
| 10 | 11 | should 'show default options for article' do |
| 11 | - CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) | |
| 12 | - result = options_for_article(RssFeed.new(:profile => Profile.new)) | |
| 12 | + result = options_for_article(build(RssFeed, :profile => Profile.new)) | |
| 13 | 13 | assert_match /id="article_published_true" name="article\[published\]" type="radio" value="true"/, result |
| 14 | 14 | assert_match /id="article_published_false" name="article\[published\]" type="radio" value="false"/, result |
| 15 | 15 | assert_match /id="article_accept_comments" name="article\[accept_comments\]" type="checkbox" value="1"/, result |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | 18 | should 'show custom options for blog' do |
| 19 | - CmsHelperTest.any_instance.stubs(:controller).returns(ActionController::Base.new) | |
| 20 | 19 | result = options_for_article(Blog.new) |
| 21 | 20 | assert_tag_in_string result, :tag => 'input', :attributes => { :name => 'article[published]' , :type => "hidden", :value => "1" } |
| 22 | 21 | assert_tag_in_string result, :tag => 'input', :attributes => { :name => "article[accept_comments]", :type => "hidden", :value => "0" } |
| ... | ... | @@ -40,7 +39,7 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 40 | 39 | |
| 41 | 40 | should 'display image and link if article is an image' do |
| 42 | 41 | profile = fast_create(Profile) |
| 43 | - file = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | |
| 42 | + file = create(UploadedFile, :profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) | |
| 44 | 43 | icon = icon_for_article(file) |
| 45 | 44 | expects(:image_tag).with(icon).returns('icon') |
| 46 | 45 | |
| ... | ... | @@ -49,8 +48,7 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 49 | 48 | end |
| 50 | 49 | |
| 51 | 50 | should 'display spread button when profile is a person' do |
| 52 | - @controller = ApplicationController.new | |
| 53 | - @plugins.stubs(:dispatch).returns([]) | |
| 51 | + plugins.stubs(:dispatch).returns([]) | |
| 54 | 52 | profile = fast_create(Person) |
| 55 | 53 | article = fast_create(TinyMceArticle, :name => 'My article', :profile_id => profile.id) |
| 56 | 54 | 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 |
| 59 | 57 | end |
| 60 | 58 | |
| 61 | 59 | should 'display spread button when profile is a community and env has portal_community' do |
| 62 | - @controller = ApplicationController.new | |
| 63 | - @plugins.stubs(:dispatch).returns([]) | |
| 60 | + plugins.stubs(:dispatch).returns([]) | |
| 64 | 61 | env = fast_create(Environment) |
| 65 | 62 | env.expects(:portal_community).returns(true) |
| 66 | 63 | profile = fast_create(Community, :environment_id => env.id) |
| ... | ... | @@ -74,8 +71,7 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 74 | 71 | end |
| 75 | 72 | |
| 76 | 73 | should 'not display spread button when profile is a community and env has not portal_community' do |
| 77 | - @controller = ApplicationController.new | |
| 78 | - @plugins.stubs(:dispatch).returns([]) | |
| 74 | + plugins.stubs(:dispatch).returns([]) | |
| 79 | 75 | env = fast_create(Environment) |
| 80 | 76 | env.expects(:portal_community).returns(nil) |
| 81 | 77 | profile = fast_create(Community, :environment_id => env.id) |
| ... | ... | @@ -89,8 +85,7 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 89 | 85 | end |
| 90 | 86 | |
| 91 | 87 | should 'display delete_button to folder' do |
| 92 | - @controller = ApplicationController.new | |
| 93 | - @plugins.stubs(:dispatch).returns([]) | |
| 88 | + plugins.stubs(:dispatch).returns([]) | |
| 94 | 89 | profile = fast_create(Profile) |
| 95 | 90 | name = 'My folder' |
| 96 | 91 | folder = fast_create(Folder, :name => name, :profile_id => profile.id) |
| ... | ... | @@ -101,8 +96,7 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 101 | 96 | end |
| 102 | 97 | |
| 103 | 98 | should 'display delete_button to article' do |
| 104 | - @controller = ApplicationController.new | |
| 105 | - @plugins.stubs(:dispatch).returns([]) | |
| 99 | + plugins.stubs(:dispatch).returns([]) | |
| 106 | 100 | profile = fast_create(Profile) |
| 107 | 101 | name = 'My article' |
| 108 | 102 | article = fast_create(TinyMceArticle, :name => name, :profile_id => profile.id) |
| ... | ... | @@ -114,6 +108,10 @@ class CmsHelperTest < ActiveSupport::TestCase |
| 114 | 108 | |
| 115 | 109 | def link_to(text, *args); puts text; puts args.inspect; text; end |
| 116 | 110 | |
| 111 | + def environment | |
| 112 | + Environment.default | |
| 113 | + end | |
| 114 | + | |
| 117 | 115 | end |
| 118 | 116 | |
| 119 | 117 | module RssFeedHelper | ... | ... |