Commit e7e132e71f3e4271d28e94784e743a644e955eb8
1 parent
5c42f6c1
Exists in
master
and in
29 other branches
Fix: profile_controller tests
Showing
2 changed files
with
46 additions
and
20 deletions
Show diff stats
app/helpers/profile_helper.rb
| ... | ... | @@ -78,7 +78,9 @@ module ProfileHelper |
| 78 | 78 | entries = multiple ? value : [] << value |
| 79 | 79 | entries.map do |entry| |
| 80 | 80 | content = self.send("treat_#{field}", entry) |
| 81 | - content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) | |
| 81 | + unless content.blank? | |
| 82 | + content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) | |
| 83 | + end | |
| 82 | 84 | end.join("\n") |
| 83 | 85 | else |
| 84 | 86 | '' | ... | ... |
test/functional/profile_controller_test.rb
| ... | ... | @@ -109,8 +109,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 109 | 109 | |
| 110 | 110 | should 'show friends link to person' do |
| 111 | 111 | person = create_user('person_1').person |
| 112 | + person.add_friend(profile) | |
| 112 | 113 | get :index, :profile => person.identifier |
| 113 | - assert_tag :tag => 'a', :content => /#{profile.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } | |
| 114 | + assert_tag :tag => 'a', :content => /#{person.friends.count}/, :attributes => { :href => /profile\/#{person.identifier}\/friends$/ } | |
| 114 | 115 | end |
| 115 | 116 | |
| 116 | 117 | should 'display tag for profile' do |
| ... | ... | @@ -232,6 +233,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 232 | 233 | |
| 233 | 234 | should 'display "Products" link for enterprise' do |
| 234 | 235 | ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false) |
| 236 | + product = fast_create(Product, :profile_id => ent.id) | |
| 235 | 237 | |
| 236 | 238 | get :index, :profile => 'my-test-enterprise' |
| 237 | 239 | assert_tag :tag => 'a', :attributes => { :href => '/catalog/my-test-enterprise'}, :content => /Products\/Services/ |
| ... | ... | @@ -1081,8 +1083,16 @@ class ProfileControllerTest < ActionController::TestCase |
| 1081 | 1083 | atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) |
| 1082 | 1084 | get :index, :profile => person.identifier |
| 1083 | 1085 | assert_no_tag :tag => 'div', :attributes => {:id => 'profile-network'} |
| 1086 | + end | |
| 1087 | + | |
| 1088 | + should "show the network activity if the viewer follows the profile" do | |
| 1089 | + login_as(profile.identifier) | |
| 1090 | + person = fast_create(Person) | |
| 1091 | + at = fast_create(ActionTracker::Record, :user_id => person.id) | |
| 1092 | + atn = fast_create(ActionTrackerNotification, :profile_id => profile.id, :action_tracker_id => at.id) | |
| 1084 | 1093 | |
| 1085 | 1094 | person.add_friend(profile) |
| 1095 | + profile.add_friend(person) | |
| 1086 | 1096 | get :index, :profile => person.identifier |
| 1087 | 1097 | assert_tag :tag => 'div', :attributes => {:id => 'profile-network'} |
| 1088 | 1098 | end |
| ... | ... | @@ -1101,8 +1111,16 @@ class ProfileControllerTest < ActionController::TestCase |
| 1101 | 1111 | scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) |
| 1102 | 1112 | get :index, :profile => person.identifier |
| 1103 | 1113 | assert_no_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } |
| 1114 | + end | |
| 1115 | + | |
| 1116 | + should "show the scrap area on wall if the user follows the user" do | |
| 1117 | + login_as(profile.identifier) | |
| 1118 | + person = fast_create(Person) | |
| 1119 | + scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => profile.id) | |
| 1104 | 1120 | |
| 1105 | 1121 | person.add_friend(profile) |
| 1122 | + profile.add_friend(person) | |
| 1123 | + | |
| 1106 | 1124 | get :index, :profile => person.identifier |
| 1107 | 1125 | assert_tag :tag => 'div', :attributes => {:id => 'leave_scrap'}, :descendant => { :tag => 'input', :attributes => {:value => 'Share'} } |
| 1108 | 1126 | end |
| ... | ... | @@ -1470,9 +1488,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 1470 | 1488 | viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public', 'birth_date' => 'public' } } |
| 1471 | 1489 | viewed.save! |
| 1472 | 1490 | get :index, :profile => viewed.identifier |
| 1473 | - assert_tag :tag => 'td', :content => 'Sex:' | |
| 1491 | + assert_tag :tag => 'td', :content => 'Sex' | |
| 1474 | 1492 | assert_tag :tag => 'td', :content => 'Male' |
| 1475 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
| 1493 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
| 1476 | 1494 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
| 1477 | 1495 | end |
| 1478 | 1496 | |
| ... | ... | @@ -1484,9 +1502,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 1484 | 1502 | viewed.data = { :sex => 'male', :fields_privacy => { 'sex' => 'public' } } |
| 1485 | 1503 | viewed.save! |
| 1486 | 1504 | get :index, :profile => viewed.identifier |
| 1487 | - assert_tag :tag => 'td', :content => 'Sex:' | |
| 1505 | + assert_tag :tag => 'td', :content => 'Sex' | |
| 1488 | 1506 | assert_tag :tag => 'td', :content => 'Male' |
| 1489 | - assert_no_tag :tag => 'td', :content => 'Date of birth:' | |
| 1507 | + assert_no_tag :tag => 'td', :content => 'Date of birth' | |
| 1490 | 1508 | assert_no_tag :tag => 'td', :content => 'August 26, 1990' |
| 1491 | 1509 | end |
| 1492 | 1510 | |
| ... | ... | @@ -1500,9 +1518,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 1500 | 1518 | strange = create_user('person_2').person |
| 1501 | 1519 | login_as(strange.identifier) |
| 1502 | 1520 | get :index, :profile => viewed.identifier |
| 1503 | - assert_tag :tag => 'td', :content => 'Sex:' | |
| 1521 | + assert_tag :tag => 'td', :content => 'Sex' | |
| 1504 | 1522 | assert_tag :tag => 'td', :content => 'Male' |
| 1505 | - assert_no_tag :tag => 'td', :content => 'Date of birth:' | |
| 1523 | + assert_no_tag :tag => 'td', :content => 'Date of birth' | |
| 1506 | 1524 | assert_no_tag :tag => 'td', :content => 'August 26, 1990' |
| 1507 | 1525 | end |
| 1508 | 1526 | |
| ... | ... | @@ -1517,9 +1535,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 1517 | 1535 | Person.any_instance.stubs(:is_a_friend?).returns(true) |
| 1518 | 1536 | login_as(friend.identifier) |
| 1519 | 1537 | get :index, :profile => viewed.identifier |
| 1520 | - assert_tag :tag => 'td', :content => 'Sex:' | |
| 1538 | + assert_tag :tag => 'td', :content => 'Sex' | |
| 1521 | 1539 | assert_tag :tag => 'td', :content => 'Male' |
| 1522 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
| 1540 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
| 1523 | 1541 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
| 1524 | 1542 | end |
| 1525 | 1543 | |
| ... | ... | @@ -1532,9 +1550,9 @@ class ProfileControllerTest < ActionController::TestCase |
| 1532 | 1550 | viewed.save! |
| 1533 | 1551 | login_as(viewed.identifier) |
| 1534 | 1552 | get :index, :profile => viewed.identifier |
| 1535 | - assert_tag :tag => 'td', :content => 'Sex:' | |
| 1553 | + assert_tag :tag => 'td', :content => 'Sex' | |
| 1536 | 1554 | assert_tag :tag => 'td', :content => 'Male' |
| 1537 | - assert_tag :tag => 'td', :content => 'Date of birth:' | |
| 1555 | + assert_tag :tag => 'td', :content => 'Date of birth' | |
| 1538 | 1556 | assert_tag :tag => 'td', :content => 'August 26, 1990' |
| 1539 | 1557 | end |
| 1540 | 1558 | |
| ... | ... | @@ -1547,7 +1565,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1547 | 1565 | login_as(strange.identifier) |
| 1548 | 1566 | get :index, :profile => viewed.identifier |
| 1549 | 1567 | assert_tag :tag => 'th', :content => 'Contact' |
| 1550 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
| 1568 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
| 1551 | 1569 | end |
| 1552 | 1570 | |
| 1553 | 1571 | should 'show contact to friend' do |
| ... | ... | @@ -1560,7 +1578,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1560 | 1578 | login_as(friend.identifier) |
| 1561 | 1579 | get :index, :profile => viewed.identifier |
| 1562 | 1580 | assert_tag :tag => 'th', :content => 'Contact' |
| 1563 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
| 1581 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
| 1564 | 1582 | end |
| 1565 | 1583 | |
| 1566 | 1584 | should 'show contact to self' do |
| ... | ... | @@ -1571,7 +1589,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1571 | 1589 | login_as(viewed.identifier) |
| 1572 | 1590 | get :index, :profile => viewed.identifier |
| 1573 | 1591 | assert_tag :tag => 'th', :content => 'Contact' |
| 1574 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
| 1592 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
| 1575 | 1593 | end |
| 1576 | 1594 | |
| 1577 | 1595 | should 'not show contact to non friend' do |
| ... | ... | @@ -1583,7 +1601,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1583 | 1601 | login_as(strange.identifier) |
| 1584 | 1602 | get :index, :profile => viewed.identifier |
| 1585 | 1603 | assert_no_tag :tag => 'th', :content => 'Contact' |
| 1586 | - assert_no_tag :tag => 'td', :content => 'e-Mail:' | |
| 1604 | + assert_no_tag :tag => 'td', :content => 'e-Mail' | |
| 1587 | 1605 | end |
| 1588 | 1606 | |
| 1589 | 1607 | should 'show contact to friend even if private' do |
| ... | ... | @@ -1596,7 +1614,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1596 | 1614 | login_as(friend.identifier) |
| 1597 | 1615 | get :index, :profile => viewed.identifier |
| 1598 | 1616 | assert_tag :tag => 'th', :content => 'Contact' |
| 1599 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
| 1617 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
| 1600 | 1618 | end |
| 1601 | 1619 | |
| 1602 | 1620 | should 'show contact to self even if private' do |
| ... | ... | @@ -1607,7 +1625,7 @@ class ProfileControllerTest < ActionController::TestCase |
| 1607 | 1625 | login_as(viewed.identifier) |
| 1608 | 1626 | get :index, :profile => viewed.identifier |
| 1609 | 1627 | assert_tag :tag => 'th', :content => 'Contact' |
| 1610 | - assert_tag :tag => 'td', :content => 'e-Mail:' | |
| 1628 | + assert_tag :tag => 'td', :content => 'e-Mail' | |
| 1611 | 1629 | end |
| 1612 | 1630 | |
| 1613 | 1631 | should 'not display list of communities to manage on menu by default' do |
| ... | ... | @@ -1715,22 +1733,28 @@ class ProfileControllerTest < ActionController::TestCase |
| 1715 | 1733 | |
| 1716 | 1734 | should 'show enterprises field if enterprises are enabled on environment' do |
| 1717 | 1735 | person = fast_create(Person) |
| 1736 | + enterprise = fast_create(Enterprise) | |
| 1737 | + enterprise.add_admin person | |
| 1718 | 1738 | environment = person.environment |
| 1719 | 1739 | environment.disable('disable_asset_enterprises') |
| 1720 | 1740 | environment.save! |
| 1721 | 1741 | |
| 1722 | 1742 | get :index, :profile => person.identifier |
| 1723 | - assert_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } | |
| 1743 | + assert_tag :tag => 'td', :content => 'Enterprises' | |
| 1744 | + assert_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} | |
| 1724 | 1745 | end |
| 1725 | 1746 | |
| 1726 | 1747 | should 'not show enterprises field if enterprises are disabled on environment' do |
| 1727 | 1748 | person = fast_create(Person) |
| 1749 | + enterprise = fast_create(Enterprise) | |
| 1750 | + enterprise.add_admin person | |
| 1728 | 1751 | environment = person.environment |
| 1729 | 1752 | environment.enable('disable_asset_enterprises') |
| 1730 | 1753 | environment.save! |
| 1731 | 1754 | |
| 1732 | 1755 | get :index, :profile => person.identifier |
| 1733 | - assert_no_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" } | |
| 1756 | + assert_no_tag :tag => 'td', :content => 'Enterprises' | |
| 1757 | + assert_no_tag :tag => 'td', :descendant => { :tag => 'a', :content => /#{person.enterprises.count}/, :attributes => { :href => /profile\/#{person.identifier}\/enterprises$/ }} | |
| 1734 | 1758 | end |
| 1735 | 1759 | |
| 1736 | 1760 | end | ... | ... |