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

Spec adjustments as suggested by @dombesz

Jonas Jabari4913e4d9714b
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
index b95abbc8d32..0d4b5f53637 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/inputs_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require_relative '../shared_context'
+require "spec_helper"
+require_relative "../shared_context"
-RSpec.describe 'Edit project custom fields on project overview page', :js do
- include_context 'with seeded projects, members and project custom fields'
+RSpec.describe "Edit project custom fields on project overview page", :js do
+ include_context "with seeded projects, members and project custom fields"
let(:overview_page) { Pages::Projects::Show.new(project) }
@@ -39,13 +39,13 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
overview_page.visit_page
end
- describe 'with correct initialization and input behaviour' do
- describe 'with input fields' do
+ describe "with correct initialization and input behaviour" do
+ describe "with input fields" do
let(:section) { section_for_input_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a custom field checkbox' do
- it 'shows the correct value if given' do
+ shared_examples "a custom field checkbox" do
+ it "shows the correct value if given" do
overview_page.open_edit_dialog_for_section(section)
dialog.within_async_content(close_after_yield: true) do
@@ -57,7 +57,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'is unchecked if no value and no default value is given' do
+ it "is unchecked if no value and no default value is given" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -67,7 +67,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows default value if no value is given' do
+ it "shows default value if no value is given" do
custom_field.custom_values.destroy_all
custom_field.update!(default_value: true)
@@ -88,8 +88,8 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- shared_examples 'a custom field input' do
- it 'shows the correct value if given' do
+ shared_examples "a custom field input" do
+ it "shows the correct value if given" do
overview_page.open_edit_dialog_for_section(section)
dialog.within_async_content(close_after_yield: true) do
@@ -97,7 +97,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows a blank input if no value or default value is given' do
+ it "shows a blank input if no value or default value is given" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -107,7 +107,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows the default value if no value is given' do
+ it "shows the default value if no value is given" do
custom_field.custom_values.destroy_all
custom_field.update!(default_value:)
@@ -119,8 +119,8 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- shared_examples 'a rich text custom field input' do
- it 'shows the correct value if given' do
+ shared_examples "a rich text custom field input" do
+ it "shows the correct value if given" do
overview_page.open_edit_dialog_for_section(section)
dialog.within_async_content(close_after_yield: true) do
@@ -128,7 +128,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows a blank input if no value or default value is given' do
+ it "shows a blank input if no value or default value is given" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -138,7 +138,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows the default value if no value is given' do
+ it "shows the default value if no value is given" do
custom_field.custom_values.destroy_all
custom_field.update!(default_value:)
@@ -150,74 +150,72 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with boolean CF' do
+ describe "with boolean CF" do
let(:custom_field) { boolean_project_custom_field }
- let(:default_value) { false }
- let(:expected_blank_value) { false }
let(:expected_initial_value) { true }
- it_behaves_like 'a custom field checkbox'
+ it_behaves_like "a custom field checkbox"
end
- describe 'with string CF' do
+ describe "with string CF" do
let(:custom_field) { string_project_custom_field }
- let(:default_value) { 'Default value' }
- let(:expected_blank_value) { '' }
- let(:expected_initial_value) { 'Foo' }
+ let(:default_value) { "Default value" }
+ let(:expected_blank_value) { "" }
+ let(:expected_initial_value) { "Foo" }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with integer CF' do
+ describe "with integer CF" do
let(:custom_field) { integer_project_custom_field }
let(:default_value) { 789 }
- let(:expected_blank_value) { '' }
+ let(:expected_blank_value) { "" }
let(:expected_initial_value) { 123 }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with float CF' do
+ describe "with float CF" do
let(:custom_field) { float_project_custom_field }
let(:default_value) { 789.123 }
- let(:expected_blank_value) { '' }
+ let(:expected_blank_value) { "" }
let(:expected_initial_value) { 123.456 }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with date CF' do
+ describe "with date CF" do
let(:custom_field) { date_project_custom_field }
let(:default_value) { Date.new(2026, 1, 1) }
- let(:expected_blank_value) { '' }
+ let(:expected_blank_value) { "" }
let(:expected_initial_value) { Date.new(2024, 1, 1) }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with text CF' do
+ describe "with text CF" do
let(:custom_field) { text_project_custom_field }
let(:field) { FormFields::Primerized::EditorFormField.new(custom_field) }
- let(:default_value) { 'Default value' }
- let(:expected_blank_value) { '' }
+ let(:default_value) { "Default value" }
+ let(:expected_blank_value) { "" }
let(:expected_initial_value) { "Lorem\nipsum" } # TBD: why is the second newline missing?
- it_behaves_like 'a rich text custom field input'
+ it_behaves_like "a rich text custom field input"
end
end
- describe 'with single select fields' do
+ describe "with single select fields" do
let(:section) { section_for_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a autocomplete single select field' do
- it 'shows the correct value if given' do
+ shared_examples "a autocomplete single select field" do
+ it "shows the correct value if given" do
overview_page.open_edit_dialog_for_section(section)
field.expect_selected(expected_initial_value)
end
- it 'shows a blank input if no value or default value is given' do
+ it "shows a blank input if no value or default value is given" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -225,7 +223,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_blank
end
- it 'filters the list based on the input' do
+ it "filters the list based on the input" do
overview_page.open_edit_dialog_for_section(section)
field.search(second_option)
@@ -235,7 +233,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_no_option(third_option)
end
- it 'enables the user to select a single value from a list' do
+ it "enables the user to select a single value from a list" do
overview_page.open_edit_dialog_for_section(section)
field.search(second_option)
@@ -250,7 +248,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_not_selected(second_option)
end
- it 'clears the input if clicked on the clear button' do
+ it "clears the input if clicked on the clear button" do
overview_page.open_edit_dialog_for_section(section)
field.clear
@@ -259,7 +257,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with single select list CF' do
+ describe "with single select list CF" do
let(:custom_field) { list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -269,9 +267,9 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { custom_field.custom_options.second.value }
let(:third_option) { custom_field.custom_options.third.value }
- it_behaves_like 'a autocomplete single select field'
+ it_behaves_like "a autocomplete single select field"
- it 'shows the default value if no value is given' do
+ it "shows the default value if no value is given" do
custom_field.custom_values.destroy_all
custom_field.custom_options.first.update!(default_value: true)
@@ -282,7 +280,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with single version select list CF' do
+ describe "with single version select list CF" do
let(:custom_field) { version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -292,35 +290,35 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { second_version.name }
let(:third_option) { third_version.name }
- it_behaves_like 'a autocomplete single select field'
+ it_behaves_like "a autocomplete single select field"
- describe 'with correct version scoping' do
- context 'with a version on a different project' do
+ describe "with correct version scoping" do
+ context "with a version on a different project" do
let!(:version_in_other_project) do
- create(:version, name: 'Version 1 in other project', project: other_project)
+ create(:version, name: "Version 1 in other project", project: other_project)
end
- it 'shows only versions that are associated with this project' do
+ it "shows only versions that are associated with this project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Version 1')
+ field.search("Version 1")
field.expect_option(first_version.name)
field.expect_no_option(version_in_other_project.name)
end
end
- context 'with a closed version' do
- let!(:closed_version) { create(:version, name: 'Closed version', project:, status: 'closed') }
+ context "with a closed version" do
+ let!(:closed_version) { create(:version, name: "Closed version", project:, status: "closed") }
before do
custom_field.update(allow_non_open_versions:)
end
- context 'when non-open versions are not allowed' do
+ context "when non-open versions are not allowed" do
let(:allow_non_open_versions) { false }
- it 'does not shows closed version option' do
+ it "does not shows closed version option" do
overview_page.open_edit_dialog_for_section(section)
field.open_options
@@ -329,10 +327,10 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- context 'when non-open versions are allowed' do
+ context "when non-open versions are allowed" do
let(:allow_non_open_versions) { true }
- it 'shows closed version option' do
+ it "shows closed version option" do
overview_page.open_edit_dialog_for_section(section)
field.open_options
@@ -344,7 +342,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with single user select list CF' do
+ describe "with single user select list CF" do
let(:custom_field) { user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -354,62 +352,62 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { another_member_in_project.name }
let(:third_option) { one_more_member_in_project.name }
- it_behaves_like 'a autocomplete single select field'
+ it_behaves_like "a autocomplete single select field"
- describe 'with correct user scoping' do
+ describe "with correct user scoping" do
let!(:member_in_other_project) do
create(:user,
- firstname: 'Member 1',
- lastname: 'In other Project',
+ firstname: "Member 1",
+ lastname: "In other Project",
member_with_roles: { other_project => reader_role })
end
- it 'shows only users that are members of the project' do
+ it "shows only users that are members of the project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Member 1')
+ field.search("Member 1")
field.expect_option(member_in_project.name)
field.expect_no_option(member_in_other_project.name)
end
end
- describe 'with support for user groups' do
+ describe "with support for user groups" do
let!(:member_in_other_project) do
create(:user,
- firstname: 'Member 1',
- lastname: 'In other Project',
+ firstname: "Member 1",
+ lastname: "In other Project",
member_with_roles: { other_project => reader_role })
end
let!(:group) do
- create(:group, name: 'Group 1 in project',
+ create(:group, name: "Group 1 in project",
member_with_roles: { project => reader_role })
end
let!(:group_in_other_project) do
- create(:group, name: 'Group 1 in other project', members: [member_in_other_project],
+ create(:group, name: "Group 1 in other project", members: [member_in_other_project],
member_with_roles: { other_project => reader_role })
end
- it 'shows only groups that are associated with this project' do
+ it "shows only groups that are associated with this project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Group 1')
+ field.search("Group 1")
field.expect_option(group.name)
field.expect_no_option(group_in_other_project.name)
end
end
- describe 'with support for placeholder users' do
+ describe "with support for placeholder users" do
let!(:placeholder_user) do
- create(:placeholder_user, name: 'Placeholder User',
+ create(:placeholder_user, name: "Placeholder User",
member_with_roles: { project => reader_role })
end
- it 'shows the placeholder user' do
+ it "shows the placeholder user" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Placeholder User')
+ field.search("Placeholder User")
field.expect_option(placeholder_user.name)
end
@@ -417,18 +415,18 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi select fields' do
+ describe "with multi select fields" do
let(:section) { section_for_multi_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a autocomplete multi select field' do
- it 'shows the correct value if given' do
+ shared_examples "a autocomplete multi select field" do
+ it "shows the correct value if given" do
overview_page.open_edit_dialog_for_section(section)
field.expect_selected(*expected_initial_value)
end
- it 'shows a blank input if no value or default value is given' do
+ it "shows a blank input if no value or default value is given" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -436,7 +434,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_blank
end
- it 'filters the list based on the input' do
+ it "filters the list based on the input" do
overview_page.open_edit_dialog_for_section(section)
field.search(second_option)
@@ -446,7 +444,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_no_option(third_option)
end
- it 'allows to select multiple values' do
+ it "allows to select multiple values" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -458,7 +456,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_selected(third_option)
end
- it 'allows to remove selected values' do
+ it "allows to remove selected values" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -472,7 +470,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
field.expect_not_selected(third_option)
end
- it 'allows to remove all selected values at once' do
+ it "allows to remove all selected values at once" do
custom_field.custom_values.destroy_all
overview_page.open_edit_dialog_for_section(section)
@@ -487,7 +485,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi select list CF' do
+ describe "with multi select list CF" do
let(:custom_field) { multi_list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -497,9 +495,9 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { custom_field.custom_options.second.value }
let(:third_option) { custom_field.custom_options.third.value }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
- it 'shows the default value if no value is given' do
+ it "shows the default value if no value is given" do
multi_list_project_custom_field.custom_values.destroy_all
multi_list_project_custom_field.custom_options.first.update!(default_value: true)
@@ -512,7 +510,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi version select list CF' do
+ describe "with multi version select list CF" do
let(:custom_field) { multi_version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -522,9 +520,9 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { second_version.name }
let(:third_option) { third_version.name }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
- describe 'with correct version scoping' do
+ describe "with correct version scoping" do
context "with a version on a different project" do
let!(:version_in_other_project) do
create(:version, name: "Version 1 in other project", project: other_project)
@@ -574,7 +572,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi user select list CF' do
+ describe "with multi user select list CF" do
let(:custom_field) { multi_user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
@@ -584,90 +582,90 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:second_option) { another_member_in_project.name }
let(:third_option) { one_more_member_in_project.name }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
- describe 'with correct user scoping' do
+ describe "with correct user scoping" do
let!(:member_in_other_project) do
create(:user,
- firstname: 'Member 1',
- lastname: 'In other Project',
+ firstname: "Member 1",
+ lastname: "In other Project",
member_with_roles: { other_project => reader_role })
end
- it 'shows only users that are members of the project' do
+ it "shows only users that are members of the project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Member 1')
+ field.search("Member 1")
field.expect_option(member_in_project.name)
field.expect_no_option(member_in_other_project.name)
end
end
- describe 'with support for user groups' do
+ describe "with support for user groups" do
let!(:member_in_other_project) do
create(:user,
- firstname: 'Member 1',
- lastname: 'In other Project',
+ firstname: "Member 1",
+ lastname: "In other Project",
member_with_roles: { other_project => reader_role })
end
let!(:group) do
- create(:group, name: 'Group 1 in project',
+ create(:group, name: "Group 1 in project",
member_with_roles: { project => reader_role })
end
let!(:another_group) do
- create(:group, name: 'Group 2 in project',
+ create(:group, name: "Group 2 in project",
member_with_roles: { project => reader_role })
end
let!(:group_in_other_project) do
- create(:group, name: 'Group 1 in other project', members: [member_in_other_project],
+ create(:group, name: "Group 1 in other project", members: [member_in_other_project],
member_with_roles: { other_project => reader_role })
end
- it 'shows only groups that are associated with this project' do
+ it "shows only groups that are associated with this project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Group 1')
+ field.search("Group 1")
field.expect_option(group.name)
field.expect_no_option(group_in_other_project.name)
end
- it 'enables to select multiple user groups' do
+ it "enables to select multiple user groups" do
overview_page.open_edit_dialog_for_section(section)
- field.select_option('Group 1 in project')
- field.select_option('Group 2 in project')
+ field.select_option("Group 1 in project")
+ field.select_option("Group 2 in project")
- field.expect_selected('Group 1 in project')
- field.expect_selected('Group 2 in project')
+ field.expect_selected("Group 1 in project")
+ field.expect_selected("Group 2 in project")
end
end
- describe 'with support for placeholder users' do
+ describe "with support for placeholder users" do
let!(:placeholder_user) do
- create(:placeholder_user, name: 'Placeholder user',
+ create(:placeholder_user, name: "Placeholder user",
member_with_roles: { project => reader_role })
end
let!(:another_placeholder_user) do
- create(:placeholder_user, name: 'Another placeholder User',
+ create(:placeholder_user, name: "Another placeholder User",
member_with_roles: { project => reader_role })
end
let!(:placeholder_user_in_other_project) do
- create(:placeholder_user, name: 'Placeholder user in other project',
+ create(:placeholder_user, name: "Placeholder user in other project",
member_with_roles: { other_project => reader_role })
end
- it 'shows only placeholder users from this project' do
+ it "shows only placeholder users from this project" do
overview_page.open_edit_dialog_for_section(section)
- field.search('Placeholder User')
+ field.search("Placeholder User")
field.expect_option(placeholder_user.name)
field.expect_option(another_placeholder_user.name)
field.expect_no_option(placeholder_user_in_other_project.name)
end
- it 'enables to select multiple placeholder users' do
+ it "enables to select multiple placeholder users" do
overview_page.open_edit_dialog_for_section(section)
field.select_option(placeholder_user.name)
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
index 85d7d638f55..15f61de8bbe 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/update_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require_relative '../shared_context'
+require "spec_helper"
+require_relative "../shared_context"
-RSpec.describe 'Edit project custom fields on project overview page', :js do
- include_context 'with seeded projects, members and project custom fields'
+RSpec.describe "Edit project custom fields on project overview page", :js do
+ include_context "with seeded projects, members and project custom fields"
let(:overview_page) { Pages::Projects::Show.new(project) }
@@ -39,19 +39,19 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
overview_page.visit_page
end
- describe 'with correct updating behaviour' do
- describe 'with input fields' do
+ describe "with correct updating behaviour" do
+ describe "with input fields" do
let(:section) { section_for_input_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a custom field checkbox' do
- it 'sets the value to true if checked' do
+ shared_examples "a custom field checkbox" do
+ it "sets the value to true if checked" do
custom_field.custom_values.destroy_all
overview_page.visit_page
overview_page.within_custom_field_container(custom_field) do
- expect(page).to have_content I18n.t('placeholders.default')
+ expect(page).to have_content I18n.t("placeholders.default")
end
overview_page.open_edit_dialog_for_section(section)
@@ -66,7 +66,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'sets the value to false if unchecked' do
+ it "sets the value to false if unchecked" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_content "Yes"
end
@@ -83,7 +83,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'does not change the value if untouched' do
+ it "does not change the value if untouched" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_content "Yes"
end
@@ -101,14 +101,14 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- shared_examples 'a custom field input' do
- it 'saves the value properly' do
+ shared_examples "a custom field input" do
+ it "saves the value properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
overview_page.within_custom_field_container(custom_field) do
- expect(page).to have_content I18n.t('placeholders.default')
+ expect(page).to have_content I18n.t("placeholders.default")
end
overview_page.open_edit_dialog_for_section(section)
@@ -123,7 +123,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'does not change the value if untouched' do
+ it "does not change the value if untouched" do
overview_page.visit_page
overview_page.within_custom_field_container(custom_field) do
@@ -142,26 +142,26 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'removes the value properly' do
+ it "removes the value properly" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_content expected_initial_value
end
overview_page.open_edit_dialog_for_section(section)
- field.fill_in(with: '')
+ field.fill_in(with: "")
dialog.submit
dialog.expect_closed
overview_page.within_custom_field_container(custom_field) do
- expect(page).to have_content I18n.t('placeholders.default')
+ expect(page).to have_content I18n.t("placeholders.default")
end
end
end
- shared_examples 'a rich text custom field input' do
- it 'saves the value properly' do
+ shared_examples "a rich text custom field input" do
+ it "saves the value properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -182,7 +182,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'does not change the value if untouched' do
+ it "does not change the value if untouched" do
overview_page.visit_page
overview_page.within_custom_field_container(custom_field) do
@@ -201,14 +201,14 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'removes the value properly' do
+ it "removes the value properly" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_text(expected_initial_value)
end
overview_page.open_edit_dialog_for_section(section)
- field.set_value('')
+ field.set_value("")
dialog.submit
dialog.expect_closed
@@ -219,71 +219,70 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with boolean CF' do
+ describe "with boolean CF" do
let(:custom_field) { boolean_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- let(:expected_initial_value) { true }
- it_behaves_like 'a custom field checkbox'
+ it_behaves_like "a custom field checkbox"
end
- describe 'with string CF' do
+ describe "with string CF" do
let(:custom_field) { string_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- let(:expected_initial_value) { 'Foo' }
- let(:update_value) { 'Bar' }
+ let(:expected_initial_value) { "Foo" }
+ let(:update_value) { "Bar" }
let(:expected_updated_value) { update_value }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with integer CF' do
+ describe "with integer CF" do
let(:custom_field) { integer_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
let(:expected_initial_value) { 123 }
let(:update_value) { 456 }
let(:expected_updated_value) { update_value }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with float CF' do
+ describe "with float CF" do
let(:custom_field) { float_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
let(:expected_initial_value) { 123.456 }
let(:update_value) { 456.789 }
let(:expected_updated_value) { update_value }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with date CF' do
+ describe "with date CF" do
let(:custom_field) { date_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- let(:expected_initial_value) { '01/01/2024' }
+ let(:expected_initial_value) { "01/01/2024" }
let(:update_value) { Date.new(2024, 1, 2) }
- let(:expected_updated_value) { '01/02/2024' }
+ let(:expected_updated_value) { "01/02/2024" }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with text CF' do
+ describe "with text CF" do
let(:custom_field) { text_project_custom_field }
let(:field) { FormFields::Primerized::EditorFormField.new(custom_field) }
let(:expected_initial_value) { "Lorem\nipsum" } # TBD: why is the second newline missing?
let(:update_value) { "Dolor\n\nsit" }
let(:expected_updated_value) { "Dolor\nsit" }
- it_behaves_like 'a rich text custom field input'
+ it_behaves_like "a rich text custom field input"
end
end
- describe 'with select fields' do
+ describe "with select fields" do
let(:section) { section_for_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a select field' do
- it 'saves the value properly' do
+ shared_examples "a select field" do
+ it "saves the value properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -304,7 +303,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'does not change the value if untouched' do
+ it "does not change the value if untouched" do
overview_page.visit_page
overview_page.within_custom_field_container(custom_field) do
@@ -324,7 +323,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'removes the value properly' do
+ it "removes the value properly" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_text first_option
end
@@ -342,39 +341,39 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with list CF' do
+ describe "with list CF" do
let(:custom_field) { list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { custom_field.custom_options.first.value }
- it_behaves_like 'a select field'
+ it_behaves_like "a select field"
end
- describe 'with version select CF' do
+ describe "with version select CF" do
let(:custom_field) { version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { first_version.name }
- it_behaves_like 'a select field'
+ it_behaves_like "a select field"
end
- describe 'with user select CF' do
+ describe "with user select CF" do
let(:custom_field) { user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { member_in_project.name }
- it_behaves_like 'a select field'
+ it_behaves_like "a select field"
- describe 'with support for user groups' do
+ describe "with support for user groups" do
let!(:group) do
- create(:group, name: 'Group 1 in project',
+ create(:group, name: "Group 1 in project",
member_with_roles: { project => reader_role })
end
- it 'saves selected user group properly' do
+ it "saves selected user group properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -392,13 +391,13 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with support for placeholder users' do
+ describe "with support for placeholder users" do
let!(:placeholder_user) do
- create(:placeholder_user, name: 'Placeholder user',
+ create(:placeholder_user, name: "Placeholder user",
member_with_roles: { project => reader_role })
end
- it 'saves selected placeholer user properly' do
+ it "saves selected placeholer user properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -418,12 +417,12 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi select fields' do
+ describe "with multi select fields" do
let(:section) { section_for_multi_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a autocomplete multi select field' do
- it 'saves single selected values properly' do
+ shared_examples "a autocomplete multi select field" do
+ it "saves single selected values properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -444,7 +443,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'saves multi selected values properly' do
+ it "saves multi selected values properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -468,7 +467,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'removes deselected values properly' do
+ it "removes deselected values properly" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_text first_option
expect(page).to have_text second_option
@@ -487,7 +486,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'does not remove values when not touching the init values' do
+ it "does not remove values when not touching the init values" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_text first_option
expect(page).to have_text second_option
@@ -507,7 +506,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'removes all values when clearing the input' do
+ it "removes all values when clearing the input" do
overview_page.within_custom_field_container(custom_field) do
expect(page).to have_text first_option
expect(page).to have_text second_option
@@ -526,7 +525,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'adds values properly to init values' do
+ it "adds values properly to init values" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -562,46 +561,46 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with multi select list CF' do
+ describe "with multi select list CF" do
let(:custom_field) { multi_list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { custom_field.custom_options.first.value }
let(:second_option) { custom_field.custom_options.second.value }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
end
- describe 'with multi version select list CF' do
+ describe "with multi version select list CF" do
let(:custom_field) { multi_version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { first_version.name }
let(:second_option) { second_version.name }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
end
- describe 'with multi user select list CF' do
+ describe "with multi user select list CF" do
let(:custom_field) { multi_user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
let(:first_option) { member_in_project.name }
let(:second_option) { another_member_in_project.name }
- it_behaves_like 'a autocomplete multi select field'
+ it_behaves_like "a autocomplete multi select field"
- describe 'with support for user groups' do
+ describe "with support for user groups" do
let!(:group) do
- create(:group, name: 'Group 1 in project',
+ create(:group, name: "Group 1 in project",
member_with_roles: { project => reader_role })
end
let!(:another_group) do
- create(:group, name: 'Group 2 in project',
+ create(:group, name: "Group 2 in project",
member_with_roles: { project => reader_role })
end
- it 'saves selected user groups properly' do
+ it "saves selected user groups properly" do
custom_field.custom_values.destroy_all
overview_page.visit_page
@@ -621,17 +620,17 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- describe 'with support for placeholder users' do
+ describe "with support for placeholder users" do
let!(:placeholder_user) do
- create(:placeholder_user, name: 'Placeholder user',
+ create(:placeholder_user, name: "Placeholder user",
member_with_roles: { project => reader_role })
end
let!(:another_placeholder_user) do
- create(:placeholder_user, name: 'Another placeholder User',
+ create(:placeholder_user, name: "Another placeholder User",
member_with_roles: { project => reader_role })
end
- it 'shows only placeholder users from this project' do
+ it "shows only placeholder users from this project" do
custom_field.custom_values.destroy_all
overview_page.visit_page
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
index 460d7253ddf..833cc8063f6 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/validation_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require_relative '../shared_context'
+require "spec_helper"
+require_relative "../shared_context"
-RSpec.describe 'Edit project custom fields on project overview page', :js do
- include_context 'with seeded projects, members and project custom fields'
+RSpec.describe "Edit project custom fields on project overview page", :js do
+ include_context "with seeded projects, members and project custom fields"
let(:overview_page) { Pages::Projects::Show.new(project) }
@@ -39,12 +39,12 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
overview_page.visit_page
end
- describe 'with correct validation behaviour' do
- describe 'after validation' do
+ describe "with correct validation behaviour" do
+ describe "after validation" do
let(:section) { section_for_input_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- it 'keeps showing only activated custom fields (tricky regression)' do
+ it "keeps showing only activated custom fields (tricky regression)" do
custom_field = string_project_custom_field
custom_field.update!(is_required: true)
field = FormFields::Primerized::InputField.new(custom_field)
@@ -54,38 +54,38 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.within_async_content do
containers = dialog.input_containers
- expect(containers[0].text).to include('Boolean field')
- expect(containers[1].text).to include('String field')
- expect(containers[2].text).to include('Integer field')
- expect(containers[3].text).to include('Float field')
- expect(containers[4].text).to include('Date field')
- expect(containers[5].text).to include('Text field')
+ expect(containers[0].text).to include("Boolean field")
+ expect(containers[1].text).to include("String field")
+ expect(containers[2].text).to include("Integer field")
+ expect(containers[3].text).to include("Float field")
+ expect(containers[4].text).to include("Date field")
+ expect(containers[5].text).to include("Text field")
expect(page).to have_no_text(boolean_project_custom_field_activated_in_other_project.name)
end
- field.fill_in(with: '') # this will trigger the validation
+ field.fill_in(with: "") # this will trigger the validation
dialog.submit
- field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ field.expect_error(I18n.t("activerecord.errors.messages.blank"))
dialog.within_async_content do
containers = dialog.input_containers
- expect(containers[0].text).to include('Boolean field')
- expect(containers[1].text).to include('String field')
- expect(containers[2].text).to include('Integer field')
- expect(containers[3].text).to include('Float field')
- expect(containers[4].text).to include('Date field')
- expect(containers[5].text).to include('Text field')
+ expect(containers[0].text).to include("Boolean field")
+ expect(containers[1].text).to include("String field")
+ expect(containers[2].text).to include("Integer field")
+ expect(containers[3].text).to include("Float field")
+ expect(containers[4].text).to include("Date field")
+ expect(containers[5].text).to include("Text field")
expect(page).to have_no_text(boolean_project_custom_field_activated_in_other_project.name)
end
end
- describe 'does not loose the unpersisted values of the custom fields' do
- context 'with input fields' do
+ describe "does not loose the unpersisted values of the custom fields" do
+ context "with input fields" do
let(:section) { section_for_input_fields }
let(:invalid_custom_field) { string_project_custom_field }
@@ -93,32 +93,32 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:invalid_field) { FormFields::Primerized::InputField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::InputField.new(valid_custom_field) }
- it 'keeps the value' do
+ it "keeps the value" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
- invalid_field.fill_in(with: '')
- valid_field.fill_in(with: '123')
+ invalid_field.fill_in(with: "")
+ valid_field.fill_in(with: "123")
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
- invalid_field.expect_value('')
- valid_field.expect_value('123')
+ invalid_field.expect_value("")
+ valid_field.expect_value("123")
end
end
- context 'with select fields' do
+ context "with select fields" do
let(:section) { section_for_select_fields }
- context 'with version selected' do
+ context "with version selected" do
let(:invalid_custom_field) { list_project_custom_field }
let(:valid_custom_field) { version_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the value' do
+ it "keeps the value" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
@@ -127,20 +127,20 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
valid_field.expect_selected(third_version.name)
end
end
- context 'with user selected' do
+ context "with user selected" do
let(:invalid_custom_field) { list_project_custom_field }
let(:valid_custom_field) { user_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the value' do
+ it "keeps the value" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
@@ -149,46 +149,46 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
valid_field.expect_selected(another_member_in_project.name)
end
end
- context 'with list selected' do
+ context "with list selected" do
let(:invalid_custom_field) { user_project_custom_field }
let(:valid_custom_field) { list_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the value' do
+ it "keeps the value" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
invalid_field.clear
- valid_field.select_option('Option 3')
+ valid_field.select_option("Option 3")
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
- valid_field.expect_selected('Option 3')
+ valid_field.expect_selected("Option 3")
end
end
end
- context 'with multi select fields' do
+ context "with multi select fields" do
let(:section) { section_for_multi_select_fields }
- context 'with multi version selected' do
+ context "with multi version selected" do
let(:invalid_custom_field) { multi_list_project_custom_field }
let(:valid_custom_field) { multi_version_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the values' do
+ it "keeps the values" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
@@ -198,20 +198,20 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
valid_field.expect_selected(first_version.name, third_version.name)
end
end
- context 'with multi user selected' do
+ context "with multi user selected" do
let(:invalid_custom_field) { multi_list_project_custom_field }
let(:valid_custom_field) { multi_user_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the values' do
+ it "keeps the values" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
@@ -221,40 +221,40 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
valid_field.expect_selected(member_in_project.name, one_more_member_in_project.name)
end
end
- context 'with multi list selected' do
+ context "with multi list selected" do
let(:invalid_custom_field) { multi_user_project_custom_field }
let(:valid_custom_field) { multi_list_project_custom_field }
let(:invalid_field) { FormFields::Primerized::AutocompleteField.new(invalid_custom_field) }
let(:valid_field) { FormFields::Primerized::AutocompleteField.new(valid_custom_field) }
- it 'keeps the value' do
+ it "keeps the value" do
invalid_custom_field.update!(is_required: true)
overview_page.open_edit_dialog_for_section(section)
invalid_field.clear
valid_field.clear
- valid_field.select_option('Option 1', 'Option 3')
+ valid_field.select_option("Option 1", "Option 3")
dialog.submit
- invalid_field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank"))
invalid_field.expect_blank
- valid_field.expect_selected('Option 1', 'Option 3')
+ valid_field.expect_selected("Option 1", "Option 3")
end
end
end
end
end
- describe 'editing multiple sections' do
+ describe "editing multiple sections" do
let(:input_fields_dialog) do
Components::Projects::ProjectCustomFields::EditDialog.new(project, section_for_input_fields)
end
@@ -263,7 +263,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
let(:field) { FormFields::Primerized::AutocompleteField.new(list_project_custom_field) }
- it 'displays validation errors, when the previous section modal was canceled (Regression)' do
+ it "displays validation errors, when the previous section modal was canceled (Regression)" do
list_project_custom_field.update!(is_required: true)
list_project_custom_field.custom_values.destroy_all
@@ -272,16 +272,16 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
overview_page.open_edit_dialog_for_section(section_for_select_fields)
select_fields_dialog.submit
- field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ field.expect_error(I18n.t("activerecord.errors.messages.blank"))
end
end
- describe 'with input fields' do
+ describe "with input fields" do
let(:section) { section_for_input_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a custom field input' do
- it 'shows an error if the value is invalid' do
+ shared_examples "a custom field input" do
+ it "shows an error if the value is invalid" do
custom_field.update!(is_required: true)
custom_field.custom_values.destroy_all
@@ -289,162 +289,54 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ field.expect_error(I18n.t("activerecord.errors.messages.blank"))
end
end
# boolean CFs can not be validated
- describe 'with string CF' do
+ describe "with string CF" do
let(:custom_field) { string_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- it_behaves_like 'a custom field input'
-
- it 'shows an error if the value is too long' do
- custom_field.update!(max_length: 3)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: 'Foooo')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_long', count: 3))
- end
-
- it 'shows an error if the value is too short' do
- custom_field.update!(min_length: 3, max_length: 5)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: 'Fo')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_short', count: 3))
- end
-
- it 'shows an error if the value does not match the regex' do
- custom_field.update!(regexp: '^[A-Z]+$')
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: 'foo')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.invalid'))
- end
+ it_behaves_like "a custom field input"
end
- describe 'with integer CF' do
+ describe "with integer CF" do
let(:custom_field) { integer_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- it_behaves_like 'a custom field input'
-
- it 'shows an error if the value is too long' do
- custom_field.update!(max_length: 2)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: '111')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_long', count: 2))
- end
-
- it 'shows an error if the value is too short' do
- custom_field.update!(min_length: 2, max_length: 5)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: '1')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_short', count: 2))
- end
+ it_behaves_like "a custom field input"
end
- describe 'with float CF' do
+ describe "with float CF" do
let(:custom_field) { float_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- it_behaves_like 'a custom field input'
-
- it 'shows an error if the value is too long' do
- custom_field.update!(max_length: 4)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: '1111.1')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_long', count: 4))
- end
-
- it 'shows an error if the value is too short' do
- custom_field.update!(min_length: 4, max_length: 5)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.fill_in(with: '1.1')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_short', count: 4))
- end
+ it_behaves_like "a custom field input"
end
- describe 'with date CF' do
+ describe "with date CF" do
let(:custom_field) { date_project_custom_field }
let(:field) { FormFields::Primerized::InputField.new(custom_field) }
- it_behaves_like 'a custom field input'
+ it_behaves_like "a custom field input"
end
- describe 'with text CF' do
+ describe "with text CF" do
let(:custom_field) { text_project_custom_field }
let(:field) { FormFields::Primerized::EditorFormField.new(custom_field) }
- it_behaves_like 'a custom field input'
-
- it 'shows an error if the value is too long' do
- custom_field.update!(max_length: 3)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.set_value('Foooo')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_long', count: 3))
- end
-
- it 'shows an error if the value is too short' do
- custom_field.update!(min_length: 3, max_length: 5)
-
- overview_page.open_edit_dialog_for_section(section)
-
- field.set_value('Fo')
-
- dialog.submit
-
- field.expect_error(I18n.t('activerecord.errors.messages.too_short', count: 3))
- end
+ it_behaves_like "a custom field input"
end
end
- describe 'with select fields' do
+ describe "with select fields" do
let(:section) { section_for_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a custom field select' do
- it 'shows an error if the value is invalid' do
+ shared_examples "a custom field select" do
+ it "shows an error if the value is invalid" do
custom_field.update!(is_required: true)
custom_field.custom_values.destroy_all
@@ -452,38 +344,38 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ field.expect_error(I18n.t("activerecord.errors.messages.blank"))
end
end
- describe 'with list CF' do
+ describe "with list CF" do
let(:custom_field) { list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field select'
+ it_behaves_like "a custom field select"
end
- describe 'with version CF' do
+ describe "with version CF" do
let(:custom_field) { version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field select'
+ it_behaves_like "a custom field select"
end
- describe 'with user CF' do
+ describe "with user CF" do
let(:custom_field) { user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field select'
+ it_behaves_like "a custom field select"
end
end
- describe 'with multi select fields' do
+ describe "with multi select fields" do
let(:section) { section_for_multi_select_fields }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section) }
- shared_examples 'a custom field multi select' do
- it 'shows an error if the value is invalid' do
+ shared_examples "a custom field multi select" do
+ it "shows an error if the value is invalid" do
custom_field.update!(is_required: true)
custom_field.custom_values.destroy_all
@@ -491,29 +383,29 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.submit
- field.expect_error(I18n.t('activerecord.errors.messages.blank'))
+ field.expect_error(I18n.t("activerecord.errors.messages.blank"))
end
end
- describe 'with multi list CF' do
+ describe "with multi list CF" do
let(:custom_field) { multi_list_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field multi select'
+ it_behaves_like "a custom field multi select"
end
- describe 'with multi version CF' do
+ describe "with multi version CF" do
let(:custom_field) { multi_version_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field multi select'
+ it_behaves_like "a custom field multi select"
end
- describe 'with multi user CF' do
+ describe "with multi user CF" do
let(:custom_field) { multi_user_project_custom_field }
let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) }
- it_behaves_like 'a custom field multi select'
+ it_behaves_like "a custom field multi select"
end
end
end
diff --git a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
index 50f01061ca2..4eae8b7909e 100644
--- a/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/sidebar_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require_relative 'shared_context'
+require "spec_helper"
+require_relative "shared_context"
-RSpec.describe 'Show project custom fields on project overview page', :js, :with_cuprite do
- include_context 'with seeded projects, members and project custom fields'
+RSpec.describe "Show project custom fields on project overview page", :js, :with_cuprite do
+ include_context "with seeded projects, members and project custom fields"
let(:overview_page) { Pages::Projects::Show.new(project) }
@@ -38,191 +38,174 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
login_as admin
end
- it 'does show the project attributes sidebar' do
+ it "does show the project attributes sidebar" do
overview_page.visit_page
- within '.op-grid-page' do
- expect(page).to have_css('#project-custom-fields-sidebar')
+ within ".op-grid-page" do
+ expect(page).to have_css("#project-custom-fields-sidebar")
end
end
- describe 'with correct scoping' do
- it 'shows enabled project custom fields in a sidebar grouped by section' do
+ describe "with correct order and scoping" do
+ it "shows the project custom field sections in the correct order" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
- expect(page).to have_css('.op-project-custom-field-section-container', count: 3)
+ sections = page.all(".op-project-custom-field-section-container")
- overview_page.within_custom_field_section_container(section_for_input_fields) do
- expect(page).to have_text 'Input fields'
-
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text 'String field'
- expect(page).to have_text 'Integer field'
- expect(page).to have_text 'Float field'
- expect(page).to have_text 'Date field'
- expect(page).to have_text 'Text field'
- end
-
- overview_page.within_custom_field_section_container(section_for_select_fields) do
- expect(page).to have_text 'Select fields'
-
- expect(page).to have_text 'List field'
- expect(page).to have_text 'Version field'
- expect(page).to have_text 'User field'
- end
-
- overview_page.within_custom_field_section_container(section_for_multi_select_fields) do
- expect(page).to have_text 'Multi select fields'
+ expect(sections.size).to eq(3)
- expect(page).to have_text 'Multi list field'
- expect(page).to have_text 'Multi version field'
- expect(page).to have_text 'Multi user field'
- end
+ expect(sections[0].text).to include("Input fields")
+ expect(sections[1].text).to include("Select fields")
+ expect(sections[2].text).to include("Multi select fields")
end
- end
- it 'does not show project custom fields not enabled for this project in a sidebar' do
- create(:string_project_custom_field, projects: [other_project], name: 'String field enabled for other project')
+ section_for_input_fields.move_to_bottom
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
- expect(page).to have_no_text 'String field enabled for other project'
+ sections = page.all(".op-project-custom-field-section-container")
+
+ expect(sections.size).to eq(3)
+
+ expect(sections[0].text).to include("Select fields")
+ expect(sections[1].text).to include("Multi select fields")
+ expect(sections[2].text).to include("Input fields")
end
end
- end
- describe 'with correct order' do
- it 'shows the project custom field sections in the correct order' do
+ it "shows the project custom fields in the correct order within the sections" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
- sections = page.all('.op-project-custom-field-section-container')
+ overview_page.within_custom_field_section_container(section_for_input_fields) do
+ fields = page.all(".op-project-custom-field-container")
- expect(sections.size).to eq(3)
+ expect(fields.size).to eq(6)
- expect(sections[0].text).to include('Input fields')
- expect(sections[1].text).to include('Select fields')
- expect(sections[2].text).to include('Multi select fields')
- end
+ expect(fields[0].text).to include("Boolean field")
+ expect(fields[1].text).to include("String field")
+ expect(fields[2].text).to include("Integer field")
+ expect(fields[3].text).to include("Float field")
+ expect(fields[4].text).to include("Date field")
+ expect(fields[5].text).to include("Text field")
+ end
- section_for_input_fields.move_to_bottom
+ overview_page.within_custom_field_section_container(section_for_select_fields) do
+ fields = page.all(".op-project-custom-field-container")
- overview_page.visit_page
+ expect(fields.size).to eq(3)
- overview_page.within_async_loaded_sidebar do
- sections = page.all('.op-project-custom-field-section-container')
+ expect(fields[0].text).to include("List field")
+ expect(fields[1].text).to include("Version field")
+ expect(fields[2].text).to include("User field")
+ end
- expect(sections.size).to eq(3)
+ overview_page.within_custom_field_section_container(section_for_multi_select_fields) do
+ fields = page.all(".op-project-custom-field-container")
- expect(sections[0].text).to include('Select fields')
- expect(sections[1].text).to include('Multi select fields')
- expect(sections[2].text).to include('Input fields')
+ expect(fields.size).to eq(3)
+
+ expect(fields[0].text).to include("Multi list field")
+ expect(fields[1].text).to include("Multi version field")
+ expect(fields[2].text).to include("Multi user field")
+ end
end
- end
- it 'shows the project custom fields in the correct order within the sections' do
+ string_project_custom_field.move_to_bottom
+
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_section_container(section_for_input_fields) do
- fields = page.all('.op-project-custom-field-container')
+ fields = page.all(".op-project-custom-field-container")
expect(fields.size).to eq(6)
- expect(fields[0].text).to include('Boolean field')
- expect(fields[1].text).to include('String field')
- expect(fields[2].text).to include('Integer field')
- expect(fields[3].text).to include('Float field')
- expect(fields[4].text).to include('Date field')
- expect(fields[5].text).to include('Text field')
+ expect(fields[0].text).to include("Boolean field")
+ expect(fields[1].text).to include("Integer field")
+ expect(fields[2].text).to include("Float field")
+ expect(fields[3].text).to include("Date field")
+ expect(fields[4].text).to include("Text field")
+ expect(fields[5].text).to include("String field")
end
end
+ end
- string_project_custom_field.move_to_bottom
+ it "does not show project custom fields not enabled for this project in a sidebar" do
+ create(:string_project_custom_field, projects: [other_project], name: "String field enabled for other project")
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
- overview_page.within_custom_field_section_container(section_for_input_fields) do
- fields = page.all('.op-project-custom-field-container')
-
- expect(fields.size).to eq(6)
-
- expect(fields[0].text).to include('Boolean field')
- expect(fields[1].text).to include('Integer field')
- expect(fields[2].text).to include('Float field')
- expect(fields[3].text).to include('Date field')
- expect(fields[4].text).to include('Text field')
- expect(fields[5].text).to include('String field')
- end
+ expect(page).to have_no_text "String field enabled for other project"
end
end
end
- describe 'with correct values' do
- describe 'with boolean CF' do
+ describe "with correct values" do
+ describe "with boolean CF" do
# it_behaves_like 'a project custom field' do
# let(subject) { boolean_project_custom_field }
# end
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(boolean_project_custom_field) do
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text 'Yes'
+ expect(page).to have_text "Boolean field"
+ expect(page).to have_text "Yes"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
# A boolean cannot be completely unset via UI, only toggle between true and false, no blank value possible
before do
boolean_project_custom_field.custom_values.where(customized: project).first.update!(value: false)
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(boolean_project_custom_field) do
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text 'No'
+ expect(page).to have_text "Boolean field"
+ expect(page).to have_text "No"
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
boolean_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(boolean_project_custom_field) do
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Boolean field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
+ it "does not show the default value for the project custom field if no value given" do
boolean_project_custom_field.update!(default_value: true)
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(boolean_project_custom_field) do
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Boolean field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
@@ -232,295 +215,295 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(boolean_project_custom_field) do
- expect(page).to have_text 'Boolean field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Boolean field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with string CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with string CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(string_project_custom_field) do
- expect(page).to have_text 'String field'
- expect(page).to have_text 'Foo'
+ expect(page).to have_text "String field"
+ expect(page).to have_text "Foo"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- string_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ string_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(string_project_custom_field) do
- expect(page).to have_text 'String field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "String field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
string_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(string_project_custom_field) do
- expect(page).to have_text 'String field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "String field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
- string_project_custom_field.update!(default_value: 'Bar')
+ it "does not show the default value for the project custom field if no value given" do
+ string_project_custom_field.update!(default_value: "Bar")
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(string_project_custom_field) do
- expect(page).to have_text 'String field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "String field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with integer CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with integer CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(integer_project_custom_field) do
- expect(page).to have_text 'Integer field'
- expect(page).to have_text '123'
+ expect(page).to have_text "Integer field"
+ expect(page).to have_text "123"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- integer_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ integer_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(integer_project_custom_field) do
- expect(page).to have_text 'Integer field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Integer field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
integer_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(integer_project_custom_field) do
- expect(page).to have_text 'Integer field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Integer field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
+ it "does not show the default value for the project custom field if no value given" do
integer_project_custom_field.update!(default_value: 456)
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(integer_project_custom_field) do
- expect(page).to have_text 'Integer field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Integer field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with date CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with date CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(date_project_custom_field) do
- expect(page).to have_text 'Date field'
- expect(page).to have_text '01/01/2024'
+ expect(page).to have_text "Date field"
+ expect(page).to have_text "01/01/2024"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- date_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ date_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(date_project_custom_field) do
- expect(page).to have_text 'Date field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Date field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
date_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(date_project_custom_field) do
- expect(page).to have_text 'Date field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Date field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
+ it "does not show the default value for the project custom field if no value given" do
date_project_custom_field.update!(default_value: Date.new(2024, 2, 2))
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(date_project_custom_field) do
- expect(page).to have_text 'Date field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Date field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with float CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with float CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(float_project_custom_field) do
- expect(page).to have_text 'Float field'
- expect(page).to have_text '123.456'
+ expect(page).to have_text "Float field"
+ expect(page).to have_text "123.456"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- float_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ float_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(float_project_custom_field) do
- expect(page).to have_text 'Float field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Float field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
float_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(float_project_custom_field) do
- expect(page).to have_text 'Float field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Float field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'dies not show the default value for the project custom field if no value given' do
+ it "dies not show the default value for the project custom field if no value given" do
float_project_custom_field.update!(default_value: 456.789)
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(float_project_custom_field) do
- expect(page).to have_text 'Float field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Float field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with text CF' do
- describe 'with value set by user' do
- context 'with a value that is shorter than 100 characters' do
- it 'shows the correct value for the project custom field if given without truncation and dialog button' do
+ describe "with text CF" do
+ describe "with value set by user" do
+ context "with a value that is shorter than 100 characters" do
+ it "shows the correct value for the project custom field if given without truncation and dialog button" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(text_project_custom_field) do
- expect(page).to have_text 'Text field'
+ expect(page).to have_text "Text field"
expect(page).to have_text "Lorem\nipsum"
end
end
end
end
- context 'with a value that is longer than 100 characters' do
+ context "with a value that is longer than 100 characters" do
before do
- text_project_custom_field.custom_values.where(customized: project).first.update!(value: 'a' * 101)
+ text_project_custom_field.custom_values.where(customized: project).first.update!(value: "a" * 101)
end
- it 'shows the correct value for the project custom field if given with truncation and dialog button' do
+ it "shows the correct value for the project custom field if given with truncation and dialog button" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(text_project_custom_field) do
- expect(page).to have_text 'Text field'
+ expect(page).to have_text "Text field"
expect(page).to have_text ("#{'a' * 97}...")
- expect(page).to have_text 'Expand'
+ expect(page).to have_text "Expand"
- click_on 'Expand'
+ click_on "Expand"
- within 'dialog' do
- expect(page).to have_text 'a' * 101
+ within "dialog" do
+ expect(page).to have_text "a" * 101
end
end
end
@@ -528,254 +511,254 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- text_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ text_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(text_project_custom_field) do
- expect(page).to have_text 'Text field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Text field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
text_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(text_project_custom_field) do
- expect(page).to have_text 'Text field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Text field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
- text_project_custom_field.update!(default_value: 'Dolor sit amet')
+ it "does not show the default value for the project custom field if no value given" do
+ text_project_custom_field.update!(default_value: "Dolor sit amet")
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(text_project_custom_field) do
- expect(page).to have_text 'Text field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Text field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with list CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with list CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(list_project_custom_field) do
- expect(page).to have_text 'List field'
- expect(page).to have_text 'Option 1'
+ expect(page).to have_text "List field"
+ expect(page).to have_text "Option 1"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- list_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ list_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(list_project_custom_field) do
- expect(page).to have_text 'List field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "List field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
list_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(list_project_custom_field) do
- expect(page).to have_text 'List field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "List field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value for the project custom field if no value given' do
+ it "does not show the default value for the project custom field if no value given" do
list_project_custom_field.custom_options.first.update!(default_value: true)
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(list_project_custom_field) do
- expect(page).to have_text 'List field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "List field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with version CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with version CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(version_project_custom_field) do
- expect(page).to have_text 'Version field'
- expect(page).to have_text 'Version 1'
+ expect(page).to have_text "Version field"
+ expect(page).to have_text "Version 1"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- version_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ version_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(version_project_custom_field) do
- expect(page).to have_text 'Version field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Version field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
version_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(version_project_custom_field) do
- expect(page).to have_text 'Version field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Version field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with user CF' do
- describe 'with value set by user' do
- it 'shows the correct value for the project custom field if given' do
+ describe "with user CF" do
+ describe "with value set by user" do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(user_project_custom_field) do
- expect(page).to have_text 'User field'
- expect(page).to have_css('opce-principal')
- expect(page).to have_text 'Member 1 In Project'
+ expect(page).to have_text "User field"
+ expect(page).to have_css("opce-principal")
+ expect(page).to have_text "Member 1 In Project"
end
end
end
end
- describe 'with value unset by user' do
+ describe "with value unset by user" do
before do
- user_project_custom_field.custom_values.where(customized: project).first.update!(value: '')
+ user_project_custom_field.custom_values.where(customized: project).first.update!(value: "")
end
- it 'shows the correct value for the project custom field if given' do
+ it "shows the correct value for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(user_project_custom_field) do
- expect(page).to have_text 'User field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "User field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
user_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(user_project_custom_field) do
- expect(page).to have_text 'User field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "User field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
- describe 'with support for user groups' do
+ describe "with support for user groups" do
# TODO
end
- describe 'with support for user placeholders' do
+ describe "with support for user placeholders" do
# TODO
end
end
- describe 'with multi list CF' do
- describe 'with value set by user' do
- it 'shows the correct values for the project custom field if given' do
+ describe "with multi list CF" do
+ describe "with value set by user" do
+ it "shows the correct values for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_list_project_custom_field) do
- expect(page).to have_text 'Multi list field'
- expect(page).to have_text 'Option 1, Option 2'
+ expect(page).to have_text "Multi list field"
+ expect(page).to have_text "Option 1, Option 2"
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
multi_list_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_list_project_custom_field) do
- expect(page).to have_text 'Multi list field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Multi list field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
- it 'does not show the default value(s) for the project custom field if no value given' do
+ it "does not show the default value(s) for the project custom field if no value given" do
multi_list_project_custom_field.custom_options.first.update!(default_value: true)
multi_list_project_custom_field.custom_options.second.update!(default_value: true)
@@ -783,74 +766,74 @@ RSpec.describe 'Show project custom fields on project overview page', :js, :with
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_list_project_custom_field) do
- expect(page).to have_text 'Multi list field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Multi list field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with multi version CF' do
- describe 'with value set by user' do
- it 'shows the correct values for the project custom field if given' do
+ describe "with multi version CF" do
+ describe "with value set by user" do
+ it "shows the correct values for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_version_project_custom_field) do
- expect(page).to have_text 'Multi version field'
- expect(page).to have_text 'Version 1, Version 2'
+ expect(page).to have_text "Multi version field"
+ expect(page).to have_text "Version 1, Version 2"
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
multi_version_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_version_project_custom_field) do
- expect(page).to have_text 'Multi version field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Multi version field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
end
end
- describe 'with multi user CF' do
- describe 'with value set by user' do
- it 'shows the correct values for the project custom field if given' do
+ describe "with multi user CF" do
+ describe "with value set by user" do
+ it "shows the correct values for the project custom field if given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_user_project_custom_field) do
- expect(page).to have_text 'Multi user field'
- expect(page).to have_css 'opce-principal', count: 2
- expect(page).to have_text 'Member 1 In Project'
- expect(page).to have_text 'Member 2 In Project'
+ expect(page).to have_text "Multi user field"
+ expect(page).to have_css "opce-principal", count: 2
+ expect(page).to have_text "Member 1 In Project"
+ expect(page).to have_text "Member 2 In Project"
end
end
end
end
- describe 'with no value set by user' do
+ describe "with no value set by user" do
before do
multi_user_project_custom_field.custom_values.where(customized: project).destroy_all
end
- it 'shows an N/A text for the project custom field if no value given' do
+ it "shows an N/A text for the project custom field if no value given" do
overview_page.visit_page
overview_page.within_async_loaded_sidebar do
overview_page.within_custom_field_container(multi_user_project_custom_field) do
- expect(page).to have_text 'Multi user field'
- expect(page).to have_text I18n.t('placeholders.default')
+ expect(page).to have_text "Multi user field"
+ expect(page).to have_text I18n.t("placeholders.default")
end
end
end
diff --git a/spec/models/projects/customizable_spec.rb b/spec/models/projects/customizable_spec.rb
index 0c7a83d16be..6dc4d64fe22 100644
--- a/spec/models/projects/customizable_spec.rb
+++ b/spec/models/projects/customizable_spec.rb
@@ -96,7 +96,6 @@ RSpec.describe Project, "customizable" do
context "when custom fields are mapped to this project" do
before do
project.project_custom_fields << [text_custom_field, bool_custom_field]
- project.reload # TODO: why is this necessary?
end
it "#custom_field_values returns a hash of mapped custom fields with nil values" do