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
[#61889] Primerize Project Settings>Information forms
Alexander Brandon Colesb8988b3a69e8
diff --git a/app/components/projects/settings/general/show_component.html.erb b/app/components/projects/settings/general/show_component.html.erbnew file mode 100644index 00000000000..0364ec75f0d--- /dev/null+++ b/app/components/projects/settings/general/show_component.html.erb@@ -0,0 +1,87 @@+<%#-- 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.++++#%>++<%=+ flex_layout do |container|+ container.with_row(mb: 3) do+ admin_settings_primer_form_with(model: project, url: project_settings_general_path(project)) do |f|+ concat(+ render(Primer::Beta::Subhead.new) do |component|+ component.with_heading(tag: :h2, size: :medium) { I18n.t("projects.settings.header_details") }+ end+ )+ concat(+ render(+ Primer::Forms::FormList.new(+ Projects::Settings::NameForm.new(f),+ Projects::Settings::DescriptionForm.new(f),+ Projects::Settings::Submit.new(f, label: I18n.t("projects.settings.button_update_details"))+ )+ )+ )+ end+ end++ container.with_row(mb: 3) do+ admin_settings_primer_form_with(model: project, url: project_settings_general_path(project)) do |f|+ concat(+ render(Primer::Beta::Subhead.new) do |component|+ component.with_heading(tag: :h2, size: :medium) { I18n.t("projects.settings.header_status") }+ end+ )+ concat(+ render(+ Primer::Forms::FormList.new(+ Projects::Settings::StatusForm.new(f),+ Projects::Settings::Submit.new(f, label: I18n.t("projects.settings.button_update_status"))+ )+ )+ )+ end+ end++ container.with_row(mb: 3) do+ admin_settings_primer_form_with(model: project, url: project_settings_general_path(project)) do |f|+ concat(+ render(Primer::Beta::Subhead.new) do |component|+ component.with_heading(tag: :h2, size: :medium) { I18n.t("projects.settings.header_relations") }+ end+ )+ concat(+ render(+ Primer::Forms::FormList.new(+ Projects::Settings::RelationsForm.new(f),+ Projects::Settings::Submit.new(f, label: I18n.t("projects.settings.button_update_parent_project"))+ )+ )+ )+ end+ end+ end+%>diff --git a/app/components/projects/settings/general/show_component.rb b/app/components/projects/settings/general/show_component.rbnew file mode 100644index 00000000000..1828fbc0a4f--- /dev/null+++ b/app/components/projects/settings/general/show_component.rb@@ -0,0 +1,43 @@+# 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.+# ++++module Projects+ module Settings+ module General+ class ShowComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ options :project+ end+ end+ end+enddiff --git a/app/controllers/projects/settings/general_controller.rb b/app/controllers/projects/settings/general_controller.rbindex e2c56b3e2a6..575ba26193f 100644--- a/app/controllers/projects/settings/general_controller.rb+++ b/app/controllers/projects/settings/general_controller.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -46,4 +48,19 @@ class Projects::Settings::GeneralController < Projects::SettingsControllerredirect_to action: :show, status: :see_otherend++ def update+ call = Projects::UpdateService+ .new(model: @project, user: current_user)+ .call(permitted_params.project)++ @project = call.result++ if call.success?+ flash[:notice] = I18n.t(:notice_successful_update)+ redirect_to project_settings_general_path(@project)+ else+ render action: :show, status: :unprocessable_entity+ end+ endenddiff --git a/app/forms/projects/settings/description_form.rb b/app/forms/projects/settings/description_form.rbnew file mode 100644index 00000000000..f9e5e85de8f--- /dev/null+++ b/app/forms/projects/settings/description_form.rb@@ -0,0 +1,45 @@+# 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.+#+++module Projects+ module Settings+ class DescriptionForm < ApplicationForm+ form do |f|+ f.rich_text_area(+ name: :description,+ label: attribute_name(:description),+ rich_text_options: {+ showAttachments: false,+ data: { qa_field_name: "description" }+ }+ )+ end+ end+ end+enddiff --git a/app/forms/projects/settings/name_form.rb b/app/forms/projects/settings/name_form.rbnew file mode 100644index 00000000000..21f20303af7--- /dev/null+++ b/app/forms/projects/settings/name_form.rb@@ -0,0 +1,38 @@+# 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.+#+++module Projects+ module Settings+ class NameForm < ApplicationForm+ form do |f|+ f.text_field name: :name, label: attribute_name(:name), required: true+ end+ end+ end+enddiff --git a/app/forms/projects/settings/relations_form.rb b/app/forms/projects/settings/relations_form.rbnew file mode 100644index 00000000000..9de688fb557--- /dev/null+++ b/app/forms/projects/settings/relations_form.rb@@ -0,0 +1,48 @@+# 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.+#+++module Projects+ module Settings+ class RelationsForm < ApplicationForm+ form do |f|+ f.project_autocompleter(+ name: :parent_id,+ label: attribute_name(:parent_id),+ autocomplete_options: {+ focusDirectly: false,+ dropdownPosition: "bottom",+ url: ::API::V3::Utilities::PathHelper::ApiV3Path.projects_available_parents + "?of=#{model.id}",+ filters: [],+ data: { qa_field_name: "parent" }+ }+ )+ end+ end+ end+enddiff --git a/app/forms/projects/settings/status_form.rb b/app/forms/projects/settings/status_form.rbnew file mode 100644index 00000000000..6d4a8f662f7--- /dev/null+++ b/app/forms/projects/settings/status_form.rb@@ -0,0 +1,68 @@+# 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.+#+++module Projects+ module Settings+ class StatusForm < ApplicationForm+ include ProjectStatusHelper++ form do |f|+ f.autocompleter(+ name: :status_code,+ label: attribute_name(:status_code),+ include_blank: true,+ autocomplete_options: {+ decorated: true,+ clearable: false,+ focusDirectly: false,+ data: { qa_field_name: "status" }+ }+ ) do |select|+ [nil, *Project.status_codes.keys].map do |status_code|+ select.option(+ label: project_status_name(status_code),+ value: status_code,+ classes: "project-status--name #{project_status_css_class(status_code)}",+ selected: model.status_code == status_code+ )+ end+ end++ f.rich_text_area(+ name: :status_explanation,+ label: attribute_name(:status_explanation),+ rich_text_options: {+ showAttachments: false,+ data: { qa_field_name: "statusExplanation" }+ }+ )+ end+ end+ end+enddiff --git a/app/forms/projects/settings/submit.rb b/app/forms/projects/settings/submit.rbnew file mode 100644index 00000000000..f26ee05480a--- /dev/null+++ b/app/forms/projects/settings/submit.rb@@ -0,0 +1,45 @@+# 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.+#+++module Projects+ module Settings+ class Submit < ApplicationForm+ attr_reader :label++ form do |f|+ f.submit name: :submit, label:+ end++ def initialize(label: I18n.t("button_save"))+ super()+ @label = label+ end+ end+ end+enddiff --git a/app/views/projects/settings/general/show.html.erb b/app/views/projects/settings/general/show.html.erbindex 96de36125da..083736a348a 100644--- a/app/views/projects/settings/general/show.html.erb+++ b/app/views/projects/settings/general/show.html.erb@@ -48,4 +48,4 @@ See COPYRIGHT and LICENSE files for more details.end%>-<%= angular_component_tag "opce-project-settings" %>+<%= render Projects::Settings::General::ShowComponent.new(project: @project) %>diff --git a/config/initializers/permissions.rb b/config/initializers/permissions.rbindex d7404f59602..c12aa8382d7 100644--- a/config/initializers/permissions.rb+++ b/config/initializers/permissions.rb@@ -98,7 +98,7 @@ Rails.application.reloader.to_prepare domap.permission :edit_project,{- "projects/settings/general": %i[show toggle_public toggle_public_dialog],+ "projects/settings/general": %i[show update toggle_public toggle_public_dialog],"projects/settings/storage": %i[show],"projects/settings/work_packages": %i[show],"projects/settings/work_packages/activities": %i[show update],diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 7e0eb5c508c..a678de81210 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -384,6 +384,12 @@ en:heading: "Delete this project list?"text: "This action will not delete any project the list contains. Are you sure you want to delete this project list?"settings:+ header_details: Basic details+ header_status: Project status+ header_relations: Project relations+ button_update_details: Update details+ button_update_status: Update status+ button_update_parent_project: Update parent projectpublic_warning: >This project is public.Anyone who has access to this instance will be able to view and interact with this project depending on their role and associated permissions.diff --git a/config/routes.rb b/config/routes.rbindex bbaa9b6ed0e..7f73a26e0bf 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -252,7 +252,7 @@ Rails.application.routes.draw doresources :projects, except: %i[show edit create update] doscope module: "projects" donamespace "settings" do- resource :general, only: %i[show], controller: "general" do+ resource :general, only: %i[show update], controller: "general" doget :toggle_public_dialogpost :toggle_publicenddiff --git a/spec/components/projects/settings/general/show_component_spec.rb b/spec/components/projects/settings/general/show_component_spec.rbnew file mode 100644index 00000000000..ce171c8be2c--- /dev/null+++ b/spec/components/projects/settings/general/show_component_spec.rb@@ -0,0 +1,86 @@+# 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 "rails_helper"++RSpec.describe Projects::Settings::General::ShowComponent, type: :component do+ let(:project) { build_stubbed(:project) }++ def render_component(**params)+ render_inline(described_class.new(project:, **params))+ page+ end++ shared_examples "section with heading" do |heading|+ it "has section semantics" do+ expect(render_component).to have_section(heading)+ end++ it "renders a heading" do+ expect(render_component).to have_heading(heading)+ end++ it "renders a form" do+ render_component++ expect(page.find(:heading, heading)).to have_ancestor "form"+ end+ end++ describe "Basic details" do+ it_behaves_like "section with heading", "Basic details"++ it "renders fields" do+ expect(render_component).to have_field "Name", required: true+ expect(render_component).to have_element "opce-ckeditor-augmented-textarea",+ "data-textarea-selector": "\"#project_description\""+ end+ end++ describe "Project status" do+ it_behaves_like "section with heading", "Project status"++ it "renders fields" do+ expect(render_component).to have_element "opce-autocompleter",+ "data-input-name": "\"project[status_code]\""+ expect(render_component).to have_element "opce-ckeditor-augmented-textarea",+ "data-textarea-selector": "\"#project_status_explanation\""+ end+ end++ describe "Project relations" do+ it_behaves_like "section with heading", "Project relations"++ it "renders field" do+ expect(render_component).to have_element "opce-project-autocompleter",+ "data-input-name": "\"project[parent_id]\""+ end+ end+enddiff --git a/spec/controllers/projects/settings/general_controller_spec.rb b/spec/controllers/projects/settings/general_controller_spec.rbnew file mode 100644index 00000000000..b3255961944--- /dev/null+++ b/spec/controllers/projects/settings/general_controller_spec.rb@@ -0,0 +1,86 @@+# 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 Projects::Settings::GeneralController do+ shared_let(:user) { create(:admin) }+ current_user { user }++ before do+ allow(controller).to receive(:set_localization)+ end++ describe "PATCH #update" do+ let(:project) { build_stubbed(:project) }++ before do+ allow(Project)+ .to receive(:find)+ .with(project.identifier)+ .and_return(project)++ update_service = instance_double(Projects::UpdateService, call: service_result)++ allow(Projects::UpdateService)+ .to receive(:new)+ .with(user:, model: project)+ .and_return(update_service)+ end++ context "when service call succeeds" do+ let(:service_result) { ServiceResult.success(result: project) }++ it "redirects to show" do+ patch :update, params: { project_id: project.identifier, project: { name: "new name" } }++ expect(response).to redirect_to action: :show+ expect(flash[:notice]).to include I18n.t(:notice_successful_update)+ end+ end++ context "when service call fails" do+ let(:service_result) { ServiceResult.failure(result: project) }++ before do+ project.name = ""+ end++ it "renders show template with errors" do+ patch :update, params: { project_id: project.identifier, project: { name: "" } }++ expect(response).not_to be_successful+ expect(response).to have_http_status :unprocessable_entity+ expect(assigns(:project)).not_to be_valid+ expect(response).to render_template "projects/settings/general/show"+ end+ end+ end+enddiff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rbindex e39e3c9c069..da5802829f9 100644--- a/spec/features/projects/copy_spec.rb+++ b/spec/features/projects/copy_spec.rb@@ -520,11 +520,6 @@ RSpec.describe "Projects copy", :js,# has the parent of the original projectparent_field.expect_selected parent_project.name- # copies over the value of the custom field- # has the parent of the original project- editor = Components::WysiwygEditor.new "[data-qa-field-name='customField#{project_custom_field.id}']"- editor.expect_value "some text cf"-# has wp custom fields of original project activecopied_settings_wp_cf_page = Pages::Projects::Settings::WorkPackageCustomFields.new(copied_project)copied_settings_wp_cf_page.visit!diff --git a/spec/features/projects/edit_settings_spec.rb b/spec/features/projects/edit_settings_spec.rbindex c25a28dd10e..968328b09ed 100644--- a/spec/features/projects/edit_settings_spec.rb+++ b/spec/features/projects/edit_settings_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,8 +31,8 @@require "spec_helper"RSpec.describe "Projects", "editing settings", :js do- let(:name_field) { FormFields::InputFormField.new :name }- let(:parent_field) { FormFields::SelectFormField.new :parent }+ include_context "ng-select-autocomplete helpers"+let(:permissions) { %i(edit_project view_project_attributes edit_project_attributes) }current_user do@@ -38,7 +40,7 @@ RSpec.describe "Projects", "editing settings", :js doendshared_let(:project) do- create(:project, name: "Foo project", identifier: "foo-project")+ create(:project, :with_status, name: "Foo project", identifier: "foo-project")endit "hides the field whose functionality is presented otherwise" do@@ -78,34 +80,123 @@ RSpec.describe "Projects", "editing settings", :js doendend- context "with a user not allowed to see the parent project" do- include_context "ng-select-autocomplete helpers"+ describe "editing basic details" do+ before do+ Pages::Projects::Settings::General.new(project).visit!+ end++ it "updates the basic details" do+ within_section "Basic details" do+ fill_in "Name", with: "Bar project"+ fill_in_rich_text "Description", with: "a long and verbose project description."++ click_on "Update details"+ end++ expect_and_dismiss_flash type: :success, message: "Successful update."++ within_section "Basic details" do+ expect(page).to have_field "Name", with: "Bar project"+ expect(page).to have_selector :rich_text, "Description", text: "a long and verbose project description."+ end+ end++ it "displays validation error on invalid input" do+ within_section "Basic details" do+ fill_in "Name", with: ""+ click_on "Update details"++ expect(page).to have_field "Name", with: "", validation_error: "Name can't be blank."++ fill_in "Name", with: "A" * 256+ click_on "Update details"++ expect(page).to have_field "Name", with: "A" * 256, validation_error: "Name is too long (maximum is 255 characters)."+ end+ end+ end++ describe "editing project status" do+ let(:status_field) { FormFields::SelectFormField.new :status }++ before do+ Pages::Projects::Settings::General.new(project).visit!+ end++ it "updates the project status and description" do+ within_section "Project status" do+ status_field.select_option "At risk"+ fill_in_rich_text "Project status description", with: "Light-years behind 🥺"++ click_on "Update status"+ end++ expect_and_dismiss_flash type: :success, message: "Successful update."++ within_section "Project status" do+ status_field.expect_selected "AT RISK"+ expect(page).to have_selector :rich_text, "Project status description", text: "Light-years behind 🥺"+ end+ end++ it "unsets the project status" do+ within_section "Project status" do+ status_field.select_option "Not set"++ click_on "Update status"+ end- let(:parent_project) { create(:project) }- let(:parent_field) { FormFields::SelectFormField.new "parent" }+ expect_and_dismiss_flash type: :success, message: "Successful update."++ within_section "Project status" do+ status_field.expect_selected "NOT SET"+ end+ end+ end++ describe "editing project relations" do+ let(:parent_field) { FormFields::SelectFormField.new :parent }+ let(:parent_project) { create(:project, name: "New parent project") }before doproject.update_attribute(:parent, parent_project)end- it "can update the project without destroying the relation to the parent" do- visit project_settings_general_path(project.id)+ context "with a user allowed to see parent project" do+ current_user { create(:user, member_with_permissions: { project => permissions, parent_project => permissions }) }- fill_in "Name", with: "New project name"+ it "updates the parent project" do+ Pages::Projects::Settings::General.new(project).visit!- parent_field.expect_selected I18n.t(:"api_v3.undisclosed.parent")+ within_section "Project relations" do+ parent_field.expect_selected "New parent project"+ click_on "Update parent project"+ end- click_on "Save"+ expect_and_dismiss_flash type: :success, message: "Successful update."- expect(page).to have_content "Successful update."+ within_section "Project relations" do+ parent_field.expect_selected "New parent project"+ end+ end+ end++ context "with a user not allowed to see the parent project" do+ it "can update the project without destroying the relation to the parent" do+ pending "need to be able to override autocompleter model"++ Pages::Projects::Settings::General.new(project).visit!- project.reload+ within_section "Project relations" do+ parent_field.expect_selected I18n.t(:"api_v3.undisclosed.parent")+ click_on "Update parent project"+ end- expect(project.name)- .to eql "New project name"+ expect_and_dismiss_flash type: :success, message: "Successful update."- expect(project.parent)- .to eql parent_project+ project.reload+ expect(project.parent).to eq parent_project+ endendendenddiff --git a/spec/features/projects/project_status_administration_spec.rb b/spec/features/projects/project_status_administration_spec.rbindex f3f5c920be0..efae670b9d7 100644--- a/spec/features/projects/project_status_administration_spec.rb+++ b/spec/features/projects/project_status_administration_spec.rb@@ -81,7 +81,7 @@ RSpec.describe "Projects status administration", :js dostatus_field.select_option "Off track"status_description.set_markdown "Oh no"- click_button "Save"+ click_button "Update status"status_field.expect_selected "OFF TRACK"status_description.expect_value "Oh no"diff --git a/spec/forms/projects/settings/description_form_spec.rb b/spec/forms/projects/settings/description_form_spec.rbnew file mode 100644index 00000000000..82616182078--- /dev/null+++ b/spec/forms/projects/settings/description_form_spec.rb@@ -0,0 +1,44 @@+# 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 Projects::Settings::DescriptionForm, type: :forms do+ include_context "with rendered form"++ let(:model) { build_stubbed(:project, description: "example description") }++ it "renders field" do+ expect(page).to have_field "Description", with: "example description", visible: :hidden+ expect(page).to have_element "opce-ckeditor-augmented-textarea",+ "data-textarea-selector": "\"#project_description\""+ expect(page).to have_element "opce-ckeditor-augmented-textarea", "data-qa-field-name": "description"+ end+enddiff --git a/spec/forms/projects/settings/name_form_spec.rb b/spec/forms/projects/settings/name_form_spec.rbnew file mode 100644index 00000000000..a101c8f9839--- /dev/null+++ b/spec/forms/projects/settings/name_form_spec.rb@@ -0,0 +1,41 @@+# 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 Projects::Settings::NameForm, type: :forms do+ include_context "with rendered form"++ let(:model) { build_stubbed(:project, name: "example project") }++ it "renders field" do+ expect(page).to have_field "Name", with: "example project", required: true+ end+enddiff --git a/spec/forms/projects/settings/relations_form_spec.rb b/spec/forms/projects/settings/relations_form_spec.rbnew file mode 100644index 00000000000..4b7c0ca3413--- /dev/null+++ b/spec/forms/projects/settings/relations_form_spec.rb@@ -0,0 +1,42 @@+# 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 Projects::Settings::RelationsForm, type: :forms do+ include_context "with rendered form"++ let(:model) { build_stubbed(:project) }++ it "renders field" do+ expect(page).to have_element "opce-project-autocompleter", "data-input-name": "\"project[parent_id]\""+ expect(page).to have_element "opce-project-autocompleter", "data-qa-field-name": "parent"+ end+enddiff --git a/spec/forms/projects/settings/status_form_spec.rb b/spec/forms/projects/settings/status_form_spec.rbnew file mode 100644index 00000000000..7898143c94f--- /dev/null+++ b/spec/forms/projects/settings/status_form_spec.rb@@ -0,0 +1,55 @@+# 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 Projects::Settings::StatusForm, type: :forms do+ include_context "with rendered form"++ let(:model) { build_stubbed(:project, status_explanation: "example status info") }++ it "renders status field" do+ expect(page).to have_element "opce-autocompleter", "data-input-name": "\"project[status_code]\""+ expect(page).to have_element "opce-autocompleter", "data-qa-field-name": "status" do |elem|+ expect(elem["data-items"]).to have_json_size(7)+ expect(elem["data-items"]).to include_json(%{{"name":"Not set","classes":"project-status--name -not-set"}})+ expect(elem["data-items"]).to include_json(+ %{{"id":"on_track","name":"On track","classes":"project-status--name -on-track"}}+ ).including(:id)+ end+ end++ it "renders status description field" do+ expect(page).to have_field "Project status description", with: "example status info", visible: :hidden+ expect(page).to have_element "opce-ckeditor-augmented-textarea",+ "data-textarea-selector": "\"#project_status_explanation\""+ expect(page).to have_element "opce-ckeditor-augmented-textarea", "data-qa-field-name": "statusExplanation"+ end+enddiff --git a/spec/forms/projects/settings/submit_spec.rb b/spec/forms/projects/settings/submit_spec.rbnew file mode 100644index 00000000000..4dd83cc58e4--- /dev/null+++ b/spec/forms/projects/settings/submit_spec.rb@@ -0,0 +1,41 @@+# 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 ChiliProjeceam+#+# 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 Projects::Settings::Submit, type: :forms do+ include_context "with rendered form"++ let(:model) { build_stubbed(:project) }++ it "renders field" do+ expect(page).to have_button "Save"+ end+enddiff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rbindex 88880864c68..74f3b57206c 100644--- a/spec/routing/project_settings_routing_spec.rb+++ b/spec/routing/project_settings_routing_spec.rb@@ -37,6 +37,13 @@ RSpec.describe Projects::SettingsController do)end+ it do+ expect(patch("/projects/123/settings/general"))+ .to route_to(+ controller: "projects/settings/general", action: "update", project_id: "123"+ )+ end+it doexpect(get("/projects/123/settings/modules")).to route_to(diff --git a/spec/support/forms/rendered_form.rb b/spec/support/forms/rendered_form.rbnew file mode 100644index 00000000000..c063edeb921--- /dev/null+++ b/spec/support/forms/rendered_form.rb@@ -0,0 +1,40 @@+# 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.+#+++RSpec.shared_context "with rendered form" do+ include ViewComponent::TestHelpers++ before do+ render_in_view_context(model, described_class) do |model, described_class|+ primer_form_with(url: "/foo", model:) do |f|+ render(described_class.new(f))+ end+ end+ end+end