diff --git a/app/helpers/display_helper.rb b/app/helpers/display_helper.rb index 496e3b6..a0514d6 100644 --- a/app/helpers/display_helper.rb +++ b/app/helpers/display_helper.rb @@ -9,7 +9,7 @@ module DisplayHelper end def themed_path(file) - if File.exists?(Rails.root.join('public', theme_path, file)) + if File.exists?(File.join(Rails.root, 'public', theme_path, file)) File.join(theme_path, file) else file diff --git a/app/helpers/macros_helper.rb b/app/helpers/macros_helper.rb index 9e9c7d0..52aa90f 100644 --- a/app/helpers/macros_helper.rb +++ b/app/helpers/macros_helper.rb @@ -37,7 +37,7 @@ module MacrosHelper plugins_javascripts = [] @plugins.dispatch(:macros).map do |macro| if macro.configuration[:js_files] - macro.configuration[:js_files].map { |js| plugins_javascripts << macro.plugin.public_path(js) } + [macro.configuration[:js_files]].flatten.map { |js| plugins_javascripts << macro.plugin.public_path(js) } end end javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? @@ -47,7 +47,7 @@ module MacrosHelper plugins_css = [] @plugins.dispatch(:macros).map do |macro| if macro.configuration[:css_files] - macro.configuration[:css_files].map { |css| plugins_css << macro.plugin.public_path(css) } + [macro.configuration[:css_files]].flatten.map { |css| plugins_css << macro.plugin.public_path(css) } end end plugins_css.join(',') diff --git a/app/models/comment.rb b/app/models/comment.rb index 452f76a..e41b932 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -6,7 +6,7 @@ class Comment < ActiveRecord::Base :body => 2, } - attr_accessible :body, :author, :name, :email, :title, :reply_of_id + attr_accessible :body, :author, :name, :email, :title, :reply_of_id, :source validates_presence_of :body diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 2ad96ef..97cbc6c 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -11,6 +11,8 @@ class Invitation < Task validates_presence_of :message, :if => Proc.new{|invite| invite.target_id.blank?} + validate :not_invite_yourself + alias :person :requestor alias :person= :requestor= @@ -31,8 +33,7 @@ class Invitation < Task _('Invitation') end - def validate - super + def not_invite_yourself email = friend ? friend.user.email : friend_email if person && email && person.user.email == email self.errors.add(:base, _("You can't invite youself")) diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index e84c7e1..900b719 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -89,7 +89,7 @@ class LinkListBlock < Block def icons_options ICONS.map do |i| "".html_safe - end.join + end end private diff --git a/app/views/box_organizer/_icon_selector.html.erb b/app/views/box_organizer/_icon_selector.html.erb index cd6080a..6e608ad 100644 --- a/app/views/box_organizer/_icon_selector.html.erb +++ b/app/views/box_organizer/_icon_selector.html.erb @@ -2,6 +2,6 @@ <%= hidden_field_tag 'block[links][][icon]', icon %>
diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 16da152..0f5ff62 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -398,9 +398,9 @@ class ArticleTest < ActiveSupport::TestCase should 'redefine the entire category set at once' do c1 = create(Category, :environment => Environment.default, :name => 'c1') - c2 = create(Category, :environment => Environment.default, :name => 'c2', :parent_id => c1) - c3 = create(Category, :environment => Environment.default, :name => 'c3', :parent_id => c2) - c4 = create(Category, :environment => Environment.default, :name => 'c4', :parent_id => c1) + c2 = create(Category, :environment => Environment.default, :name => 'c2', :parent_id => c1.id) + c3 = create(Category, :environment => Environment.default, :name => 'c3', :parent_id => c2.id) + c4 = create(Category, :environment => Environment.default, :name => 'c4', :parent_id => c1.id) owner = create_user('testuser').person art = create(Article, :name => 'ytest', :profile_id => owner.id) diff --git a/test/unit/box_test.rb b/test/unit/box_test.rb index 54c6849..78f794d 100644 --- a/test/unit/box_test.rb +++ b/test/unit/box_test.rb @@ -96,7 +96,7 @@ class BoxTest < ActiveSupport::TestCase end end class PluginBlock < Block - def self.to_s; 'plugin-block'; end + def self.name; 'plugin-block'; end end Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) @@ -111,7 +111,7 @@ class BoxTest < ActiveSupport::TestCase end end class PluginBlock < Block - def self.to_s; 'plugin-block'; end + def self.name; 'plugin-block'; end end Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index 1e4b71c..508bbc4 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -366,9 +366,8 @@ class CommunityTest < ActiveSupport::TestCase UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once assert_difference 'ActionTracker::Record.count', 1 do article = create(TinyMceArticle, :profile => community, :name => 'An article about free software') + assert_equal [article.activity], community.activities.map { |a| a.klass.constantize.find(a.id) } end - - assert_equal [article.activity], community.activities.map { |a| a.klass.constantize.find(a.id) } end should 'not return tracked_actions of other community as activities' do diff --git a/test/unit/macros_helper_test.rb b/test/unit/macros_helper_test.rb index 6aa4f86..84a3fa0 100644 --- a/test/unit/macros_helper_test.rb +++ b/test/unit/macros_helper_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' -class MacrosHelperTest < ActiveSupport::TestCase +class MacrosHelperTest < ActionView::TestCase include MacrosHelper include ApplicationHelper include ActionView::Helpers::FormOptionsHelper @@ -101,7 +101,7 @@ class MacrosHelperTest < ActiveSupport::TestCase {:js_files => 'macro.js' } end end - + ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag.any_instance.stubs('asset_file_path!') assert_equal "", include_macro_js_files end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index b881106..3274e95 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1348,7 +1348,7 @@ class PersonTest < ActiveSupport::TestCase (6..10).each {|i| u = create_user('user'+i.to_s) } - assert_equal admins, Person.admins + assert_equivalent admins, Person.admins end should 'activated named_scope return persons who are activated users' do @@ -1364,7 +1364,7 @@ class PersonTest < ActiveSupport::TestCase u = create_user('user'+i.to_s) u.deactivate } - assert_equal activated, Person.activated + assert_equivalent activated, Person.activated end should 'deactivated named_scope return persons who are deactivated users' do diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index 6066860..7ec4fed 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -557,9 +557,9 @@ class ProductTest < ActiveSupport::TestCase end should 'return products from a category' do - pc1 = create(ProductCategory, :name => 'PC1', :environment => Environment.default) - pc2 = create(ProductCategory, :name => 'PC2', :environment => Environment.default) - pc3 = create(ProductCategory, :name => 'PC3', :environment => Environment.default, :parent => pc1) + pc1 = ProductCategory.create!(:name => 'PC1', :environment => Environment.default) + pc2 = ProductCategory.create!(:name => 'PC2', :environment => Environment.default) + pc3 = ProductCategory.create!(:name => 'PC3', :environment => Environment.default, :parent => pc1) p1 = fast_create(Product, :product_category_id => pc1) p2 = fast_create(Product, :product_category_id => pc1) p3 = fast_create(Product, :product_category_id => pc2) diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index d010d7d..cc99809 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -276,7 +276,7 @@ class ProfileTest < ActiveSupport::TestCase should 'list tags for profile' do profile = create(Profile, :tag_list => 'first-tag, second-tag') - assert_equal(['first-tag', 'second-tag'], profile.tags.map(&:name)) + assert_equivalent(['first-tag', 'second-tag'], profile.tags.map(&:name)) end should 'find content tagged with given tag' do diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb index db35af6..746ea30 100644 --- a/test/unit/rss_feed_test.rb +++ b/test/unit/rss_feed_test.rb @@ -159,11 +159,9 @@ class RssFeedTest < ActiveSupport::TestCase should 'limit should only accept integers' do feed = RssFeed.new feed.limit = 'text' - feed.valid? - assert feed.errors[:limit.to_s].present? + assert_not_equal 'text', feed.limit feed.limit = 10 - feed.valid? - assert !feed.errors[:limit.to_s].present? + assert_equal 10, feed.limit end should 'allow only parent_and_children and all as include setting' do diff --git a/test/unit/thumbnail_test.rb b/test/unit/thumbnail_test.rb index 561d8c9..6369ee4 100644 --- a/test/unit/thumbnail_test.rb +++ b/test/unit/thumbnail_test.rb @@ -6,7 +6,7 @@ class ThumbnailTest < ActiveSupport::TestCase assert_equal :file_system, Thumbnail.attachment_options[:storage] Thumbnail.attachment_options[:content_type].each do |item| - assert_match 'image/', item + assert_match /(image|application)\/.+/, item end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 0dd0fb4..c3ca32f 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -339,7 +339,7 @@ class UserTest < ActiveSupport::TestCase expected_hash = { 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, 'chat_enabled' => false, 'since_year' => 2010, 'avatar' => - 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e?only_path=false&d=&size=20', + 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e?only_path=false&size=20&d=', 'email_domain' => nil, 'amount_of_friends' => 0, 'friends_list' => {}, 'enterprises' => [], } -- libgit2 0.21.2