Commit 115f27ae873ba51163b988c66c5defe5e97d0436
Exists in
master
and in
29 other branches
Merge branch 'fix_people_block' into 'master'
Fix people block tests See merge request !375
Showing
4 changed files
with
24 additions
and
25 deletions
Show diff stats
app/helpers/sweeper_helper.rb
@@ -56,12 +56,12 @@ module SweeperHelper | @@ -56,12 +56,12 @@ module SweeperHelper | ||
56 | if profile | 56 | if profile |
57 | profile.blocks.each {|block| | 57 | profile.blocks.each {|block| |
58 | conditions = block.class.expire_on | 58 | conditions = block.class.expire_on |
59 | - blocks_to_expire << block unless (conditions[:profile] & causes).empty? | 59 | + blocks_to_expire << block unless (conditions[:profile] & causes).blank? |
60 | } | 60 | } |
61 | end | 61 | end |
62 | environment.blocks.each {|block| | 62 | environment.blocks.each {|block| |
63 | conditions = block.class.expire_on | 63 | conditions = block.class.expire_on |
64 | - blocks_to_expire << block unless (conditions[:environment] & causes).empty? | 64 | + blocks_to_expire << block unless (conditions[:environment] & causes).blank? |
65 | } | 65 | } |
66 | 66 | ||
67 | blocks_to_expire.uniq! | 67 | blocks_to_expire.uniq! |
plugins/people_block/test/unit/friends_block_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | -class FriendsBlockTest < ActiveSupport::TestCase | 3 | +class FriendsBlockTest < ActionView::TestCase |
4 | 4 | ||
5 | should 'inherit from Block' do | 5 | should 'inherit from Block' do |
6 | assert_kind_of Block, FriendsBlock.new | 6 | assert_kind_of Block, FriendsBlock.new |
@@ -8,6 +8,7 @@ class FriendsBlockTest < ActiveSupport::TestCase | @@ -8,6 +8,7 @@ class FriendsBlockTest < ActiveSupport::TestCase | ||
8 | 8 | ||
9 | 9 | ||
10 | should 'declare its default title' do | 10 | should 'declare its default title' do |
11 | + FriendsBlock.any_instance.expects(:profile_count).returns(0) | ||
11 | assert_not_equal Block.new.default_title, FriendsBlock.new.default_title | 12 | assert_not_equal Block.new.default_title, FriendsBlock.new.default_title |
12 | end | 13 | end |
13 | 14 | ||
@@ -60,7 +61,7 @@ class FriendsBlockTest < ActiveSupport::TestCase | @@ -60,7 +61,7 @@ class FriendsBlockTest < ActiveSupport::TestCase | ||
60 | 61 | ||
61 | 62 | ||
62 | should 'prioritize profiles with image by default' do | 63 | should 'prioritize profiles with image by default' do |
63 | - assert FriendsBlock.new.prioritize_people_with_image | 64 | + assert FriendsBlock.new.prioritize_profiles_with_image |
64 | end | 65 | end |
65 | 66 | ||
66 | 67 | ||
@@ -98,10 +99,10 @@ class FriendsBlockTest < ActiveSupport::TestCase | @@ -98,10 +99,10 @@ class FriendsBlockTest < ActiveSupport::TestCase | ||
98 | block = FriendsBlock.new | 99 | block = FriendsBlock.new |
99 | block.expects(:owner).returns(person1).at_least_once | 100 | block.expects(:owner).returns(person1).at_least_once |
100 | 101 | ||
101 | - expects(:_).with('View all').returns('View all') | ||
102 | - expects(:link_to).with('View all', :profile => 'mytestperson', :controller => 'profile', :action => 'friends').returns('link-to-friends') | ||
103 | - | ||
104 | - assert_equal 'link-to-friends', instance_eval(&block.footer) | 102 | + instance_eval(&block.footer) |
103 | + assert_select 'a.view-all' do |elements| | ||
104 | + assert_select '[href=/profile/mytestperson/friends]' | ||
105 | + end | ||
105 | end | 106 | end |
106 | 107 | ||
107 | 108 |
plugins/people_block/test/unit/members_block_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | -class MembersBlockTest < ActiveSupport::TestCase | 3 | +class MembersBlockTest < ActionView::TestCase |
4 | 4 | ||
5 | should 'inherit from Block' do | 5 | should 'inherit from Block' do |
6 | assert_kind_of Block, MembersBlock.new | 6 | assert_kind_of Block, MembersBlock.new |
@@ -60,7 +60,7 @@ class MembersBlockTest < ActiveSupport::TestCase | @@ -60,7 +60,7 @@ class MembersBlockTest < ActiveSupport::TestCase | ||
60 | 60 | ||
61 | 61 | ||
62 | should 'prioritize profiles with image by default' do | 62 | should 'prioritize profiles with image by default' do |
63 | - assert MembersBlock.new.prioritize_people_with_image | 63 | + assert MembersBlock.new.prioritize_profiles_with_image |
64 | end | 64 | end |
65 | 65 | ||
66 | 66 | ||
@@ -145,10 +145,10 @@ class MembersBlockTest < ActiveSupport::TestCase | @@ -145,10 +145,10 @@ class MembersBlockTest < ActiveSupport::TestCase | ||
145 | block.box = profile.boxes.first | 145 | block.box = profile.boxes.first |
146 | block.save! | 146 | block.save! |
147 | 147 | ||
148 | - expects(:_).with('View all').returns('View all') | ||
149 | - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'people_block_plugin_profile', :action => 'members', :role_key => block.visible_role).returns('link-to-members') | ||
150 | - | ||
151 | - assert_equal 'link-to-members', instance_eval(&block.footer) | 148 | + instance_eval(&block.footer) |
149 | + assert_select 'a.view-all' do |elements| | ||
150 | + assert_select '[href=/profile/mytestuser/plugin/people_block/members]' | ||
151 | + end | ||
152 | end | 152 | end |
153 | 153 | ||
154 | should 'provide link to members page with a selected role' do | 154 | should 'provide link to members page with a selected role' do |
@@ -158,10 +158,10 @@ class MembersBlockTest < ActiveSupport::TestCase | @@ -158,10 +158,10 @@ class MembersBlockTest < ActiveSupport::TestCase | ||
158 | block.visible_role = 'profile_member' | 158 | block.visible_role = 'profile_member' |
159 | block.save! | 159 | block.save! |
160 | 160 | ||
161 | - expects(:_).with('View all').returns('View all') | ||
162 | - expects(:link_to).with('View all' , :profile => 'mytestuser', :controller => 'people_block_plugin_profile', :action => 'members', :role_key => block.visible_role).returns('link-to-members') | ||
163 | - | ||
164 | - assert_equal 'link-to-members', instance_eval(&block.footer) | 161 | + instance_eval(&block.footer) |
162 | + assert_select 'a.view-all' do |elements| | ||
163 | + assert_select '[href=/profile/mytestuser/plugin/people_block/members?role_key=profile_member]' | ||
164 | + end | ||
165 | end | 165 | end |
166 | 166 | ||
167 | should 'provide a role to be displayed (and default to nil)' do | 167 | should 'provide a role to be displayed (and default to nil)' do |
plugins/people_block/test/unit/people_block_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | -class PeopleBlockTest < ActiveSupport::TestCase | 3 | +class PeopleBlockTest < ActionView::TestCase |
4 | 4 | ||
5 | should 'inherit from Block' do | 5 | should 'inherit from Block' do |
6 | assert_kind_of Block, PeopleBlock.new | 6 | assert_kind_of Block, PeopleBlock.new |
@@ -106,14 +106,12 @@ class PeopleBlockTest < ActiveSupport::TestCase | @@ -106,14 +106,12 @@ class PeopleBlockTest < ActiveSupport::TestCase | ||
106 | 106 | ||
107 | should 'link to "all people"' do | 107 | should 'link to "all people"' do |
108 | env = fast_create(Environment) | 108 | env = fast_create(Environment) |
109 | - | ||
110 | block = PeopleBlock.new | 109 | block = PeopleBlock.new |
111 | 110 | ||
112 | - stubs(:_).with('View all').returns('View all') | ||
113 | - stubs(:link_to).returns('link-to-people') | ||
114 | - stubs(:url_for).returns(' ') | ||
115 | - | ||
116 | - assert_equal 'link-to-people', instance_exec(&block.footer) | 111 | + instance_eval(&block.footer) |
112 | + assert_select 'a.view-all' do |elements| | ||
113 | + assert_select '[href=/search/people]' | ||
114 | + end | ||
117 | end | 115 | end |
118 | 116 | ||
119 | 117 |