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