From bef9c7c4ddbfbe023bdc240ba7347a298e5721ed Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Wed, 12 Nov 2014 14:55:05 -0300 Subject: [PATCH] people_block: fix tests --- app/helpers/sweeper_helper.rb | 4 ++-- plugins/people_block/test/unit/friends_block_test.rb | 13 +++++++------ plugins/people_block/test/unit/members_block_test.rb | 20 ++++++++++---------- plugins/people_block/test/unit/people_block_test.rb | 12 +++++------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/helpers/sweeper_helper.rb b/app/helpers/sweeper_helper.rb index bb4a6a4..4126c2f 100644 --- a/app/helpers/sweeper_helper.rb +++ b/app/helpers/sweeper_helper.rb @@ -56,12 +56,12 @@ module SweeperHelper if profile profile.blocks.each {|block| conditions = block.class.expire_on - blocks_to_expire << block unless (conditions[:profile] & causes).empty? + blocks_to_expire << block unless (conditions[:profile] & causes).blank? } end environment.blocks.each {|block| conditions = block.class.expire_on - blocks_to_expire << block unless (conditions[:environment] & causes).empty? + blocks_to_expire << block unless (conditions[:environment] & causes).blank? } blocks_to_expire.uniq! diff --git a/plugins/people_block/test/unit/friends_block_test.rb b/plugins/people_block/test/unit/friends_block_test.rb index 0e19ae7..274edcb 100644 --- a/plugins/people_block/test/unit/friends_block_test.rb +++ b/plugins/people_block/test/unit/friends_block_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' -class FriendsBlockTest < ActiveSupport::TestCase +class FriendsBlockTest < ActionView::TestCase should 'inherit from Block' do assert_kind_of Block, FriendsBlock.new @@ -8,6 +8,7 @@ class FriendsBlockTest < ActiveSupport::TestCase should 'declare its default title' do + FriendsBlock.any_instance.expects(:profile_count).returns(0) assert_not_equal Block.new.default_title, FriendsBlock.new.default_title end @@ -60,7 +61,7 @@ class FriendsBlockTest < ActiveSupport::TestCase should 'prioritize profiles with image by default' do - assert FriendsBlock.new.prioritize_people_with_image + assert FriendsBlock.new.prioritize_profiles_with_image end @@ -98,10 +99,10 @@ class FriendsBlockTest < ActiveSupport::TestCase block = FriendsBlock.new block.expects(:owner).returns(person1).at_least_once - expects(:_).with('View all').returns('View all') - expects(:link_to).with('View all', :profile => 'mytestperson', :controller => 'profile', :action => 'friends').returns('link-to-friends') - - assert_equal 'link-to-friends', instance_eval(&block.footer) + instance_eval(&block.footer) + assert_select 'a.view-all' do |elements| + assert_select '[href=/profile/mytestperson/friends]' + end end diff --git a/plugins/people_block/test/unit/members_block_test.rb b/plugins/people_block/test/unit/members_block_test.rb index f3c6355..5887de1 100644 --- a/plugins/people_block/test/unit/members_block_test.rb +++ b/plugins/people_block/test/unit/members_block_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' -class MembersBlockTest < ActiveSupport::TestCase +class MembersBlockTest < ActionView::TestCase should 'inherit from Block' do assert_kind_of Block, MembersBlock.new @@ -60,7 +60,7 @@ class MembersBlockTest < ActiveSupport::TestCase should 'prioritize profiles with image by default' do - assert MembersBlock.new.prioritize_people_with_image + assert MembersBlock.new.prioritize_profiles_with_image end @@ -145,10 +145,10 @@ class MembersBlockTest < ActiveSupport::TestCase block.box = profile.boxes.first block.save! - expects(:_).with('View all').returns('View all') - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'people_block_plugin_profile', :action => 'members', :role_key => block.visible_role).returns('link-to-members') - - assert_equal 'link-to-members', instance_eval(&block.footer) + instance_eval(&block.footer) + assert_select 'a.view-all' do |elements| + assert_select '[href=/profile/mytestuser/plugin/people_block/members]' + end end should 'provide link to members page with a selected role' do @@ -158,10 +158,10 @@ class MembersBlockTest < ActiveSupport::TestCase block.visible_role = 'profile_member' block.save! - expects(:_).with('View all').returns('View all') - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'people_block_plugin_profile', :action => 'members', :role_key => block.visible_role).returns('link-to-members') - - assert_equal 'link-to-members', instance_eval(&block.footer) + instance_eval(&block.footer) + assert_select 'a.view-all' do |elements| + assert_select '[href=/profile/mytestuser/plugin/people_block/members?role_key=profile_member]' + end end should 'provide a role to be displayed (and default to nil)' do diff --git a/plugins/people_block/test/unit/people_block_test.rb b/plugins/people_block/test/unit/people_block_test.rb index 201a521..6482192 100644 --- a/plugins/people_block/test/unit/people_block_test.rb +++ b/plugins/people_block/test/unit/people_block_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' -class PeopleBlockTest < ActiveSupport::TestCase +class PeopleBlockTest < ActionView::TestCase should 'inherit from Block' do assert_kind_of Block, PeopleBlock.new @@ -106,14 +106,12 @@ class PeopleBlockTest < ActiveSupport::TestCase should 'link to "all people"' do env = fast_create(Environment) - block = PeopleBlock.new - stubs(:_).with('View all').returns('View all') - stubs(:link_to).returns('link-to-people') - stubs(:url_for).returns(' ') - - assert_equal 'link-to-people', instance_exec(&block.footer) + instance_eval(&block.footer) + assert_select 'a.view-all' do |elements| + assert_select '[href=/search/people]' + end end -- libgit2 0.21.2