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

fixed and enriched project settings page specs

Jonas Jabari6d8fd7fb36b6
diff --git a/spec/features/projects/edit_settings_spec.rb b/spec/features/projects/edit_settings_spec.rb
index f6be75da0e2..202b6d8b6c8 100644
--- a/spec/features/projects/edit_settings_spec.rb
+++ b/spec/features/projects/edit_settings_spec.rb
@@ -80,15 +80,15 @@ RSpec.describe 'Projects', 'editing settings', :js, :with_cuprite do
context 'with optional and required custom fields' do
let!(:optional_custom_field) do
- create(:custom_field, name: 'Optional Foo',
- type: ProjectCustomField,
- is_for_all: true)
+ create(:project_custom_field, name: 'Optional Foo',
+ is_for_all: true,
+ projects: [project])
end
let!(:required_custom_field) do
- create(:custom_field, name: 'Required Foo',
- type: ProjectCustomField,
- is_for_all: true,
- is_required: true)
+ 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
@@ -106,10 +106,10 @@ RSpec.describe 'Projects', 'editing settings', :js, :with_cuprite do
let!(:required_custom_field) do
create(:string_project_custom_field,
name: 'Foo',
- type: ProjectCustomField,
min_length: 1,
max_length: 2,
- is_for_all: true)
+ is_for_all: true,
+ projects: [project])
end
let(:foo_field) { FormFields::InputFormField.new required_custom_field }
@@ -133,7 +133,7 @@ RSpec.describe 'Projects', 'editing settings', :js, :with_cuprite do
context 'with a multi-select custom field' do
include_context 'ng-select-autocomplete helpers'
- let!(:list_custom_field) { create(:list_project_custom_field, name: 'List CF', multi_value: true) }
+ 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
@@ -154,7 +154,7 @@ RSpec.describe 'Projects', 'editing settings', :js, :with_cuprite do
end
context 'with a date custom field' do
- let!(:date_custom_field) { create(:date_project_custom_field, name: 'Date') }
+ 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
@@ -204,4 +204,23 @@ RSpec.describe 'Projects', 'editing settings', :js, :with_cuprite 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
end