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,45 +17,55 @@ class ProfileHelperTest < ActiveSupport::TestCase | ||
| 17 | self.stubs(:user).returns(nil) | 17 | self.stubs(:user).returns(nil) |
| 18 | profile.expects(:may_display_field_to?).returns(true) | 18 | profile.expects(:may_display_field_to?).returns(true) |
| 19 | profile.expects(:field).returns('value') | 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 | end | 22 | end |
| 22 | 23 | ||
| 23 | should 'not display field if may not display it and not forced' do | 24 | should 'not display field if may not display it and not forced' do |
| 24 | self.stubs(:user).returns(nil) | 25 | self.stubs(:user).returns(nil) |
| 25 | profile.expects(:may_display_field_to?).returns(false) | 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 | end | 29 | end |
| 28 | 30 | ||
| 29 | should 'display field if may not display it but is forced' do | 31 | should 'display field if may not display it but is forced' do |
| 30 | self.stubs(:user).returns(nil) | 32 | self.stubs(:user).returns(nil) |
| 31 | profile.stubs(:may_display_field_to?).returns(false) | 33 | profile.stubs(:may_display_field_to?).returns(false) |
| 34 | + profile.stubs(:kind_of?).with(Person).returns(:person) | ||
| 35 | + FORCE.merge!({:person => [:field]}) | ||
| 32 | profile.expects(:field).returns('value') | 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 | end | 39 | end |
| 35 | 40 | ||
| 36 | should 'display work info if at least one of the fields should be displayed' do | 41 | should 'display work info if at least one of the fields should be displayed' do |
| 37 | self.stubs(:user).returns(nil) | 42 | self.stubs(:user).returns(nil) |
| 38 | profile.stubs(:may_display_field_to?).with(:organization, nil).returns(true) | 43 | profile.stubs(:may_display_field_to?).with(:organization, nil).returns(true) |
| 39 | profile.stubs(:may_display_field_to?).with(:organization_website, nil).returns(false) | 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 | profile.expects(:organization).returns('Organization Name') | 47 | profile.expects(:organization).returns('Organization Name') |
| 41 | profile.expects(:organization_website).never | 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 | end | 51 | end |
| 44 | 52 | ||
| 45 | should 'not display work info if none of the fields should be displayed' do | 53 | should 'not display work info if none of the fields should be displayed' do |
| 46 | self.stubs(:user).returns(nil) | 54 | self.stubs(:user).returns(nil) |
| 47 | profile.stubs(:may_display_field_to?).returns(false) | 55 | profile.stubs(:may_display_field_to?).returns(false) |
| 56 | + profile.stubs(:kind_of?).with(Person).returns(:person) | ||
| 48 | profile.expects(:organization).never | 57 | profile.expects(:organization).never |
| 49 | profile.expects(:organization_website).never | 58 | profile.expects(:organization_website).never |
| 50 | - assert_equal '', display_work_info(profile) | 59 | + assert_equal '', display_work |
| 51 | end | 60 | end |
| 52 | 61 | ||
| 53 | should 'display work info if both fields should be displayed' do | 62 | should 'display work info if both fields should be displayed' do |
| 54 | self.stubs(:user).returns(nil) | 63 | self.stubs(:user).returns(nil) |
| 55 | profile.stubs(:may_display_field_to?).returns(true) | 64 | profile.stubs(:may_display_field_to?).returns(true) |
| 65 | + profile.stubs(:kind_of?).with(Person).returns(:person) | ||
| 56 | profile.expects(:organization).returns('Organization Name') | 66 | profile.expects(:organization).returns('Organization Name') |
| 57 | profile.expects(:organization_website).returns('') | 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 | end | 69 | end |
| 60 | 70 | ||
| 61 | end | 71 | end |