Skip to content

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

split project setting spec support pages

ulferts866b739cff34
diff --git a/modules/backlogs/spec/features/resolved_status_spec.rb b/modules/backlogs/spec/features/resolved_status_spec.rb
index ce72102dc5e..3e094570a96 100644
--- a/modules/backlogs/spec/features/resolved_status_spec.rb
+++ b/modules/backlogs/spec/features/resolved_status_spec.rb
@@ -27,6 +27,7 @@
#++
require "spec_helper"
+require_relative "../support/pages/projects/settings/backlogs"
RSpec.describe "Resolved status" do
let!(:project) do
@@ -42,14 +43,14 @@ RSpec.describe "Resolved status" do
create(:user,
member_with_roles: { project => role })
end
- let(:settings_page) { Pages::Projects::Settings.new(project) }
+ let(:settings_page) { Pages::Projects::Settings::Backlogs.new(project) }
before do
login_as current_user
end
it "allows setting a status as done although it is not closed" do
- settings_page.visit_tab! "backlogs"
+ settings_page.visit!
check status.name
click_button "Save"
diff --git a/modules/backlogs/spec/support/pages/projects/settings/backlogs.rb b/modules/backlogs/spec/support/pages/projects/settings/backlogs.rb
new file mode 100644
index 00000000000..86f573bd766
--- /dev/null
+++ b/modules/backlogs/spec/support/pages/projects/settings/backlogs.rb
@@ -0,0 +1,49 @@
+# -- 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 Backlogs < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ self.project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/backlogs"
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/custom_fields/activate_in_project_spec.rb b/spec/features/custom_fields/activate_in_project_spec.rb
index 796b0eef3b8..ea6fc23de27 100644
--- a/spec/features/custom_fields/activate_in_project_spec.rb
+++ b/spec/features/custom_fields/activate_in_project_spec.rb
@@ -35,13 +35,13 @@ RSpec.describe "custom fields", :js, :with_cuprite do
let(:for_all_cf) { create(:list_wp_custom_field, is_for_all: true) }
let(:project_specific_cf) { create(:integer_wp_custom_field) }
let(:work_package) do
- wp = build(:work_package).tap do |wp|
+ build(:work_package) do |wp|
wp.type.custom_fields = [for_all_cf, project_specific_cf]
wp.save!
end
end
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
- let(:project_settings_page) { Pages::Projects::Settings.new(work_package.project) }
+ let(:project_settings_page) { Pages::Projects::Settings::WorkPackageCustomFields.new(work_package.project) }
before do
login_as user
@@ -53,9 +53,9 @@ RSpec.describe "custom fields", :js, :with_cuprite do
wp_page.expect_attributes "customField#{for_all_cf.id}": "-"
wp_page.expect_no_attribute "customField#{project_specific_cf.id}"
- project_settings_page.visit_tab!("custom_fields")
+ project_settings_page.visit!
- project_settings_page.activate_wp_custom_field(project_specific_cf)
+ project_settings_page.activate(project_specific_cf)
project_settings_page.save!
diff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rb
index 18253e9452a..03be48add18 100644
--- a/spec/features/projects/copy_spec.rb
+++ b/spec/features/projects/copy_spec.rb
@@ -164,8 +164,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
context "with correct project custom field activations" do
before do
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
@@ -229,8 +228,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
optional_project_custom_field_with_default.id
)
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
@@ -302,8 +300,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
end
before do
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
@@ -373,8 +370,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
end
it "copies the project attributes" do
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
@@ -406,8 +402,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
end
it "copies projects and the associated objects" do
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
@@ -433,8 +428,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
# Will redirect to the new project automatically once the copy process is done
expect(page).to have_current_path(Regexp.new("#{project_path(copied_project)}/?"))
- copied_settings_page = Pages::Projects::Settings.new(copied_project)
- copied_settings_page.visit!
+ Pages::Projects::Settings::General.new(copied_project).visit!
# has the parent of the original project
parent_field.expect_selected parent_project.name
@@ -445,19 +439,21 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
editor.expect_value "some text cf"
# has wp custom fields of original project active
- copied_settings_page.visit_tab!("custom_fields")
+ copied_settings_wp_cf_page = Pages::Projects::Settings::WorkPackageCustomFields.new(copied_project)
+ copied_settings_wp_cf_page.visit!
- copied_settings_page.expect_wp_custom_field_active(wp_custom_field)
- copied_settings_page.expect_wp_custom_field_inactive(inactive_wp_custom_field)
+ copied_settings_wp_cf_page.expect_active(wp_custom_field)
+ copied_settings_wp_cf_page.expect_inactive(inactive_wp_custom_field)
# has types of original project active
- copied_settings_page.visit_tab!("types")
+ copied_settings_type_page = Pages::Projects::Settings::Type.new(copied_project)
+ copied_settings_type_page.visit!
active_types.each do |type|
- copied_settings_page.expect_type_active(type)
+ copied_settings_type_page.expect_type_active(type)
end
- copied_settings_page.expect_type_inactive(inactive_type)
+ copied_settings_type_page.expect_type_inactive(inactive_type)
# Expect wiki was copied
expect(copied_project.wiki.pages.count).to eq(project.wiki.pages.count)
@@ -540,8 +536,7 @@ RSpec.describe "Projects copy", :js, :with_cuprite,
wp_table.expect_work_package_listed *order
wp_table.expect_work_package_order *order
- original_settings_page = Pages::Projects::Settings.new(project)
- original_settings_page.visit!
+ Pages::Projects::Settings::General.new(project).visit!
find(".toolbar a", text: "Copy").click
diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb
index 045ab880ed6..69ea63ff35b 100644
--- a/spec/features/projects/modules_spec.rb
+++ b/spec/features/projects/modules_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "Projects module administration" do
end
let(:permissions) { %i(edit_project select_project_modules view_work_packages) }
- let(:settings_page) { Pages::Projects::Settings.new(project) }
+ let(:modules_settings_page) { Pages::Projects::Settings::Modules.new(project) }
current_user do
create(:user, member_with_permissions: { project => permissions })
@@ -43,7 +43,7 @@ RSpec.describe "Projects module administration" do
it "allows adding and removing modules" do
project_work_packages_menu_link_selector = '//ul[contains(@class, "menu_root")]//span[text()="Work packages"]'
- settings_page.visit_tab!("modules")
+ modules_settings_page.visit!
expect(page).to have_unchecked_field "Activity"
expect(page).to have_unchecked_field "Calendar"
@@ -95,10 +95,11 @@ RSpec.describe "Projects module administration" do
create(:user,
member_with_permissions: { project => %i(edit_project) })
end
+ let(:general_settings_page) { Pages::Projects::Settings::General.new(project) }
before do
login_as user_without_permission
- settings_page.visit_tab!("general")
+ general_settings_page.visit!
end
it "I can't see the modules menu item" do
diff --git a/spec/features/types/activate_in_project_spec.rb b/spec/features/types/activate_in_project_spec.rb
index 4f0f1e67042..68a484b591c 100644
--- a/spec/features/types/activate_in_project_spec.rb
+++ b/spec/features/types/activate_in_project_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "types", :js, :with_cuprite do
let!(:active_type) { create(:type) }
let!(:type) { create(:type) }
let!(:project) { create(:project, types: [active_type]) }
- let(:project_settings_page) { Pages::Projects::Settings.new(project) }
+ let(:project_type_settings_page) { Pages::Projects::Settings::Type.new(project) }
let(:work_packages_page) { Pages::WorkPackagesTable.new(project) }
before do
@@ -51,7 +51,7 @@ RSpec.describe "types", :js, :with_cuprite do
work_packages_page.expect_type_available_for_create(active_type)
work_packages_page.expect_type_not_available_for_create(type)
- project_settings_page.visit_tab!("types")
+ project_type_settings_page.visit!
expect(page)
.to have_unchecked_field(type.name)
@@ -62,9 +62,9 @@ RSpec.describe "types", :js, :with_cuprite do
check(type.name)
uncheck(active_type.name)
- project_settings_page.save!
+ project_type_settings_page.save!
- project_settings_page.expect_and_dismiss_flash(message: "Successful update.")
+ project_type_settings_page.expect_and_dismiss_flash(message: "Successful update.")
expect(page)
.to have_checked_field(type.name)
diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb
index 0457df023ee..0376c310c07 100644
--- a/spec/features/types/form_configuration_spec.rb
+++ b/spec/features/types/form_configuration_spec.rb
@@ -274,7 +274,7 @@ RSpec.describe "form configuration", :js do
end
describe "custom fields" do
- let(:project_settings_page) { Pages::Projects::Settings.new(project) }
+ let(:project_cf_settings_page) { Pages::Projects::Settings::WorkPackageCustomFields.new(project) }
let(:custom_fields) { [custom_field] }
let(:custom_field) { create(:issue_custom_field, :integer, name: "MyNumber") }
@@ -315,7 +315,7 @@ RSpec.describe "form configuration", :js do
wp_page.expect_attribute_hidden(cf_identifier_api)
# Enable in project, should then be visible
- project_settings_page.visit_tab!("custom_fields")
+ project_cf_settings_page.visit!
expect(page).to have_css(".custom-field-#{custom_field.id} td", text: "MyNumber")
expect(page).to have_css(".custom-field-#{custom_field.id} td", text: type.name)
@@ -356,7 +356,7 @@ RSpec.describe "form configuration", :js do
end
# Ensure CF is checked
- project_settings_page.visit_tab!("custom_fields")
+ project_cf_settings_page.visit!
expect(page).to have_css(".custom-field-#{custom_field.id} td", text: "MyNumber")
expect(page).to have_css(".custom-field-#{custom_field.id} td", text: type.name)
expect(page).to have_css("#project_work_package_custom_field_ids_#{custom_field.id}[checked]")
diff --git a/spec/support/pages/projects/settings.rb b/spec/support/pages/projects/settings.rb
deleted file mode 100644
index 7b698f23e05..00000000000
--- a/spec/support/pages/projects/settings.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-#-- 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 "support/pages/page"
-
-module Pages
- module Projects
- class Settings < Pages::Page
- attr_accessor :project
-
- def initialize(project)
- super()
-
- self.project = project
- end
-
- def visit_tab!(name)
- visit "/projects/#{project.identifier}/settings/#{name}"
- end
-
- def expect_type_active(type)
- expect_type(type, true)
- end
-
- def expect_type_inactive(type)
- expect_type(type, false)
- end
-
- def expect_type(type, active = true)
- expect(page)
- .to have_field("project_planning_element_type_ids_#{type.id}", checked: active)
- end
-
- def expect_wp_custom_field_active(custom_field)
- expect_wp_custom_field(custom_field, true)
- end
-
- def expect_wp_custom_field_inactive(custom_field)
- expect_wp_custom_field(custom_field, false)
- end
-
- def activate_wp_custom_field(custom_field)
- check custom_field.name
- end
-
- def save!
- click_button "Save"
- end
-
- def expect_wp_custom_field(custom_field, active = true)
- expect(page)
- .to have_field(custom_field.name, checked: active)
- end
-
- def fieldset_label
- find "fieldset#project_issue_custom_fields label"
- end
-
- private
-
- def path
- project_settings_general_path(project)
- end
- end
- end
-end
diff --git a/spec/support/pages/projects/settings/general.rb b/spec/support/pages/projects/settings/general.rb
new file mode 100644
index 00000000000..eb515944db4
--- /dev/null
+++ b/spec/support/pages/projects/settings/general.rb
@@ -0,0 +1,49 @@
+# -- 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 General < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ self.project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/general"
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/pages/projects/settings/life_cycle.rb b/spec/support/pages/projects/settings/life_cycle.rb
index 07ddb2544d5..7a4a2215d6b 100644
--- a/spec/support/pages/projects/settings/life_cycle.rb
+++ b/spec/support/pages/projects/settings/life_cycle.rb
@@ -30,8 +30,7 @@ require "support/pages/page"
module Pages
module Projects
- # TODO: Ideally this would be turned into a module but it would require having the other settings pages being split up.
- class Settings
+ module Settings
class LifeCycle < Pages::Page
attr_accessor :project
diff --git a/spec/support/pages/projects/settings/modules.rb b/spec/support/pages/projects/settings/modules.rb
new file mode 100644
index 00000000000..f97681f7901
--- /dev/null
+++ b/spec/support/pages/projects/settings/modules.rb
@@ -0,0 +1,49 @@
+# -- 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 Modules < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ self.project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/modules"
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/pages/projects/settings/type.rb b/spec/support/pages/projects/settings/type.rb
new file mode 100644
index 00000000000..de34fe8566a
--- /dev/null
+++ b/spec/support/pages/projects/settings/type.rb
@@ -0,0 +1,66 @@
+# -- 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 Type < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ self.project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/types"
+ end
+
+ def expect_type_active(type)
+ expect_type(type, active: true)
+ end
+
+ def expect_type_inactive(type)
+ expect_type(type, active: false)
+ end
+
+ def expect_type(type, active: true)
+ expect(page)
+ .to have_field("project_planning_element_type_ids_#{type.id}", checked: active)
+ end
+
+ def save!
+ click_link_or_button "Save"
+ end
+ end
+ end
+ end
+end
diff --git a/spec/support/pages/projects/settings/work_package_custom_fields.rb b/spec/support/pages/projects/settings/work_package_custom_fields.rb
new file mode 100644
index 00000000000..4b80d0cfe0b
--- /dev/null
+++ b/spec/support/pages/projects/settings/work_package_custom_fields.rb
@@ -0,0 +1,70 @@
+# -- 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 WorkPackageCustomFields < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ super()
+
+ self.project = project
+ end
+
+ def path
+ "/projects/#{project.identifier}/settings/custom_fields"
+ end
+
+ def expect_active(custom_field)
+ expect_field(custom_field, active: true)
+ end
+
+ def expect_inactive(custom_field)
+ expect_field(custom_field, active: false)
+ end
+
+ def activate(custom_field)
+ check custom_field.name
+ end
+
+ def expect_field(custom_field, active: true)
+ expect(page)
+ .to have_field(custom_field.name, checked: active)
+ end
+
+ def save!
+ click_link_or_button "Save"
+ end
+ end
+ end
+ end
+end