Commit a0b2a3433ff4459a892f56bb5a895dcbd86852a5
1 parent
caa8090a
Exists in
master
and in
27 other branches
rails3: fix some unit tests
Showing
16 changed files
with
27 additions
and
29 deletions
Show diff stats
app/helpers/display_helper.rb
app/helpers/macros_helper.rb
... | ... | @@ -37,7 +37,7 @@ module MacrosHelper |
37 | 37 | plugins_javascripts = [] |
38 | 38 | @plugins.dispatch(:macros).map do |macro| |
39 | 39 | if macro.configuration[:js_files] |
40 | - macro.configuration[:js_files].map { |js| plugins_javascripts << macro.plugin.public_path(js) } | |
40 | + [macro.configuration[:js_files]].flatten.map { |js| plugins_javascripts << macro.plugin.public_path(js) } | |
41 | 41 | end |
42 | 42 | end |
43 | 43 | 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 |
47 | 47 | plugins_css = [] |
48 | 48 | @plugins.dispatch(:macros).map do |macro| |
49 | 49 | if macro.configuration[:css_files] |
50 | - macro.configuration[:css_files].map { |css| plugins_css << macro.plugin.public_path(css) } | |
50 | + [macro.configuration[:css_files]].flatten.map { |css| plugins_css << macro.plugin.public_path(css) } | |
51 | 51 | end |
52 | 52 | end |
53 | 53 | plugins_css.join(',') | ... | ... |
app/models/comment.rb
app/models/invitation.rb
... | ... | @@ -11,6 +11,8 @@ class Invitation < Task |
11 | 11 | |
12 | 12 | validates_presence_of :message, :if => Proc.new{|invite| invite.target_id.blank?} |
13 | 13 | |
14 | + validate :not_invite_yourself | |
15 | + | |
14 | 16 | alias :person :requestor |
15 | 17 | alias :person= :requestor= |
16 | 18 | |
... | ... | @@ -31,8 +33,7 @@ class Invitation < Task |
31 | 33 | _('Invitation') |
32 | 34 | end |
33 | 35 | |
34 | - def validate | |
35 | - super | |
36 | + def not_invite_yourself | |
36 | 37 | email = friend ? friend.user.email : friend_email |
37 | 38 | if person && email && person.user.email == email |
38 | 39 | self.errors.add(:base, _("You can't invite youself")) | ... | ... |
app/models/link_list_block.rb
app/views/box_organizer/_icon_selector.html.erb
... | ... | @@ -2,6 +2,6 @@ |
2 | 2 | <%= hidden_field_tag 'block[links][][icon]', icon %> |
3 | 3 | <span class='icon-<%= icon %>' style='display:block; width:16px; height:16px;'></span> |
4 | 4 | <div class="icon-selector" style='display:none;'> |
5 | - <%= @block.icons_options %> | |
5 | + <%= @block.icons_options.join %> | |
6 | 6 | </div> |
7 | 7 | </div> | ... | ... |
test/unit/article_test.rb
... | ... | @@ -398,9 +398,9 @@ class ArticleTest < ActiveSupport::TestCase |
398 | 398 | |
399 | 399 | should 'redefine the entire category set at once' do |
400 | 400 | c1 = create(Category, :environment => Environment.default, :name => 'c1') |
401 | - c2 = create(Category, :environment => Environment.default, :name => 'c2', :parent_id => c1) | |
402 | - c3 = create(Category, :environment => Environment.default, :name => 'c3', :parent_id => c2) | |
403 | - c4 = create(Category, :environment => Environment.default, :name => 'c4', :parent_id => c1) | |
401 | + c2 = create(Category, :environment => Environment.default, :name => 'c2', :parent_id => c1.id) | |
402 | + c3 = create(Category, :environment => Environment.default, :name => 'c3', :parent_id => c2.id) | |
403 | + c4 = create(Category, :environment => Environment.default, :name => 'c4', :parent_id => c1.id) | |
404 | 404 | owner = create_user('testuser').person |
405 | 405 | art = create(Article, :name => 'ytest', :profile_id => owner.id) |
406 | 406 | ... | ... |
test/unit/box_test.rb
... | ... | @@ -96,7 +96,7 @@ class BoxTest < ActiveSupport::TestCase |
96 | 96 | end |
97 | 97 | end |
98 | 98 | class PluginBlock < Block |
99 | - def self.to_s; 'plugin-block'; end | |
99 | + def self.name; 'plugin-block'; end | |
100 | 100 | end |
101 | 101 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
102 | 102 | |
... | ... | @@ -111,7 +111,7 @@ class BoxTest < ActiveSupport::TestCase |
111 | 111 | end |
112 | 112 | end |
113 | 113 | class PluginBlock < Block |
114 | - def self.to_s; 'plugin-block'; end | |
114 | + def self.name; 'plugin-block'; end | |
115 | 115 | end |
116 | 116 | Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([SomePlugin.new]) |
117 | 117 | ... | ... |
test/unit/community_test.rb
... | ... | @@ -366,9 +366,8 @@ class CommunityTest < ActiveSupport::TestCase |
366 | 366 | UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once |
367 | 367 | assert_difference 'ActionTracker::Record.count', 1 do |
368 | 368 | article = create(TinyMceArticle, :profile => community, :name => 'An article about free software') |
369 | + assert_equal [article.activity], community.activities.map { |a| a.klass.constantize.find(a.id) } | |
369 | 370 | end |
370 | - | |
371 | - assert_equal [article.activity], community.activities.map { |a| a.klass.constantize.find(a.id) } | |
372 | 371 | end |
373 | 372 | |
374 | 373 | should 'not return tracked_actions of other community as activities' do | ... | ... |
test/unit/macros_helper_test.rb
1 | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | -class MacrosHelperTest < ActiveSupport::TestCase | |
3 | +class MacrosHelperTest < ActionView::TestCase | |
4 | 4 | include MacrosHelper |
5 | 5 | include ApplicationHelper |
6 | 6 | include ActionView::Helpers::FormOptionsHelper |
... | ... | @@ -101,7 +101,7 @@ class MacrosHelperTest < ActiveSupport::TestCase |
101 | 101 | {:js_files => 'macro.js' } |
102 | 102 | end |
103 | 103 | end |
104 | - | |
104 | + ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag.any_instance.stubs('asset_file_path!') | |
105 | 105 | assert_equal "<script src=\"#{Plugin1.public_path('macro.js')}\" type=\"text/javascript\"></script>", include_macro_js_files |
106 | 106 | end |
107 | 107 | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1348,7 +1348,7 @@ class PersonTest < ActiveSupport::TestCase |
1348 | 1348 | (6..10).each {|i| |
1349 | 1349 | u = create_user('user'+i.to_s) |
1350 | 1350 | } |
1351 | - assert_equal admins, Person.admins | |
1351 | + assert_equivalent admins, Person.admins | |
1352 | 1352 | end |
1353 | 1353 | |
1354 | 1354 | should 'activated named_scope return persons who are activated users' do |
... | ... | @@ -1364,7 +1364,7 @@ class PersonTest < ActiveSupport::TestCase |
1364 | 1364 | u = create_user('user'+i.to_s) |
1365 | 1365 | u.deactivate |
1366 | 1366 | } |
1367 | - assert_equal activated, Person.activated | |
1367 | + assert_equivalent activated, Person.activated | |
1368 | 1368 | end |
1369 | 1369 | |
1370 | 1370 | should 'deactivated named_scope return persons who are deactivated users' do | ... | ... |
test/unit/product_test.rb
... | ... | @@ -557,9 +557,9 @@ class ProductTest < ActiveSupport::TestCase |
557 | 557 | end |
558 | 558 | |
559 | 559 | should 'return products from a category' do |
560 | - pc1 = create(ProductCategory, :name => 'PC1', :environment => Environment.default) | |
561 | - pc2 = create(ProductCategory, :name => 'PC2', :environment => Environment.default) | |
562 | - pc3 = create(ProductCategory, :name => 'PC3', :environment => Environment.default, :parent => pc1) | |
560 | + pc1 = ProductCategory.create!(:name => 'PC1', :environment => Environment.default) | |
561 | + pc2 = ProductCategory.create!(:name => 'PC2', :environment => Environment.default) | |
562 | + pc3 = ProductCategory.create!(:name => 'PC3', :environment => Environment.default, :parent => pc1) | |
563 | 563 | p1 = fast_create(Product, :product_category_id => pc1) |
564 | 564 | p2 = fast_create(Product, :product_category_id => pc1) |
565 | 565 | p3 = fast_create(Product, :product_category_id => pc2) | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -276,7 +276,7 @@ class ProfileTest < ActiveSupport::TestCase |
276 | 276 | should 'list tags for profile' do |
277 | 277 | profile = create(Profile, :tag_list => 'first-tag, second-tag') |
278 | 278 | |
279 | - assert_equal(['first-tag', 'second-tag'], profile.tags.map(&:name)) | |
279 | + assert_equivalent(['first-tag', 'second-tag'], profile.tags.map(&:name)) | |
280 | 280 | end |
281 | 281 | |
282 | 282 | should 'find content tagged with given tag' do | ... | ... |
test/unit/rss_feed_test.rb
... | ... | @@ -159,11 +159,9 @@ class RssFeedTest < ActiveSupport::TestCase |
159 | 159 | should 'limit should only accept integers' do |
160 | 160 | feed = RssFeed.new |
161 | 161 | feed.limit = 'text' |
162 | - feed.valid? | |
163 | - assert feed.errors[:limit.to_s].present? | |
162 | + assert_not_equal 'text', feed.limit | |
164 | 163 | feed.limit = 10 |
165 | - feed.valid? | |
166 | - assert !feed.errors[:limit.to_s].present? | |
164 | + assert_equal 10, feed.limit | |
167 | 165 | end |
168 | 166 | |
169 | 167 | should 'allow only parent_and_children and all as include setting' do | ... | ... |
test/unit/thumbnail_test.rb
... | ... | @@ -6,7 +6,7 @@ class ThumbnailTest < ActiveSupport::TestCase |
6 | 6 | assert_equal :file_system, Thumbnail.attachment_options[:storage] |
7 | 7 | |
8 | 8 | Thumbnail.attachment_options[:content_type].each do |item| |
9 | - assert_match 'image/', item | |
9 | + assert_match /(image|application)\/.+/, item | |
10 | 10 | end |
11 | 11 | end |
12 | 12 | ... | ... |
test/unit/user_test.rb
... | ... | @@ -339,7 +339,7 @@ class UserTest < ActiveSupport::TestCase |
339 | 339 | expected_hash = { |
340 | 340 | 'login' => 'x_and_y', 'is_admin' => true, 'since_month' => 8, |
341 | 341 | 'chat_enabled' => false, 'since_year' => 2010, 'avatar' => |
342 | - 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e?only_path=false&d=&size=20', | |
342 | + 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e?only_path=false&size=20&d=', | |
343 | 343 | 'email_domain' => nil, 'amount_of_friends' => 0, |
344 | 344 | 'friends_list' => {}, 'enterprises' => [], |
345 | 345 | } | ... | ... |