· 7 years ago · Jun 02, 2018, 09:10 PM
1diff --git a/app/views/spaces/portfolio/index.rhtml b/app/views/spaces/portfolio/index.rhtml
2index 00d9bcc..3bdcd9c 100644
3--- a/app/views/spaces/portfolio/index.rhtml
4+++ b/app/views/spaces/portfolio/index.rhtml
5@@ -18,7 +18,9 @@
6 <% end %>
7 <th width="17%"><%= _("Payer")%></th>
8 <th width="18%"><a class="noBorder" href="<%= url_for :order=>"date", :sort=>(@order == "date" && @sort=="asc" ? "desc" : "asc")%>"><%= _("Last report date")%></a> <%=image_tag @sort+".gif" if @order == "date"%></th>
9- <th> </th>
10+ <% if logged_in? and @space.is_owner?(current_user) %>
11+ <th> </th>
12+ <% end %>
13 </tr>
14 <% for space in @managed_spaces
15 settings = nil
16@@ -40,9 +42,9 @@ settings = @member_tools[space.id].first.settings_obj if @member_tools[space.id]
17 <td> </td>
18 <td> </td>
19 <% end -%>
20- <% if space.parent.is_owner?(current_user) %>
21- <td><div class="icon"><img src="/images/ico_detremove.gif" alt="Remove from the portfolio" /></div><%= link_to _("Remove from the portfolio"), { :controller => 'spaces/portfolio_member', :action=>"remove", :id => space, :back_to_list => 1 }, :confirm => _("Are you sure you want to remove this space from the portfolio?") %></td>
22- <% end %>
23+ <% if logged_in? and @space.is_owner?(current_user) %>
24+ <td><div class="icon"><img src="/images/ico_detremove.gif" alt="Remove from the portfolio" /></div><%= link_to _("Remove from the portfolio"), { :controller => 'spaces/portfolio_member', :action=>"remove", :id => space, :back_to_list => 1 }, :confirm => _("Are you sure you want to remove this space from the portfolio?") %></td>
25+ <% end %>
26 </tr>
27 <% if settings -%>
28 <tr id="tr_<%= space.id %>" style="display:none;">
29diff --git a/test/fixtures/space_tools.yml b/test/fixtures/space_tools.yml
30index be5908d..ec10d6f 100644
31--- a/test/fixtures/space_tools.yml
32+++ b/test/fixtures/space_tools.yml
33@@ -116,6 +116,13 @@ portfolio_m_tool_p:
34 type: PortfolioManagerTool
35 tool_id: <%= PortfolioManagerTool::ID %>
36
37+portfolio_m_tool_p2:
38+ space_id: 3
39+ active: 1
40+ secret_key: portfolio_manager_key2
41+ type: PortfolioManagerTool
42+ tool_id: <%= PortfolioManagerTool::ID %>
43+
44 staffing_test_space_recruiting_tool:
45 id: 8208
46 space_id: 10009
47@@ -231,6 +238,14 @@ portfolio_mmember_tool_p:
48 type: PortfolioMemberTool
49 tool_id: <%= PortfolioMemberTool::ID %>
50
51+new_space_child:
52+ id: 8212
53+ space_id: 12333
54+ active: 1
55+ secret_key: portfolio_member_key2
56+ type: PortfolioMemberTool
57+ tool_id: <%= PortfolioMemberTool::ID %>
58+
59 no_space_tool:
60 space: no_space
61 active: 1
62diff --git a/test/fixtures/spaces.yml b/test/fixtures/spaces.yml
63index 0afa7ab..719e315 100644
64--- a/test/fixtures/spaces.yml
65+++ b/test/fixtures/spaces.yml
66@@ -325,3 +325,14 @@ watcher_private_space:
67 created_at: 2006-06-24 23:47
68 commercial_from: 2008-10-24 00:47
69 watcher_permissions: <%= Space::PERMISSION_VIEW %>
70+
71+#====================fixture(s) for commercial spaces billing testing end============================
72+
73+new_space2:
74+ id: 12333
75+ parent_id: 3
76+ name: 'NewSpace2'
77+ public_permissions: <%= Space::PERMISSION_EDIT %>
78+ team_permissions: <%= Space::PERMISSION_EDIT %>
79+ created_at: 2006-06-24 23:47
80+ updated_at: 2006-06-24 23:47
81diff --git a/test/functional/spaces/portfolio_controller_test.rb b/test/functional/spaces/portfolio_controller_test.rb
82index 2ea5385..4e6dbc8 100644
83--- a/test/functional/spaces/portfolio_controller_test.rb
84+++ b/test/functional/spaces/portfolio_controller_test.rb
85@@ -63,17 +63,37 @@ class Spaces::PortfolioControllerTest < Test::Unit::TestCase
86 assert_equal assigns(:child).id, "10002"
87 end
88
89- def test_index
90+ def test_index_public_view
91+ space = spaces(:public_view)
92+ get :index, :id => space.id
93+ assert_response :success, "Error while opening space for public view"
94+ assert_select "body", {:count => 1, :html => /Space name/}, "Here should be a list"
95+ assert_select "body", {:count => 0, :html => /Remove from the portfolio/}, "Anonymous users should not remove spaces from portfolio"
96+ end
97+
98+ def test_index_user_view
99+ login_user(:mike)
100+ space = spaces(:public_view)
101+ get :index, :id => space.id
102+ assert_response :success, "Error while opening space for public view"
103+ assert_select "body", {:count => 1, :html => /Space name/}, "Here should be a list"
104+ assert_select "body", {:count => 0, :html => /Remove from the portfolio/}, "Other users should not remove spaces from portfolio"
105+ end
106+
107+ def test_index_owner_view
108 login_user(:bob)
109 space = spaces(:public_none)
110 mt = space.spaces_tools.detect{ |t| t.tool_id == PortfolioManagerTool::ID}
111 get :index, :id => space.id, :sort => "desc", :order => "date"
112- assert_response :success
113+ assert_response :success, "Error while opening space for public view"
114 assert_template "index"
115+ assert_select "body", {:count => 1, :html => /Space name/}, "Here should be a list"
116+ assert_select "body", {:html => /Remove from the portfolio/}, "Owner must have rights to remove from portfolio"
117 assert_equal assigns(:tab), mt.tool_title
118 assert_equal assigns(:space).id, "4"
119 assert_equal assigns(:managed_spaces).size, 1
120 assert_equal assigns(:managed_spaces)[0].id, "10002"
121 assert_logged :error, /detected parent:child relation/
122 end
123+
124 end