OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
store project settings data and include feature specs
Bruno Pagno31f65ec4ffc5
diff --git a/app/controllers/projects/settings/work_packages/activities_controller.rb b/app/controllers/projects/settings/work_packages/activities_controller.rbindex b1db79446d2..18a756f1174 100644--- a/app/controllers/projects/settings/work_packages/activities_controller.rb+++ b/app/controllers/projects/settings/work_packages/activities_controller.rb@@ -32,6 +32,23 @@ class Projects::Settings::WorkPackages::ActivitiesController < Projects::Settingmenu_item :settings_work_packagesdef update- redirect_to :show+ enabled = ActiveRecord::Type::Boolean.new.cast(expected_params[:enabled_comments_with_restricted_visibility])+ result = Projects::UpdateService+ .new(user: current_user, model: @project, contract_class: Projects::SettingsContract)+ .call(enabled_comments_with_restricted_visibility: enabled)++ if result.success?+ flash[:notice] = t("notice_successful_update")+ else+ flash[:error] = t("notice_unsuccessful_update")+ end++ redirect_to project_settings_work_packages_activities_path+ end++ private++ def expected_params+ params.expect(project: [:enabled_comments_with_restricted_visibility])endenddiff --git a/app/models/project.rb b/app/models/project.rbindex f368c165fa2..79440b6a6fa 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -99,6 +99,7 @@ class Project < ApplicationRecordvalidates_associated :available_life_cycle_steps, on: :saving_life_cycle_stepsstore_attribute :settings, :deactivate_work_package_attachments, :boolean+ store_attribute :settings, :enabled_comments_with_restricted_visibility, :booleanacts_as_favorablediff --git a/app/views/projects/settings/work_packages/activities/show.html.erb b/app/views/projects/settings/work_packages/activities/show.html.erbindex 1ea3a215e43..c8f1b2c66fe 100644--- a/app/views/projects/settings/work_packages/activities/show.html.erb+++ b/app/views/projects/settings/work_packages/activities/show.html.erb@@ -29,4 +29,15 @@ See COPYRIGHT and LICENSE files for more details.<%= render(Settings::ProjectWorkPackages::HeaderComponent.new(@project, selected: :activities)) %>-<span>Form goes here</span>+<%=+ # this could be exctracted into a Form component+ form_for @project,+ url: project_settings_work_packages_activities_path(@project),+ method: :patch,+ html: { id: "activities-form" } do |f|+%>+ <%= f.check_box :enabled_comments_with_restricted_visibility %>+ <%= f.label :enabled_comments_with_restricted_visibility, "Enable comments with restricted visibility" %>+ <p>Helper text here</p>+ <%= f.submit "Save" %>+<% end %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 8afc1681081..42ffa81138b 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3367,6 +3367,7 @@ en:notice_successful_delete: "Successful deletion."notice_successful_cancel: "Successful cancellation."notice_successful_update: "Successful update."+ notice_unsuccessful_update: "Update failed."notice_successful_update_custom_fields_added_to_project: |Successful update. The custom fields of the activated types are automatically activatedon the work package form. <a href="%{url}" target="_blank">See more</a>.diff --git a/spec/features/projects/settings/activities_settings_spec.rb b/spec/features/projects/settings/activities_settings_spec.rbnew file mode 100644index 00000000000..31238e0041b--- /dev/null+++ b/spec/features/projects/settings/activities_settings_spec.rb@@ -0,0 +1,57 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"++RSpec.describe "WorkPackages-Settings-Activities", :js do+ let!(:project) { create(:project) }+ let(:activities_settings_page) { Pages::Projects::Settings::Activities.new(project) }++ current_user { create(:admin) }++ it "enables and disables the settings for the project" do+ activities_settings_page.visit!+ expect(page).to have_css("#activities-form")++ expect(page).to have_field(:project_enabled_comments_with_restricted_visibility, checked: false)++ check("Enable comments with restricted visibility")+ click_link_or_button "Save"++ expect_and_dismiss_flash(message: "Successful update.")+ expect(page).to have_field(:project_enabled_comments_with_restricted_visibility, checked: true)++ uncheck("Enable comments with restricted visibility")+ click_link_or_button "Save"++ expect_and_dismiss_flash(message: "Successful update.")+ expect(page).to have_field(:project_enabled_comments_with_restricted_visibility, checked: false)+ end+enddiff --git a/spec/features/projects/work_packages_settings_spec.rb b/spec/features/projects/settings/work_packages_settings_spec.rbsimilarity index 98%rename from spec/features/projects/work_packages_settings_spec.rbrename to spec/features/projects/settings/work_packages_settings_spec.rbindex 2c6060306ec..7d7aa81dba3 100644--- a/spec/features/projects/work_packages_settings_spec.rb+++ b/spec/features/projects/settings/work_packages_settings_spec.rb@@ -80,7 +80,7 @@ RSpec.describe "Projects", "work packages settings menu", :js doit "displays the custom fields tab" dowork_packages_settings_page.visit!expect(page).to have_css(".tabnav-tab", text: "Activity")- expect(page).to have_css("span", text: "Form goes here")+ expect(page).to have_css("#activities-form")endenddiff --git a/spec/support/pages/projects/settings/activities.rb b/spec/support/pages/projects/settings/activities.rbnew file mode 100644index 00000000000..b8c70b9d1cc--- /dev/null+++ b/spec/support/pages/projects/settings/activities.rb@@ -0,0 +1,51 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require "support/pages/page"++module Pages+ module Projects+ module Settings+ class Activities < Pages::Page+ attr_accessor :project++ def initialize(project)+ super()++ @project = project+ end++ def path+ "/projects/#{project.identifier}/settings/work_packages/activities"+ end+ end+ end+ end+end