diff --git a/test/test_helper.rb b/test/test_helper.rb
index deefbab..5d953ea 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -233,8 +233,9 @@ module NoosferoTestHelper
''
end
- def tag(tag)
- "<#{tag}/>"
+ def tag(tag, args = {})
+ attrs = args.map{|k,v| "#{k}='#{v}'"}.join(' ')
+ "<#{tag} #{attrs} />"
end
def options_from_collection_for_select(collection, value_method, content_method)
@@ -245,7 +246,7 @@ module NoosferoTestHelper
""
end
- def options_for_select(collection)
+ def options_for_select(collection, selected = nil)
collection.map{|item| ""}.join("\n")
end
@@ -259,6 +260,35 @@ module NoosferoTestHelper
def will_paginate(arg1, arg2)
end
+
+ def url_for(args = {})
+ args
+ end
+ def javascript_tag(any)
+ ''
+ end
+ def javascript_include_tag(any)
+ ''
+ end
+ def check_box_tag(name, value = 1, checked = false, options = {})
+ name
+ end
+ def stylesheet_link_tag(arg)
+ arg
+ end
+
+ def show_date(date)
+ date.to_s
+ end
+
+ def strip_tags(html)
+ html.gsub(/<[^>]+>/, '')
+ end
+
+ def icon_for_article(article)
+ ''
+ end
+
end
class ActionController::IntegrationTest
diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb
index 58452a7..595585e 100644
--- a/test/unit/application_helper_test.rb
+++ b/test/unit/application_helper_test.rb
@@ -89,7 +89,7 @@ class ApplicationHelperTest < Test::Unit::TestCase
person = create_user('usertest').person
community = fast_create(Community, :name => 'new community', :identifier => 'new-community', :environment_id => Environment.default.id)
community.add_member(person)
- assert_equal 'Profile Administrator', rolename_for(person, community)
+ assert_tag_in_string rolename_for(person, community), :tag => 'span', :content => 'Profile Administrator'
end
should 'rolename for a member' do
@@ -98,7 +98,7 @@ class ApplicationHelperTest < Test::Unit::TestCase
community = fast_create(Community, :name => 'new community', :identifier => 'new-community', :environment_id => Environment.default.id)
community.add_member(member1)
community.add_member(member2)
- assert_equal 'Profile Member', rolename_for(member2, community)
+ assert_tag_in_string rolename_for(member2, community), :tag => 'span', :content => 'Profile Member'
end
should 'get theme from environment by default' do
@@ -608,27 +608,6 @@ class ApplicationHelperTest < Test::Unit::TestCase
end
protected
-
- def url_for(args = {})
- args
- end
- def content_tag(tag, content, options = {})
- content.strip
- end
- def javascript_tag(any)
- ''
- end
- def javascript_include_tag(any)
- ''
- end
- def link_to(label, action, options = {})
- label
- end
- def check_box_tag(name, value = 1, checked = false, options = {})
- name
- end
- def stylesheet_link_tag(arg)
- arg
- end
+ include NoosferoTestHelper
end
diff --git a/test/unit/blog_helper_test.rb b/test/unit/blog_helper_test.rb
index 4cbbf66..37f1d92 100644
--- a/test/unit/blog_helper_test.rb
+++ b/test/unit/blog_helper_test.rb
@@ -113,20 +113,6 @@ class BlogHelperTest < Test::Unit::TestCase
end
protected
+ include NoosferoTestHelper
- def will_paginate(arg1, arg2)
- end
-
- def link_to(content, url)
- content
- end
-
- def tag(tag, args = {})
- attrs = args.map{|k,v| "#{k}='#{v}'"}.join(' ')
- "<#{tag} #{attrs} />"
- end
-
- def content_tag(tag, content, options = {})
- "<#{tag}>#{content}#{tag}>"
- end
end
diff --git a/test/unit/content_viewer_helper_test.rb b/test/unit/content_viewer_helper_test.rb
index 1e79db2..a74309f 100644
--- a/test/unit/content_viewer_helper_test.rb
+++ b/test/unit/content_viewer_helper_test.rb
@@ -30,7 +30,7 @@ class ContentViewerHelperTest < Test::Unit::TestCase
post = fast_create(TextileArticle, :name => 'post test', :profile_id => profile.id, :parent_id => blog.id)
assert post.belongs_to_blog?
result = article_title(post)
- assert_match /a href='#{post.url}'>#{post.name}, result
+ assert_tag_in_string result, :tag => 'h1', :child => {:tag => 'a', :content => 'post test', :attributes => { :href => /my-article-\d+/ }}
end
should 'not create link on title if pass no_link option' do
@@ -130,34 +130,10 @@ class ContentViewerHelperTest < Test::Unit::TestCase
end
protected
-
+ include NoosferoTestHelper
include ActionView::Helpers::TextHelper
-
- def show_date(date)
- date.to_s
- end
-
- def link_to(content, url)
- "#{content}"
- end
-
- def _(text)
- text
- end
-
- def will_paginate(arg1, arg2)
- end
-
- def strip_tags(html)
- html.gsub(/<[^>]+>/, '')
- end
-
def url_for(args = {})
['http:/', args[:host], args[:profile], args[:page]].join('/')
end
- def image_tag(file, args = {})
- file
- end
-
end
diff --git a/test/unit/events_helper_test.rb b/test/unit/events_helper_test.rb
index d2661fc..6cdc79f 100644
--- a/test/unit/events_helper_test.rb
+++ b/test/unit/events_helper_test.rb
@@ -79,18 +79,6 @@ class EventsHelperTest < Test::Unit::TestCase
end
protected
-
- def content_tag(tag, text, options = {})
- "<#{tag}>#{text}#{tag}>"
- end
- def icon_for_article(article)
- ''
- end
- def image_tag(arg)
- arg
- end
- def link_to(text, url, options = {})
- "#{text}"
- end
+ include NoosferoTestHelper
end
diff --git a/test/unit/forms_helper_test.rb b/test/unit/forms_helper_test.rb
index 06dd8a6..13c9a7c 100644
--- a/test/unit/forms_helper_test.rb
+++ b/test/unit/forms_helper_test.rb
@@ -27,9 +27,6 @@ class FormsHelperTest < Test::Unit::TestCase
end
protected
-
- def _(text)
- text
- end
+ include NoosferoTestHelper
end
diff --git a/test/unit/language_helper_test.rb b/test/unit/language_helper_test.rb
index 11a7c8e..5ee9121 100644
--- a/test/unit/language_helper_test.rb
+++ b/test/unit/language_helper_test.rb
@@ -38,8 +38,6 @@ class LanguageHelperTest < Test::Unit::TestCase
end
- include ActionView::Helpers::FormOptionsHelper
- include ActionView::Helpers::FormTagHelper
should 'generate drodown language chooser correcly' do
Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once
@@ -55,26 +53,8 @@ class LanguageHelperTest < Test::Unit::TestCase
end
protected
+ include NoosferoTestHelper
+ include ActionView::Helpers::FormOptionsHelper
+ include ActionView::Helpers::FormTagHelper
- def _(s)
- s
- end
-
- def content_tag(tag, text, options = {})
- "<#{tag}>#{text}#{tag}>"
- end
-
- def link_to(text, url, options = {})
- "#{text}"
- end
-
- def params
- {}
- end
-
- def url_for(x)
- x.inspect
- end
-
end
-
diff --git a/test/unit/organization_mailing_test.rb b/test/unit/organization_mailing_test.rb
index a9e007f..bb3dccc 100644
--- a/test/unit/organization_mailing_test.rb
+++ b/test/unit/organization_mailing_test.rb
@@ -112,9 +112,6 @@ class OrganizationMailingTest < ActiveSupport::TestCase
end
protected
-
- def url_for(url)
- url
- end
+ include NoosferoTestHelper
end
diff --git a/test/unit/people_block_test.rb b/test/unit/people_block_test.rb
index c26c112..dfd3d7b 100644
--- a/test/unit/people_block_test.rb
+++ b/test/unit/people_block_test.rb
@@ -45,8 +45,6 @@ class PeopleBlockTest < ActiveSupport::TestCase
end
protected
+ include NoosferoTestHelper
- def content_tag(tag, text, options = {})
- text
- end
end
--
libgit2 0.21.2