Commit 5c42f6c17c2ec3ba5d0589a89a1a178149a7607e
1 parent
00bda324
Exists in
master
and in
21 other branches
Fix: profile_helper tests
Showing
1 changed file
with
16 additions
and
6 deletions
Show diff stats
test/unit/profile_helper_test.rb
| ... | ... | @@ -17,45 +17,55 @@ class ProfileHelperTest < ActiveSupport::TestCase |
| 17 | 17 | self.stubs(:user).returns(nil) |
| 18 | 18 | profile.expects(:may_display_field_to?).returns(true) |
| 19 | 19 | profile.expects(:field).returns('value') |
| 20 | - assert_match /Title.*value/, display_field('Title', profile, 'field') | |
| 20 | + expects(:title).with(:field, anything).returns('Title') | |
| 21 | + assert_match /Title.*value/, display_field(:field) | |
| 21 | 22 | end |
| 22 | 23 | |
| 23 | 24 | should 'not display field if may not display it and not forced' do |
| 24 | 25 | self.stubs(:user).returns(nil) |
| 25 | 26 | profile.expects(:may_display_field_to?).returns(false) |
| 26 | - assert_equal '', display_field('Title', profile, 'field') | |
| 27 | + profile.expects(:field).never | |
| 28 | + assert_equal '', display_field(:field) | |
| 27 | 29 | end |
| 28 | 30 | |
| 29 | 31 | should 'display field if may not display it but is forced' do |
| 30 | 32 | self.stubs(:user).returns(nil) |
| 31 | 33 | profile.stubs(:may_display_field_to?).returns(false) |
| 34 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
| 35 | + FORCE.merge!({:person => [:field]}) | |
| 32 | 36 | profile.expects(:field).returns('value') |
| 33 | - assert_match /Title.*value/, display_field('Title', profile, 'field', true) | |
| 37 | + expects(:title).with(:field, anything).returns('Title') | |
| 38 | + assert_match /Title.*value/, display_field(:field) | |
| 34 | 39 | end |
| 35 | 40 | |
| 36 | 41 | should 'display work info if at least one of the fields should be displayed' do |
| 37 | 42 | self.stubs(:user).returns(nil) |
| 38 | 43 | profile.stubs(:may_display_field_to?).with(:organization, nil).returns(true) |
| 39 | 44 | profile.stubs(:may_display_field_to?).with(:organization_website, nil).returns(false) |
| 45 | + profile.stubs(:may_display_field_to?).with(:professional_activity, nil).returns(false) | |
| 46 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
| 40 | 47 | profile.expects(:organization).returns('Organization Name') |
| 41 | 48 | profile.expects(:organization_website).never |
| 42 | - assert_match /Work.*Organization Name/, display_work_info(profile) | |
| 49 | + profile.expects(:professional_activity).never | |
| 50 | + assert_match /Work.*Organization Name/, display_work | |
| 43 | 51 | end |
| 44 | 52 | |
| 45 | 53 | should 'not display work info if none of the fields should be displayed' do |
| 46 | 54 | self.stubs(:user).returns(nil) |
| 47 | 55 | profile.stubs(:may_display_field_to?).returns(false) |
| 56 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
| 48 | 57 | profile.expects(:organization).never |
| 49 | 58 | profile.expects(:organization_website).never |
| 50 | - assert_equal '', display_work_info(profile) | |
| 59 | + assert_equal '', display_work | |
| 51 | 60 | end |
| 52 | 61 | |
| 53 | 62 | should 'display work info if both fields should be displayed' do |
| 54 | 63 | self.stubs(:user).returns(nil) |
| 55 | 64 | profile.stubs(:may_display_field_to?).returns(true) |
| 65 | + profile.stubs(:kind_of?).with(Person).returns(:person) | |
| 56 | 66 | profile.expects(:organization).returns('Organization Name') |
| 57 | 67 | profile.expects(:organization_website).returns('') |
| 58 | - assert_match /Work.*Organization Name/, display_work_info(profile) | |
| 68 | + assert_match /Work.*Organization Name/, display_work | |
| 59 | 69 | end |
| 60 | 70 | |
| 61 | 71 | end | ... | ... |