Commit c4affd13a72a6afcb0420d6e2dde5411b8792ef4
Committed by
Daniela Feitosa
1 parent
3f54dc4f
Exists in
master
and in
22 other branches
Moving all testing fake helper methods to test_helper
Showing
9 changed files
with
46 additions
and
115 deletions
Show diff stats
test/test_helper.rb
| ... | ... | @@ -233,8 +233,9 @@ module NoosferoTestHelper |
| 233 | 233 | '' |
| 234 | 234 | end |
| 235 | 235 | |
| 236 | - def tag(tag) | |
| 237 | - "<#{tag}/>" | |
| 236 | + def tag(tag, args = {}) | |
| 237 | + attrs = args.map{|k,v| "#{k}='#{v}'"}.join(' ') | |
| 238 | + "<#{tag} #{attrs} />" | |
| 238 | 239 | end |
| 239 | 240 | |
| 240 | 241 | def options_from_collection_for_select(collection, value_method, content_method) |
| ... | ... | @@ -245,7 +246,7 @@ module NoosferoTestHelper |
| 245 | 246 | "<select id='#{id}'>fake content</select>" |
| 246 | 247 | end |
| 247 | 248 | |
| 248 | - def options_for_select(collection) | |
| 249 | + def options_for_select(collection, selected = nil) | |
| 249 | 250 | collection.map{|item| "<option value='#{item[1]}'>#{item[0]}</option>"}.join("\n") |
| 250 | 251 | end |
| 251 | 252 | |
| ... | ... | @@ -259,6 +260,35 @@ module NoosferoTestHelper |
| 259 | 260 | |
| 260 | 261 | def will_paginate(arg1, arg2) |
| 261 | 262 | end |
| 263 | + | |
| 264 | + def url_for(args = {}) | |
| 265 | + args | |
| 266 | + end | |
| 267 | + def javascript_tag(any) | |
| 268 | + '' | |
| 269 | + end | |
| 270 | + def javascript_include_tag(any) | |
| 271 | + '' | |
| 272 | + end | |
| 273 | + def check_box_tag(name, value = 1, checked = false, options = {}) | |
| 274 | + name | |
| 275 | + end | |
| 276 | + def stylesheet_link_tag(arg) | |
| 277 | + arg | |
| 278 | + end | |
| 279 | + | |
| 280 | + def show_date(date) | |
| 281 | + date.to_s | |
| 282 | + end | |
| 283 | + | |
| 284 | + def strip_tags(html) | |
| 285 | + html.gsub(/<[^>]+>/, '') | |
| 286 | + end | |
| 287 | + | |
| 288 | + def icon_for_article(article) | |
| 289 | + '' | |
| 290 | + end | |
| 291 | + | |
| 262 | 292 | end |
| 263 | 293 | |
| 264 | 294 | class ActionController::IntegrationTest | ... | ... |
test/unit/application_helper_test.rb
| ... | ... | @@ -89,7 +89,7 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 89 | 89 | person = create_user('usertest').person |
| 90 | 90 | community = fast_create(Community, :name => 'new community', :identifier => 'new-community', :environment_id => Environment.default.id) |
| 91 | 91 | community.add_member(person) |
| 92 | - assert_equal 'Profile Administrator', rolename_for(person, community) | |
| 92 | + assert_tag_in_string rolename_for(person, community), :tag => 'span', :content => 'Profile Administrator' | |
| 93 | 93 | end |
| 94 | 94 | |
| 95 | 95 | should 'rolename for a member' do |
| ... | ... | @@ -98,7 +98,7 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 98 | 98 | community = fast_create(Community, :name => 'new community', :identifier => 'new-community', :environment_id => Environment.default.id) |
| 99 | 99 | community.add_member(member1) |
| 100 | 100 | community.add_member(member2) |
| 101 | - assert_equal 'Profile Member', rolename_for(member2, community) | |
| 101 | + assert_tag_in_string rolename_for(member2, community), :tag => 'span', :content => 'Profile Member' | |
| 102 | 102 | end |
| 103 | 103 | |
| 104 | 104 | should 'get theme from environment by default' do |
| ... | ... | @@ -608,27 +608,6 @@ class ApplicationHelperTest < Test::Unit::TestCase |
| 608 | 608 | end |
| 609 | 609 | |
| 610 | 610 | protected |
| 611 | - | |
| 612 | - def url_for(args = {}) | |
| 613 | - args | |
| 614 | - end | |
| 615 | - def content_tag(tag, content, options = {}) | |
| 616 | - content.strip | |
| 617 | - end | |
| 618 | - def javascript_tag(any) | |
| 619 | - '' | |
| 620 | - end | |
| 621 | - def javascript_include_tag(any) | |
| 622 | - '' | |
| 623 | - end | |
| 624 | - def link_to(label, action, options = {}) | |
| 625 | - label | |
| 626 | - end | |
| 627 | - def check_box_tag(name, value = 1, checked = false, options = {}) | |
| 628 | - name | |
| 629 | - end | |
| 630 | - def stylesheet_link_tag(arg) | |
| 631 | - arg | |
| 632 | - end | |
| 611 | + include NoosferoTestHelper | |
| 633 | 612 | |
| 634 | 613 | end | ... | ... |
test/unit/blog_helper_test.rb
| ... | ... | @@ -113,20 +113,6 @@ class BlogHelperTest < Test::Unit::TestCase |
| 113 | 113 | end |
| 114 | 114 | |
| 115 | 115 | protected |
| 116 | + include NoosferoTestHelper | |
| 116 | 117 | |
| 117 | - def will_paginate(arg1, arg2) | |
| 118 | - end | |
| 119 | - | |
| 120 | - def link_to(content, url) | |
| 121 | - content | |
| 122 | - end | |
| 123 | - | |
| 124 | - def tag(tag, args = {}) | |
| 125 | - attrs = args.map{|k,v| "#{k}='#{v}'"}.join(' ') | |
| 126 | - "<#{tag} #{attrs} />" | |
| 127 | - end | |
| 128 | - | |
| 129 | - def content_tag(tag, content, options = {}) | |
| 130 | - "<#{tag}>#{content}</#{tag}>" | |
| 131 | - end | |
| 132 | 118 | end | ... | ... |
test/unit/content_viewer_helper_test.rb
| ... | ... | @@ -30,7 +30,7 @@ class ContentViewerHelperTest < Test::Unit::TestCase |
| 30 | 30 | post = fast_create(TextileArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id) |
| 31 | 31 | assert post.belongs_to_blog? |
| 32 | 32 | result = article_title(post) |
| 33 | - assert_match /a href='#{post.url}'>#{post.name}</, result | |
| 33 | + assert_tag_in_string result, :tag => 'h1', :child => {:tag => 'a', :content => 'post test', :attributes => { :href => /my-article-\d+/ }} | |
| 34 | 34 | end |
| 35 | 35 | |
| 36 | 36 | should 'not create link on title if pass no_link option' do |
| ... | ... | @@ -130,34 +130,10 @@ class ContentViewerHelperTest < Test::Unit::TestCase |
| 130 | 130 | end |
| 131 | 131 | |
| 132 | 132 | protected |
| 133 | - | |
| 133 | + include NoosferoTestHelper | |
| 134 | 134 | include ActionView::Helpers::TextHelper |
| 135 | - | |
| 136 | - def show_date(date) | |
| 137 | - date.to_s | |
| 138 | - end | |
| 139 | - | |
| 140 | - def link_to(content, url) | |
| 141 | - "<a href='#{url}'>#{content}</a>" | |
| 142 | - end | |
| 143 | - | |
| 144 | - def _(text) | |
| 145 | - text | |
| 146 | - end | |
| 147 | - | |
| 148 | - def will_paginate(arg1, arg2) | |
| 149 | - end | |
| 150 | - | |
| 151 | - def strip_tags(html) | |
| 152 | - html.gsub(/<[^>]+>/, '') | |
| 153 | - end | |
| 154 | - | |
| 155 | 135 | def url_for(args = {}) |
| 156 | 136 | ['http:/', args[:host], args[:profile], args[:page]].join('/') |
| 157 | 137 | end |
| 158 | 138 | |
| 159 | - def image_tag(file, args = {}) | |
| 160 | - file | |
| 161 | - end | |
| 162 | - | |
| 163 | 139 | end | ... | ... |
test/unit/events_helper_test.rb
| ... | ... | @@ -79,18 +79,6 @@ class EventsHelperTest < Test::Unit::TestCase |
| 79 | 79 | end |
| 80 | 80 | |
| 81 | 81 | protected |
| 82 | - | |
| 83 | - def content_tag(tag, text, options = {}) | |
| 84 | - "<#{tag}>#{text}</#{tag}>" | |
| 85 | - end | |
| 86 | - def icon_for_article(article) | |
| 87 | - '' | |
| 88 | - end | |
| 89 | - def image_tag(arg) | |
| 90 | - arg | |
| 91 | - end | |
| 92 | - def link_to(text, url, options = {}) | |
| 93 | - "<a href='#{url.to_s}'>#{text}</a>" | |
| 94 | - end | |
| 82 | + include NoosferoTestHelper | |
| 95 | 83 | |
| 96 | 84 | end | ... | ... |
test/unit/forms_helper_test.rb
test/unit/language_helper_test.rb
| ... | ... | @@ -38,8 +38,6 @@ class LanguageHelperTest < Test::Unit::TestCase |
| 38 | 38 | |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | - include ActionView::Helpers::FormOptionsHelper | |
| 42 | - include ActionView::Helpers::FormTagHelper | |
| 43 | 41 | should 'generate drodown language chooser correcly' do |
| 44 | 42 | Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once |
| 45 | 43 | |
| ... | ... | @@ -55,26 +53,8 @@ class LanguageHelperTest < Test::Unit::TestCase |
| 55 | 53 | end |
| 56 | 54 | |
| 57 | 55 | protected |
| 56 | + include NoosferoTestHelper | |
| 57 | + include ActionView::Helpers::FormOptionsHelper | |
| 58 | + include ActionView::Helpers::FormTagHelper | |
| 58 | 59 | |
| 59 | - def _(s) | |
| 60 | - s | |
| 61 | - end | |
| 62 | - | |
| 63 | - def content_tag(tag, text, options = {}) | |
| 64 | - "<#{tag}>#{text}</#{tag}>" | |
| 65 | - end | |
| 66 | - | |
| 67 | - def link_to(text, url, options = {}) | |
| 68 | - "<a href='?lang=#{url[:lang]}'>#{text}</a>" | |
| 69 | - end | |
| 70 | - | |
| 71 | - def params | |
| 72 | - {} | |
| 73 | - end | |
| 74 | - | |
| 75 | - def url_for(x) | |
| 76 | - x.inspect | |
| 77 | - end | |
| 78 | - | |
| 79 | 60 | end |
| 80 | - | ... | ... |
test/unit/organization_mailing_test.rb