Commit 60fa418f09737c172ff2951c2198b367563174cf
1 parent
c806d821
Exists in
master
and in
29 other branches
Adding tests to verify solution to AI1030
ActionItem1030
Showing
2 changed files
with
61 additions
and
4 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1132,7 +1132,8 @@ module ApplicationHelper |
1132 | 1132 | end |
1133 | 1133 | |
1134 | 1134 | def manage_enterprises |
1135 | - if user && !user.enterprises.empty? | |
1135 | + return if not user | |
1136 | + if !user.enterprises.empty? | |
1136 | 1137 | enterprises_link = user.enterprises.map do |enterprise| |
1137 | 1138 | link_to(content_tag('strong', [_('<span>Manage</span> %s') % enterprise.short_name(25)]), @environment.top_url + "/myprofile/#{enterprise.identifier}", :class => "icon-menu-"+enterprise.class.identification.underscore, :title => [_('Manage %s') % enterprise.short_name]) |
1138 | 1139 | end | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -96,7 +96,7 @@ class ProfileControllerTest < ActionController::TestCase |
96 | 96 | end |
97 | 97 | |
98 | 98 | should 'not show enterprises link to enterprise' do |
99 | - ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enteprise1') | |
99 | + ent = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enterprise1') | |
100 | 100 | get :index, :profile => ent.identifier |
101 | 101 | assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ } |
102 | 102 | end |
... | ... | @@ -561,7 +561,7 @@ class ProfileControllerTest < ActionController::TestCase |
561 | 561 | assert_response 403 |
562 | 562 | end |
563 | 563 | |
564 | - should 'allow environment admin to unblock enteprises' do | |
564 | + should 'allow environment admin to unblock enterprises' do | |
565 | 565 | login_as(profile.identifier) |
566 | 566 | enterprise = fast_create(Enterprise) |
567 | 567 | enterprise.environment.add_admin(profile) |
... | ... | @@ -882,7 +882,7 @@ class ProfileControllerTest < ActionController::TestCase |
882 | 882 | assert_template 'index' |
883 | 883 | end |
884 | 884 | |
885 | - should 'the network activity be visible to uses not logged in on communities and enteprises' do | |
885 | + should 'the network activity be visible to uses not logged in on communities and enterprises' do | |
886 | 886 | p1= Person.first |
887 | 887 | community = fast_create(Community) |
888 | 888 | p2= fast_create(Person) |
... | ... | @@ -1521,4 +1521,60 @@ class ProfileControllerTest < ActionController::TestCase |
1521 | 1521 | assert_tag :tag => 'td', :content => 'e-Mail:' |
1522 | 1522 | end |
1523 | 1523 | |
1524 | + should 'build menu to the community panel' do | |
1525 | + u = create_user('other_other_ze').person | |
1526 | + u2 = create_user('guy_that_will_be_admin_of_all').person # because the first member of each community is an admin | |
1527 | + Environment.any_instance.stubs(:required_person_fields).returns([]) | |
1528 | + u.data = { :email => 'test@test.com', :fields_privacy => { } } | |
1529 | + u.save! | |
1530 | + c1 = Community.create!(:name => 'community_1') | |
1531 | + c2 = Community.create!(:name => 'community_2') | |
1532 | + c3 = Community.create!(:name => 'community_3') | |
1533 | + c4 = Community.create!(:name => 'community_4') | |
1534 | + | |
1535 | + c1.add_admin(u2) | |
1536 | + c2.add_admin(u2) | |
1537 | + c3.add_admin(u2) | |
1538 | + | |
1539 | + c1.add_member(u) | |
1540 | + c2.add_member(u) | |
1541 | + c3.add_member(u) | |
1542 | + c1.add_admin(u) | |
1543 | + c2.add_admin(u) | |
1544 | + | |
1545 | + login_as(u.identifier) | |
1546 | + | |
1547 | + get :index | |
1548 | + | |
1549 | + assert_tag :tag => 'div', :attributes => {:id => 'manage-communities'} | |
1550 | + assert_select '#manage-communities li > a' do |links| | |
1551 | + assert_equal 2, links.length | |
1552 | + assert_match /community_1/, links.to_s | |
1553 | + assert_match /community_2/, links.to_s | |
1554 | + assert_no_match /community_3/, links.to_s | |
1555 | + assert_no_match /community_4/, links.to_s | |
1556 | + end | |
1557 | + end | |
1558 | + | |
1559 | + should 'build menu to the enterprise panel' do | |
1560 | + u = create_user('other_other_ze').person | |
1561 | + Environment.any_instance.stubs(:required_person_fields).returns([]) | |
1562 | + u.data = { :email => 'test@test.com', :fields_privacy => { } } | |
1563 | + u.save! | |
1564 | + e1 = fast_create(Enterprise, :identifier => 'test_enterprise1', :name => 'Test enterprise1') | |
1565 | + e2 = fast_create(Enterprise, :identifier => 'test_enterprise2', :name => 'Test enterprise2') | |
1566 | + | |
1567 | + e1.add_member(u) | |
1568 | + | |
1569 | + login_as(u.identifier) | |
1570 | + | |
1571 | + get :index | |
1572 | + | |
1573 | + assert_tag :tag => 'div', :attributes => {:id => 'manage-enterprises'} | |
1574 | + assert_select '#manage-enterprises li > a' do |links| | |
1575 | + assert_equal 1, links.length | |
1576 | + assert_match /Test enterprise1/, links.to_s | |
1577 | + assert_no_match /Test enterprise_2/, links.to_s | |
1578 | + end | |
1579 | + end | |
1524 | 1580 | end | ... | ... |