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

Remove custom field specs from Edit Settings feature

Alexander Brandon Coles6821b5f7bef1
diff --git a/spec/features/projects/edit_settings_spec.rb b/spec/features/projects/edit_settings_spec.rb
index f0d5f7c142c..c25a28dd10e 100644
--- a/spec/features/projects/edit_settings_spec.rb
+++ b/spec/features/projects/edit_settings_spec.rb
@@ -78,177 +78,6 @@ RSpec.describe "Projects", "editing settings", :js do
end
end
- context "with optional and required custom fields" do
- let!(:optional_custom_field) do
- create(:project_custom_field, name: "Optional Foo",
- is_for_all: true,
- projects: [project])
- end
- let!(:required_custom_field) do
- create(:project_custom_field, name: "Required Foo",
- is_for_all: true,
- is_required: true,
- projects: [project])
- end
-
- it "shows optional and required custom fields for edit without a separation" do
- project.custom_field_values.last.value = "FOO"
- project.save!
-
- visit project_settings_general_path(project.id)
-
- expect(page).to have_text "Optional Foo"
- expect(page).to have_text "Required Foo"
- end
- end
-
- context "with a length internal custom field" do
- let!(:required_custom_field) do
- create(:string_project_custom_field,
- name: "Foo",
- min_length: 1,
- max_length: 2,
- is_for_all: true,
- projects: [project])
- end
- let(:foo_field) { FormFields::InputFormField.new required_custom_field }
-
- it "shows the errors of that field when saving (Regression #33766)" do
- visit project_settings_general_path(project.id)
-
- expect(page).to have_content "Foo"
-
- # Enter something too long
- foo_field.set_value "1234"
-
- # It should cut of that remaining value
- foo_field.expect_value "12"
-
- click_button "Save"
-
- expect(page).to have_text "Successful update."
- end
- end
-
- context "with a multi-select list custom field" do
- include_context "ng-select-autocomplete helpers"
-
- let!(:list_custom_field) { create(:list_project_custom_field, name: "List CF", multi_value: true, projects: [project]) }
- let(:form_field) { FormFields::SelectFormField.new list_custom_field }
-
- it "can select multiple values" do
- visit project_settings_general_path(project.id)
-
- form_field.select_option "A", "B"
-
- click_on "Save"
-
- expect(page).to have_content "Successful update."
-
- form_field.expect_selected "A", "B"
-
- cvs = project.reload.custom_value_for(list_custom_field)
- expect(cvs.count).to eq 2
- expect(cvs.map(&:typed_value)).to contain_exactly "A", "B"
- end
- end
-
- context "with a multi-select user custom field" do
- include_context "ng-select-autocomplete helpers"
-
- let!(:list_custom_field) { create(:user_project_custom_field, name: "List CF", multi_value: true, projects: [project]) }
- let(:dummy_role) { create(:project_role) }
- let!(:users) do
- [
- create(:user, firstname: "First", lastname: "User", member_with_roles: { project => [dummy_role] }),
- create(:user, firstname: "Second", lastname: "User", member_with_roles: { project => [dummy_role] }),
- create(:user, firstname: "Third", lastname: "User", member_with_roles: { project => [dummy_role] })
- ]
- end
- let(:form_field) { FormFields::SelectFormField.new list_custom_field }
-
- it "can select multiple values" do
- visit project_settings_general_path(project.id)
-
- form_field.select_option users.first.name, users.last.name
-
- click_on "Save"
-
- expect(page).to have_content "Successful update."
-
- refresh
-
- expect(page).to have_no_content "Successful update."
-
- form_field.expect_selected users.first.name, users.last.name
- end
- end
-
- context "with a version custom field" do
- include_context "ng-select-autocomplete helpers"
-
- shared_let(:public_project) do
- create(:project, name: "Public Pr", identifier: "public-pr", public: true)
- end
-
- let!(:versions) do
- [
- create(:version, project:, name: "Ringbo 1.0", sharing: "system"),
- create(:version, project: public_project, name: "Ringbo 2.0", sharing: "system")
- ]
- end
-
- let!(:version_custom_field) do
- create(:version_project_custom_field,
- name: "List CF",
- multi_value: true,
- projects: [project])
- end
-
- let(:form_field) { FormFields::SelectFormField.new version_custom_field }
-
- it "can select multiple values" do
- visit project_settings_general_path(project.id)
-
- # expect the versions are grouped by the project name
- form_field.expect_option(versions.first.name, grouping: project.name)
- form_field.expect_option(versions.last.name, grouping: public_project.name)
-
- form_field.select_option(versions.first.name, versions.last.name)
-
- click_on "Save"
-
- expect(page).to have_content "Successful update."
-
- refresh
-
- expect(page).to have_no_content "Successful update."
-
- form_field.expect_selected versions.first.name, versions.last.name
- end
- end
-
- context "with a date custom field" do
- let!(:date_custom_field) { create(:date_project_custom_field, name: "Date", projects: [project]) }
- let(:form_field) { FormFields::InputFormField.new date_custom_field }
-
- it "can save and remove the date (Regression #37459)" do
- visit project_settings_general_path(project.id)
-
- form_field.set_value "2021-05-26"
- form_field.send_keys :enter
-
- click_on "Save"
-
- expect(page).to have_content "Successful update."
-
- form_field.expect_value "2021-05-26"
-
- cv = project.reload.custom_value_for(date_custom_field)
- expect(cv.typed_value).to eq "2021-05-26".to_date
- end
- end
-
context "with a user not allowed to see the parent project" do
include_context "ng-select-autocomplete helpers"
@@ -279,54 +108,4 @@ RSpec.describe "Projects", "editing settings", :js do
.to eql parent_project
end
end
-
- context "with correct scoping of project custom fields" do
- let!(:optional_custom_field_activated_in_project) do
- create(:project_custom_field, name: "Optional Foo",
- is_for_all: true,
- projects: [project])
- end
- let!(:optional_custom_field_not_activated_in_project) do
- create(:project_custom_field, name: "Optional Bar",
- is_for_all: true)
- end
-
- it "shows only the custom fields that are activated in the project" do
- visit project_settings_general_path(project.id)
-
- expect(page).to have_text "Optional Foo"
- expect(page).to have_no_text "Optional Bar"
- end
- end
-
- describe "permissions" do
- context "with edit_project permission only" do
- let!(:custom_field) { create(:string_project_custom_field, projects: [project]) }
- let(:foo_field) { FormFields::InputFormField.new custom_field }
- let(:role) { Role.first }
-
- it "does not show custom fields" do
- role.update(permissions: permissions - %i(edit_project_attributes))
-
- visit project_settings_general_path(project)
- expect(page).to have_no_content(custom_field.name)
- end
-
- it "does not allow saving custom fields" do
- visit project_settings_general_path(project.id)
-
- expect(page).to have_content(custom_field.name)
-
- # Remove edit_project_attributes after loading the form
- role.update(permissions: permissions - %i(edit_project_attributes))
- current_user.reload
-
- foo_field.set_value "1234"
-
- click_on "Save"
- expect(page)
- .to have_text "#{custom_field.name} was attempted to be written but is not writable."
- end
- end
- end
end