diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index fbccbbe..6704462 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -78,7 +78,9 @@ module ProfileHelper entries = multiple ? value : [] << value entries.map do |entry| content = self.send("treat_#{field}", entry) - content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) + unless content.blank? + content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) + end end.join("\n") else '' diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 16a78da..5737509 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -109,8 +109,9 @@ class ProfileControllerTest < ActionController::TestCase should 'show friends link to person' do person = create_user('person_1').person + person.add_friend(profile) get :index, :profile => person.identifier - assert_tag :tag => 'a', :content => /#{profile.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } + assert_tag :tag => 'a', :content => /#{person.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } end should 'display tag for profile' do @@ -232,6 +233,7 @@ class ProfileControllerTest < ActionController::TestCase should 'display "Products" link for enterprise' do ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) + product = fast_create(Product, :profile_id => ent.id) get :index, :profile => 'my-test-enterprise' assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ @@ -1081,8 +1083,16 @@ class ProfileControllerTest < ActionController::TestCase atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) get :index, :profile => person.identifier assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'} + end + + should "show the network activity if the viewer follows the profile" do + login_as(profile.identifier) + person = fast_create(Person) + at = fast_create(ActionTracker::Record, :user_id => person.id) + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) person.add_friend(profile) + profile.add_friend(person) get :index, :profile => person.identifier assert_tag :tag => 'div', :attributes => {:id => 'profile-network'} end @@ -1101,8 +1111,16 @@ class ProfileControllerTest < ActionController::TestCase scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) get :index, :profile => person.identifier assert_no_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } + end + + should "show the scrap area on wall if the user follows the user" do + login_as(profile.identifier) + person = fast_create(Person) + scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) person.add_friend(profile) + profile.add_friend(person) + get :index, :profile => person.identifier assert_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } end @@ -1470,9 +1488,9 @@ class ProfileControllerTest < ActionController::TestCase viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public', 'birth_date' => 'public' } } viewed.save! get :index, :profile => viewed.identifier - assert_tag :tag => 'td', :content => 'Sex:' + assert_tag :tag => 'td', :content => 'Sex' assert_tag :tag => 'td', :content => 'Male' - assert_tag :tag => 'td', :content => 'Date of birth:' + assert_tag :tag => 'td', :content => 'Date of birth' assert_tag :tag => 'td', :content => 'August 26, 1990' end @@ -1484,9 +1502,9 @@ class ProfileControllerTest < ActionController::TestCase viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public' } } viewed.save! get :index, :profile => viewed.identifier - assert_tag :tag => 'td', :content => 'Sex:' + assert_tag :tag => 'td', :content => 'Sex' assert_tag :tag => 'td', :content => 'Male' - assert_no_tag :tag => 'td', :content => 'Date of birth:' + assert_no_tag :tag => 'td', :content => 'Date of birth' assert_no_tag :tag => 'td', :content => 'August 26, 1990' end @@ -1500,9 +1518,9 @@ class ProfileControllerTest < ActionController::TestCase strange = create_user('person_2').person login_as(strange.identifier) get :index, :profile => viewed.identifier - assert_tag :tag => 'td', :content => 'Sex:' + assert_tag :tag => 'td', :content => 'Sex' assert_tag :tag => 'td', :content => 'Male' - assert_no_tag :tag => 'td', :content => 'Date of birth:' + assert_no_tag :tag => 'td', :content => 'Date of birth' assert_no_tag :tag => 'td', :content => 'August 26, 1990' end @@ -1517,9 +1535,9 @@ class ProfileControllerTest < ActionController::TestCase Person.any_instance.stubs(:is_a_friend?).returns(true) login_as(friend.identifier) get :index, :profile => viewed.identifier - assert_tag :tag => 'td', :content => 'Sex:' + assert_tag :tag => 'td', :content => 'Sex' assert_tag :tag => 'td', :content => 'Male' - assert_tag :tag => 'td', :content => 'Date of birth:' + assert_tag :tag => 'td', :content => 'Date of birth' assert_tag :tag => 'td', :content => 'August 26, 1990' end @@ -1532,9 +1550,9 @@ class ProfileControllerTest < ActionController::TestCase viewed.save! login_as(viewed.identifier) get :index, :profile => viewed.identifier - assert_tag :tag => 'td', :content => 'Sex:' + assert_tag :tag => 'td', :content => 'Sex' assert_tag :tag => 'td', :content => 'Male' - assert_tag :tag => 'td', :content => 'Date of birth:' + assert_tag :tag => 'td', :content => 'Date of birth' assert_tag :tag => 'td', :content => 'August 26, 1990' end @@ -1547,7 +1565,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(strange.identifier) get :index, :profile => viewed.identifier assert_tag :tag => 'th', :content => 'Contact' - assert_tag :tag => 'td', :content => 'e-Mail:' + assert_tag :tag => 'td', :content => 'e-Mail' end should 'show contact to friend' do @@ -1560,7 +1578,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(friend.identifier) get :index, :profile => viewed.identifier assert_tag :tag => 'th', :content => 'Contact' - assert_tag :tag => 'td', :content => 'e-Mail:' + assert_tag :tag => 'td', :content => 'e-Mail' end should 'show contact to self' do @@ -1571,7 +1589,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(viewed.identifier) get :index, :profile => viewed.identifier assert_tag :tag => 'th', :content => 'Contact' - assert_tag :tag => 'td', :content => 'e-Mail:' + assert_tag :tag => 'td', :content => 'e-Mail' end should 'not show contact to non friend' do @@ -1583,7 +1601,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(strange.identifier) get :index, :profile => viewed.identifier assert_no_tag :tag => 'th', :content => 'Contact' - assert_no_tag :tag => 'td', :content => 'e-Mail:' + assert_no_tag :tag => 'td', :content => 'e-Mail' end should 'show contact to friend even if private' do @@ -1596,7 +1614,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(friend.identifier) get :index, :profile => viewed.identifier assert_tag :tag => 'th', :content => 'Contact' - assert_tag :tag => 'td', :content => 'e-Mail:' + assert_tag :tag => 'td', :content => 'e-Mail' end should 'show contact to self even if private' do @@ -1607,7 +1625,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(viewed.identifier) get :index, :profile => viewed.identifier assert_tag :tag => 'th', :content => 'Contact' - assert_tag :tag => 'td', :content => 'e-Mail:' + assert_tag :tag => 'td', :content => 'e-Mail' end should 'not display list of communities to manage on menu by default' do @@ -1715,22 +1733,28 @@ class ProfileControllerTest < ActionController::TestCase should 'show enterprises field if enterprises are enabled on environment' do person = fast_create(Person) + enterprise = fast_create(Enterprise) + enterprise.add_admin person environment = person.environment environment.disable('disable_asset_enterprises') environment.save! get :index, :profile => person.identifier - assert_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } + assert_tag :tag => 'td', :content => 'Enterprises' + assert_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} end should 'not show enterprises field if enterprises are disabled on environment' do person = fast_create(Person) + enterprise = fast_create(Enterprise) + enterprise.add_admin person environment = person.environment environment.enable('disable_asset_enterprises') environment.save! get :index, :profile => person.identifier - assert_no_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } + assert_no_tag :tag => 'td', :content => 'Enterprises' + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} end end -- libgit2 0.21.2