]> source.dussan.org Git - redmine.git/commitdiff
Subprojects checkbox should be shown in Activity and Roadmap sidebars only if the...
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 26 Feb 2024 21:14:47 +0000 (21:14 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 26 Feb 2024 21:14:47 +0000 (21:14 +0000)
Patch by Holger Just (@hjust) and Marius BALTEANU (@marius.balteanu).

git-svn-id: https://svn.redmine.org/redmine/trunk@22739 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/activities/index.html.erb
app/views/versions/_sidebar.html.erb
test/functional/activities_controller_test.rb
test/functional/versions_controller_test.rb

index cb0bef9dc225a4fb4df2cfa453c80efb38e823fe..e5176d85950fbdd1c9027b69553fbb69664ad2a6 100644 (file)
@@ -50,7 +50,7 @@
   </li>
 <% end %>
 </ul>
-<% if @project && @project.descendants.active.any? %>
+<% if @project && @project.descendants.visible.any? %>
     <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
     <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
 <% end %>
index aecb7d131e65baba5656821a5e9f03f0f5b9b49d..809b60ded9f203f0c9d198d057551e6f8b9af81d 100644 (file)
@@ -20,7 +20,7 @@
       <%= check_box_tag "completed", 1, params[:completed] %> <%= l(:label_show_completed_versions) %>
     </label>
   </li>
-  <% if @project.descendants.active.any? %>
+  <% if @project.descendants.visible.any? %>
   <li>
     <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
     <label>
index fbbf9e601e76482a87a14466db482fb12489fbfb..0646df97fbb3b4a44fc0bb76e02208219162771d 100644 (file)
@@ -45,6 +45,34 @@ class ActivitiesControllerTest < Redmine::ControllerTest
     assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
   end
 
+  def test_index_subproject_checkbox_should_check_descendants_visibility
+    @request.session[:user_id] = 2
+    get(
+      :index,
+      :params => {
+        :id => 5,
+      }
+    )
+    assert_response :success
+
+    assert_select '#sidebar input#with_subprojects'
+
+    project = Project.find(6)
+    project.is_public = false
+    project.save
+
+    get(
+      :index,
+      :params => {
+        :id => 5,
+      }
+    )
+    assert_response :success
+
+    assert_select '#sidebar input#with_subprojects', :count => 0
+
+  end
+
   def test_project_index_with_invalid_project_id_should_respond_404
     get(:index, :params => {:id => 299})
     assert_response 404
index 5b72f4c481371918bdf8d8d4da8495cd20877685..0e6b018f66b738aca7e882946b8d4aaa5aed75af 100644 (file)
@@ -87,6 +87,8 @@ class VersionsControllerTest < Redmine::ControllerTest
     assert_select 'h3', :text => Version.find(4).name
     # Subproject version
     assert_select 'h3', :text => /#{version_name}/
+    # Subproject checkbox
+    assert_select '#sidebar input[id=?][value=?]', "with_subprojects", 1
   end
 
   def test_index_should_prepend_shared_versions
@@ -119,6 +121,20 @@ class VersionsControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_index_subproject_checkbox_should_check_descendants_visibility
+    project = Project.find(6)
+    project.is_public = false
+    project.save
+
+    @request.session[:user_id] = 2
+
+    get :index, :params => {:project_id => 5, :with_subprojects => 1}
+    assert_response :success
+
+    # Subproject checkbox should not be shown
+    assert_select '#sidebar input[id=?]', "with_subprojects", :count => 0
+  end
+
   def test_show
     with_settings :gravatar_enabled => '0' do
       get :show, :params => {:id => 2}