From 191ef25a9c5357053a4ef107735bde85fee71477 Mon Sep 17 00:00:00 2001 From: ishikawa999 Date: Sat, 8 May 2021 05:48:12 +0000 Subject: [PATCH 1/2] Add test --- app/views/projects/_members_box.html.erb | 7 +++++++ test/functional/projects_controller_test.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/views/projects/_members_box.html.erb b/app/views/projects/_members_box.html.erb index e915ab910..bec4a6a3a 100644 --- a/app/views/projects/_members_box.html.erb +++ b/app/views/projects/_members_box.html.erb @@ -4,5 +4,12 @@ <% @principals_by_role.keys.sort.each do |role| %>

<%= role %>: <%= @principals_by_role[role].sort.collect{|p| link_to_user p}.join(", ").html_safe %>

<% end %> + <% if @project.is_public %> +
+
+

<%= l(:field_is_public) %>: <%= l(:general_text_Yes) %> + <%= Setting.login_required? ? l(:text_project_is_public_non_member) : l(:text_project_is_public_anonymous) %> +

+ <% end -%> <% end %> diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 2c3cb2968..a76f3d20c 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -673,6 +673,33 @@ class ProjectsControllerTest < Redmine::ControllerTest assert_select '#main.nosidebar' end + def test_show_should_display_is_public_project_notice + p = Project.find('ecookbook') + assert p.is_public? + + with_settings :login_required => '0' do + get(:show, :params => {:id => p.identifier}) + assert_response :success + assert_select '#is-public-project-notice .info', :text => l(:text_project_is_public_anonymous) + end + + with_settings :login_required => '1' do + @request.session[:user_id] = 1 + get(:show, :params => {:id => p.identifier}) + assert_response :success + assert_select '#is-public-project-notice .info', :text => l(:text_project_is_public_non_member) + end + end + + def test_show_should_display_is_private_project_notice + @request.session[:user_id] = 1 + p = Project.find('private-child') + assert_not p.is_public? + get(:show, :params => {:id => p.identifier}) + assert_response :success + assert_select '#is-public-project-notice', :count => 0 + end + def test_show_should_display_visible_custom_fields ProjectCustomField.find_by_name('Development status').update_attribute :visible, true get(:show, :params => {:id => 'ecookbook'}) -- 2.11.0