Commit 68acfa9ba279d9cad7392a350e9e007bf310c5a3

Authored by JoenioCosta
1 parent c05f52ba

ActionItem276: added functional tests to profile controller

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1664 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/person.rb
... ... @@ -21,9 +21,6 @@ class Person < Profile
21 21 def remove_friend(friend)
22 22 friends.delete(friend)
23 23 end
24   -
25   -# has_many :person_friendships
26   -# has_many :people, :through => :person_friendships, :foreign_key => 'friend_id'
27 24  
28 25 has_one :person_info
29 26  
... ...
app/views/profile/index.rhtml
... ... @@ -11,9 +11,11 @@
11 11 </li>
12 12  
13 13 <%# FIXME %>
14   - <li><%= link_to _('Friends'), :action => 'friends' %></li>
15   - <li><%= link_to _('Communities'), :action => 'communities' %></li>
16   - <li><%= link_to _('Enterprises'), :action => 'enterprises' %></li>
  14 + <% if profile.kind_of? Person %>
  15 + <li><%= link_to _('Friends'), :action => 'friends' %></li>
  16 + <li><%= link_to _('Communities'), :action => 'communities' %></li>
  17 + <li><%= link_to _('Enterprises'), :action => 'enterprises' %></li>
  18 + <% end %>
17 19 <% if profile.kind_of? Organization %>
18 20 <li><%= link_to _('Members'), :action => 'members' %></li>
19 21 <% end %>
... ...
test/functional/profile_controller_test.rb
... ... @@ -68,4 +68,24 @@ class ProfileControllerTest &lt; Test::Unit::TestCase
68 68 assert_no_tag :tag => 'a', :content => 'Join this community'
69 69 end
70 70  
  71 + should 'dont show enterprises link to enterprise' do
  72 + ent = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1')
  73 + get :index, :profile => ent.identifier
  74 + assert_tag :tag => 'h2', :content => "#{ent.identifier}'s profile"
  75 + assert_no_tag :tag => 'a', :content => 'Enterprises', :attributes => { :href => /profile\/#{ent.identifier}\/enterprises$/ }
  76 + end
  77 +
  78 + should 'dont show members link to person' do
  79 + person = create_user('person_1').person
  80 + get :index, :profile => person.identifier
  81 + assert_tag :tag => 'h2', :content => "#{person.identifier}'s profile"
  82 + assert_no_tag :tag => 'a', :content => 'Members', :attributes => { :href => /profile\/#{person.identifier}\/members$/ }
  83 + end
  84 +
  85 + should 'show friends link to person' do
  86 + person = create_user('person_1').person
  87 + get :index, :profile => person.identifier
  88 + assert_tag :tag => 'a', :content => 'Friends', :attributes => { :href => /profile\/#{person.identifier}\/friends$/ }
  89 + end
  90 +
71 91 end
... ...