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

Refactor CustomField factories using traits

Christophe Bliarddf827db62710
diff --git a/modules/bim/spec/features/bcf/create_spec.rb b/modules/bim/spec/features/bcf/create_spec.rb
index 51fd5ea59d9..9ecccef2212 100644
--- a/modules/bim/spec/features/bcf/create_spec.rb
+++ b/modules/bim/spec/features/bcf/create_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe 'Create BCF',
create(:type, custom_fields: [integer_cf])
end
let(:integer_cf) do
- create(:int_wp_custom_field)
+ create(:integer_wp_custom_field)
end
shared_examples 'bcf details creation' do |with_viewpoints|
diff --git a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
index 3874df89d17..d44476cb058 100644
--- a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
+++ b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb
@@ -271,7 +271,7 @@ RSpec.describe API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter do
end
context 'for a custom value' do
- let(:custom_field) { build_stubbed(:text_time_entry_custom_field) }
+ let(:custom_field) { build_stubbed(:time_entry_custom_field) }
let(:path) { "customField#{custom_field.id}" }
let(:writable_attributes) { [custom_field.attribute_name] }
diff --git a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb
index f6a2ad429e0..211a71f235e 100644
--- a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb
+++ b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_parsing_spec.rb
@@ -53,10 +53,10 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'parsing' do
described_class.create(time_entry, current_user: user, embed_links: true)
end
let(:user_custom_field) do
- build_stubbed(:time_entry_custom_field, field_format: 'user')
+ build_stubbed(:time_entry_custom_field, :user)
end
- let(:test_custom_field) do
- build_stubbed(:time_entry_custom_field, field_format: 'text')
+ let(:text_custom_field) do
+ build_stubbed(:time_entry_custom_field)
end
let(:hash) do
@@ -81,7 +81,7 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'parsing' do
"raw" => "some comment"
},
"spentOn" => "2017-07-28",
- test_custom_field.attribute_name(:camel_case) => {
+ text_custom_field.attribute_name(:camel_case) => {
"raw" => "some text"
}
}
@@ -90,7 +90,7 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'parsing' do
before do
allow(time_entry)
.to receive(:available_custom_fields)
- .and_return([test_custom_field, user_custom_field])
+ .and_return([text_custom_field, user_custom_field])
end
describe '_links' do
@@ -171,7 +171,7 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'parsing' do
it 'updates the custom value' do
time_entry = representer.from_hash(hash)
- expect(time_entry.custom_field_values.detect { |cv| cv.custom_field_id == test_custom_field.id }.value)
+ expect(time_entry.custom_field_values.detect { |cv| cv.custom_field_id == text_custom_field.id }.value)
.to eql("some text")
end
end
diff --git a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
index fdbc82adca8..53e8a79a409 100644
--- a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
+++ b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb
@@ -106,7 +106,7 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do
context 'custom value' do
let(:custom_field) do
- build_stubbed(:time_entry_custom_field, field_format: 'user')
+ build_stubbed(:time_entry_custom_field, :user)
end
let(:custom_value) do
double('CustomValue',
@@ -255,7 +255,7 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do
end
context 'custom value' do
- let(:custom_field) { build_stubbed(:text_time_entry_custom_field) }
+ let(:custom_field) { build_stubbed(:time_entry_custom_field) }
let(:custom_value) do
CustomValue.new(custom_field:,
value: '1234',
diff --git a/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb b/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
index c52f6526263..6c40e51a846 100644
--- a/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
+++ b/modules/costs/spec/requests/api/time_entries/create_form_resource_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe API::V3::TimeEntries::CreateFormAPI, content_type: :json do
TimeEntryActivitiesProject.insert(project_id: project.id, activity_id: tea.id, active: false)
end
end
- let(:custom_field) { create(:text_time_entry_custom_field) }
+ let(:custom_field) { create(:time_entry_custom_field) }
let(:user) do
create(:user,
member_in_project: project,
diff --git a/modules/costs/spec/requests/api/time_entries/update_form_resource_spec.rb b/modules/costs/spec/requests/api/time_entries/update_form_resource_spec.rb
index c598118b572..d52b7d256b7 100644
--- a/modules/costs/spec/requests/api/time_entries/update_form_resource_spec.rb
+++ b/modules/costs/spec/requests/api/time_entries/update_form_resource_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe API::V3::TimeEntries::UpdateFormAPI, content_type: :json do
TimeEntryActivitiesProject.insert(project_id: project.id, activity_id: tea.id, active: false)
end
end
- let(:custom_field) { create(:text_time_entry_custom_field) }
+ let(:custom_field) { create(:time_entry_custom_field) }
let(:user) do
create(:user,
member_in_project: project,
diff --git a/modules/costs/spec/requests/api/time_entry_resource_spec.rb b/modules/costs/spec/requests/api/time_entry_resource_spec.rb
index d58d7ec13fe..2562cbab53a 100644
--- a/modules/costs/spec/requests/api/time_entry_resource_spec.rb
+++ b/modules/costs/spec/requests/api/time_entry_resource_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe 'API v3 time_entry resource' do
let(:other_project) { other_work_package.project }
let(:role) { create(:role, permissions:) }
let(:permissions) { %i(view_time_entries view_work_packages) }
- let(:custom_field) { create(:text_time_entry_custom_field) }
+ let(:custom_field) { create(:time_entry_custom_field) }
let(:custom_value) do
CustomValue.create(custom_field:,
value: '1234',
diff --git a/modules/dashboards/spec/features/project_details_spec.rb b/modules/dashboards/spec/features/project_details_spec.rb
index 79bfda16dbe..b5fc763ea74 100644
--- a/modules/dashboards/spec/features/project_details_spec.rb
+++ b/modules/dashboards/spec/features/project_details_spec.rb
@@ -32,9 +32,9 @@ require_relative '../support/pages/dashboard'
RSpec.describe 'Project details widget on dashboard', js: true do
let!(:version_cf) { create(:version_project_custom_field) }
- let!(:bool_cf) { create(:bool_project_custom_field) }
+ let!(:bool_cf) { create(:boolean_project_custom_field) }
let!(:user_cf) { create(:user_project_custom_field) }
- let!(:int_cf) { create(:int_project_custom_field) }
+ let!(:int_cf) { create(:integer_project_custom_field) }
let!(:float_cf) { create(:float_project_custom_field) }
let!(:text_cf) { create(:text_project_custom_field) }
let!(:string_cf) { create(:string_project_custom_field) }
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index f07bf42ee87..87041606b06 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -98,7 +98,7 @@ RSpec.describe 'My page time entries current user widget spec', js: true do
hours: 4)
end
let!(:custom_field) do
- create(:time_entry_custom_field, field_format: 'text')
+ create(:time_entry_custom_field)
end
let(:other_user) do
create(:user)
diff --git a/spec/contracts/projects/shared_contract_examples.rb b/spec/contracts/projects/shared_contract_examples.rb
index 53128e6e6fe..f2da795a04a 100644
--- a/spec/contracts/projects/shared_contract_examples.rb
+++ b/spec/contracts/projects/shared_contract_examples.rb
@@ -262,8 +262,8 @@ RSpec.shared_examples_for 'project contract' do
end
describe 'available_custom_fields' do
- let(:visible_custom_field) { build_stubbed(:int_project_custom_field, visible: true) }
- let(:invisible_custom_field) { build_stubbed(:int_project_custom_field, visible: false) }
+ let(:visible_custom_field) { build_stubbed(:integer_project_custom_field, visible: true) }
+ let(:invisible_custom_field) { build_stubbed(:integer_project_custom_field, visible: false) }
before do
allow(project)
@@ -280,14 +280,14 @@ RSpec.shared_examples_for 'project contract' do
it 'returns all available_custom_fields of the project' do
expect(subject.available_custom_fields)
- .to match_array([visible_custom_field, invisible_custom_field])
+ .to contain_exactly(visible_custom_field, invisible_custom_field)
end
end
context 'if the user is no admin' do
it 'returns all visible and available_custom_fields of the project' do
expect(subject.available_custom_fields)
- .to match_array([visible_custom_field])
+ .to contain_exactly(visible_custom_field)
end
end
end
diff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rb
index d962f805b5f..572c2305ae7 100644
--- a/spec/controllers/my_controller_spec.rb
+++ b/spec/controllers/my_controller_spec.rb
@@ -121,7 +121,7 @@ RSpec.describe MyController do
end
describe 'account' do
- let(:custom_field) { create(:text_user_custom_field) }
+ let(:custom_field) { create(:user_custom_field, :text) }
before do
custom_field
diff --git a/spec/controllers/work_packages/bulk_controller_spec.rb b/spec/controllers/work_packages/bulk_controller_spec.rb
index 0ac16f7271b..d66d9aad002 100644
--- a/spec/controllers/work_packages/bulk_controller_spec.rb
+++ b/spec/controllers/work_packages/bulk_controller_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe WorkPackages::BulkController, with_settings: { journal_aggregatio
is_for_all: true)
end
let(:custom_field2) { create(:work_package_custom_field) }
- let(:custom_field_user) { create(:user_issue_custom_field) }
+ let(:custom_field_user) { create(:issue_custom_field, :user) }
let(:status) { create(:status) }
let(:type) do
create(:type_standard,
diff --git a/spec/factories/custom_field_factory.rb b/spec/factories/custom_field_factory.rb
index deaa85ca4f9..44c88e2c787 100644
--- a/spec/factories/custom_field_factory.rb
+++ b/spec/factories/custom_field_factory.rb
@@ -28,7 +28,20 @@
FactoryBot.define do
factory :custom_field do
- name { 'Custom Field' }
+ transient do
+ # These values are used internally to customize the custom field name
+ # when using traits. They are not meant to be set externally.
+ _format_name do
+ [
+ multi_value ? 'multi-' : nil,
+ field_format
+ ].compact.join
+ end
+ _type_name { instance.class.name.underscore.humanize(capitalize: false) }
+ end
+ sequence(:name) do |n, _e|
+ [_format_name, _type_name, n.to_s].join(' ').capitalize
+ end
regexp { '' }
is_required { false }
min_length { false }
@@ -39,12 +52,13 @@ FactoryBot.define do
visible { true }
field_format { 'bool' }
- callback(:after_create) do
+ after(:create) do
# As the request store keeps track of the created custom fields
RequestStore.clear!
end
trait :boolean do
+ _format_name { 'boolean' }
field_format { 'bool' }
end
@@ -56,7 +70,8 @@ FactoryBot.define do
field_format { 'text' }
end
- trait :int do
+ trait :integer do
+ _format_name { 'integer' }
field_format { 'int' }
end
@@ -143,141 +158,23 @@ FactoryBot.define do
end
factory :project_custom_field, class: 'ProjectCustomField' do
- sequence(:name) { |n| "Project custom field #{n}" }
-
- factory :list_project_custom_field do
- sequence(:name) { |n| "List project custom field #{n}" }
- multi_value { false }
- field_format { 'list' }
- possible_values { ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }
- end
-
- factory :version_project_custom_field do
- sequence(:name) { |n| "Version project custom field #{n}" }
- field_format { 'version' }
- end
-
- factory :bool_project_custom_field do
- sequence(:name) { |n| "Bool project custom field #{n}" }
- field_format { 'bool' }
- end
-
- factory :user_project_custom_field do
- sequence(:name) { |n| "User project custom field #{n}" }
- field_format { 'user' }
- end
-
- factory :int_project_custom_field do
- sequence(:name) { |n| "Int project custom field #{n}" }
- field_format { 'int' }
- end
-
- factory :float_project_custom_field do
- sequence(:name) { |n| "Float project custom field #{n}" }
- field_format { 'float' }
- end
-
- factory :text_project_custom_field do
- sequence(:name) { |n| "Text project custom field #{n}" }
- field_format { 'text' }
- end
-
- factory :string_project_custom_field do
- sequence(:name) { |n| "String project custom field #{n}" }
- field_format { 'string' }
- end
-
- factory :date_project_custom_field do
- sequence(:name) { |n| "Date project custom field #{n}" }
- field_format { 'date' }
- end
- end
-
- factory :user_custom_field, class: 'UserCustomField' do
- sequence(:name) { |n| "User Custom Field #{n}" }
- type { 'UserCustomField' }
-
- factory :boolean_user_custom_field do
- name { 'BooleanUserCustomField' }
- field_format { 'bool' }
- end
-
- factory :integer_user_custom_field do
- name { 'IntegerUserCustomField' }
- field_format { 'int' }
- end
-
- factory :text_user_custom_field do
- name { 'TextUserCustomField' }
- field_format { 'text' }
- end
-
- factory :string_user_custom_field do
- name { 'StringUserCustomField' }
- field_format { 'string' }
- end
-
- factory :float_user_custom_field do
- name { 'FloatUserCustomField' }
- field_format { 'float' }
- end
-
- factory :list_user_custom_field do
- name { 'ListUserCustomField' }
- field_format { 'list' }
- possible_values { ['1', '2', '3', '4', '5', '6', '7'] }
- end
-
- factory :date_user_custom_field do
- name { 'DateUserCustomField' }
- field_format { 'date' }
- end
+ factory :boolean_project_custom_field, traits: [:boolean]
+ factory :string_project_custom_field, traits: [:string]
+ factory :text_project_custom_field, traits: [:text]
+ factory :integer_project_custom_field, traits: [:integer]
+ factory :float_project_custom_field, traits: [:float]
+ factory :date_project_custom_field, traits: [:date]
+ factory :list_project_custom_field, traits: [:list]
+ factory :version_project_custom_field, traits: [:version]
+ factory :user_project_custom_field, traits: [:user]
end
- factory :group_custom_field, class: 'GroupCustomField' do
- sequence(:name) { |n| "User Custom Field #{n}" }
- type { 'GroupCustomField' }
-
- factory :boolean_group_custom_field do
- name { 'BooleanGroupCustomField' }
- field_format { 'bool' }
- end
-
- factory :integer_group_custom_field do
- name { 'IntegerGroupCustomField' }
- field_format { 'int' }
- end
-
- factory :text_group_custom_field do
- name { 'TextGroupCustomField' }
- field_format { 'text' }
- end
-
- factory :string_group_custom_field do
- name { 'StringGroupCustomField' }
- field_format { 'string' }
- end
+ factory :user_custom_field, class: 'UserCustomField'
- factory :float_group_custom_field do
- name { 'FloatGroupCustomField' }
- field_format { 'float' }
- end
-
- factory :list_group_custom_field do
- name { 'ListGroupCustomField' }
- field_format { 'list' }
- possible_values { ['1', '2', '3', '4', '5', '6', '7'] }
- end
-
- factory :date_group_custom_field do
- name { 'DateGroupCustomField' }
- field_format { 'date' }
- end
- end
+ factory :group_custom_field, class: 'GroupCustomField'
factory :wp_custom_field, class: 'WorkPackageCustomField' do
- sequence(:name) { |n| "Work package custom field #{n}" }
- type { 'WorkPackageCustomField' }
+ _type_name { 'WP custom field' }
is_filter { true }
transient do
@@ -288,134 +185,29 @@ FactoryBot.define do
evaluator.projects.each do |project|
project.work_package_custom_fields << custom_field
end
-
- if evaluator.projects.any? || evaluator.types.any?
- # As the request store keeps track of the available custom fields of work packages
- RequestStore.clear!
- end
- end
-
- factory :list_wp_custom_field do
- sequence(:name) { |n| "List CF #{n}" }
- field_format { 'list' }
- possible_values { ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }
- end
-
- factory :version_wp_custom_field do
- sequence(:name) { |n| "Version WP custom field #{n}" }
- field_format { 'version' }
- end
-
- factory :bool_wp_custom_field do
- sequence(:name) { |n| "Bool WP custom field #{n}" }
- field_format { 'bool' }
- end
-
- factory :user_wp_custom_field do
- sequence(:name) { |n| "User WP custom field #{n}" }
- field_format { 'user' }
- end
-
- factory :int_wp_custom_field do
- sequence(:name) { |n| "Int WP custom field #{n}" }
- field_format { 'int' }
- end
-
- factory :float_wp_custom_field do
- sequence(:name) { |n| "Float WP custom field #{n}" }
- field_format { 'float' }
- end
-
- factory :text_wp_custom_field do
- sequence(:name) { |n| "Text WP custom field #{n}" }
- field_format { 'text' }
- end
-
- factory :string_wp_custom_field do
- sequence(:name) { |n| "String WP custom field #{n}" }
- field_format { 'string' }
end
- factory :date_wp_custom_field do
- sequence(:name) { |n| "Date WP custom field #{n}" }
- field_format { 'date' }
- end
+ factory :boolean_wp_custom_field, traits: [:boolean]
+ factory :string_wp_custom_field, traits: [:string]
+ factory :text_wp_custom_field, traits: [:text]
+ factory :integer_wp_custom_field, traits: [:integer]
+ factory :float_wp_custom_field, traits: [:float]
+ factory :date_wp_custom_field, traits: [:date]
+ factory :list_wp_custom_field, traits: [:list]
+ factory :version_wp_custom_field, traits: [:version]
+ factory :user_wp_custom_field, traits: [:user]
end
factory :issue_custom_field, class: 'WorkPackageCustomField' do
- sequence(:name) { |n| "Issue Custom Field #{n}" }
-
- factory :user_issue_custom_field do
- field_format { 'user' }
- sequence(:name) { |n| "UserWorkPackageCustomField #{n}" }
- end
-
- factory :text_issue_custom_field do
- field_format { 'text' }
- sequence(:name) { |n| "TextWorkPackageCustomField #{n}" }
- end
-
- factory :integer_issue_custom_field do
- field_format { 'int' }
- sequence(:name) { |n| "IntegerWorkPackageCustomField #{n}" }
- end
+ _type_name { 'issue custom field' }
end
factory :time_entry_custom_field, class: 'TimeEntryCustomField' do
- sequence(:name) { |n| "User Custom Field #{n}" }
- type { 'TimeEntryCustomField' }
-
- factory :boolean_time_entry_custom_field do
- name { 'BooleanTimeEntryCustomField' }
- field_format { 'bool' }
- end
-
- factory :integer_time_entry_custom_field do
- name { 'IntegerTimeEntryCustomField' }
- field_format { 'int' }
- end
-
- factory :text_time_entry_custom_field do
- name { 'TextTimeEntryCustomField' }
- field_format { 'text' }
- end
-
- factory :string_time_entry_custom_field do
- name { 'StringTimeEntryCustomField' }
- field_format { 'string' }
- end
-
- factory :float_time_entry_custom_field do
- name { 'FloatTimeEntryCustomField' }
- field_format { 'float' }
- end
-
- factory :list_time_entry_custom_field do
- name { 'ListTimeEntryCustomField' }
- field_format { 'list' }
- possible_values { ['A', 'B'] }
- end
-
- factory :date_time_entry_custom_field do
- name { 'DateTimeEntryCustomField' }
- field_format { 'date' }
- end
+ field_format { 'text' }
end
factory :version_custom_field, class: 'VersionCustomField' do
field_format { 'text' }
- sequence(:name) { |n| "Version Custom Field #{n}" }
-
- factory :int_version_custom_field do
- sequence(:name) { |n| "Int version custom field #{n}" }
- field_format { 'int' }
- end
-
- factory :list_version_custom_field do
- sequence(:name) { |n| "List version custom field #{n}" }
- field_format { 'list' }
- possible_values { ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }
- end
end
end
end
diff --git a/spec/features/activities/project_attributes_activity_spec.rb b/spec/features/activities/project_attributes_activity_spec.rb
index 26e9fd9abad..29d88f90f1e 100644
--- a/spec/features/activities/project_attributes_activity_spec.rb
+++ b/spec/features/activities/project_attributes_activity_spec.rb
@@ -35,9 +35,9 @@ RSpec.describe 'Project attributes activity', :js, :with_cuprite do
let!(:list_project_custom_field) { create(:list_project_custom_field) }
let!(:version_project_custom_field) { create(:version_project_custom_field) }
- let!(:bool_project_custom_field) { create(:bool_project_custom_field) }
+ let!(:bool_project_custom_field) { create(:boolean_project_custom_field) }
let!(:user_project_custom_field) { create(:user_project_custom_field) }
- let!(:int_project_custom_field) { create(:int_project_custom_field) }
+ let!(:int_project_custom_field) { create(:integer_project_custom_field) }
let!(:float_project_custom_field) { create(:float_project_custom_field) }
let!(:text_project_custom_field) { create(:text_project_custom_field) }
let!(:string_project_custom_field) { create(:string_project_custom_field) }
diff --git a/spec/features/custom_fields/activate_in_project_spec.rb b/spec/features/custom_fields/activate_in_project_spec.rb
index 25cfa4ad2bf..8b495c40159 100644
--- a/spec/features/custom_fields/activate_in_project_spec.rb
+++ b/spec/features/custom_fields/activate_in_project_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe 'custom fields', js: true, with_cuprite: true do
let(:user) { create(:admin) }
let(:cf_page) { Pages::CustomFields.new }
let(:for_all_cf) { create(:list_wp_custom_field, is_for_all: true) }
- let(:project_specific_cf) { create(:int_wp_custom_field) }
+ let(:project_specific_cf) { create(:integer_wp_custom_field) }
let(:work_package) do
wp = build(:work_package).tap do |wp|
wp.type.custom_fields = [for_all_cf, project_specific_cf]
diff --git a/spec/features/projects/projects_custom_fields_spec.rb b/spec/features/projects/projects_custom_fields_spec.rb
index c9bd37c680c..045f2e96694 100644
--- a/spec/features/projects/projects_custom_fields_spec.rb
+++ b/spec/features/projects/projects_custom_fields_spec.rb
@@ -63,7 +63,7 @@ RSpec.describe 'Projects custom fields',
describe 'with default values' do
let!(:default_int_custom_field) do
- create(:int_project_custom_field, default_value: 123)
+ create(:integer_project_custom_field, default_value: 123)
end
let!(:default_string_custom_field) do
create(:string_project_custom_field, default_value: 'lorem')
@@ -195,7 +195,7 @@ RSpec.describe 'Projects custom fields',
describe 'with boolean CF' do
let!(:custom_field) do
- create(:bool_project_custom_field)
+ create(:boolean_project_custom_field)
end
it 'allows settings the project boolean CF (regression #26313)' do
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index 10546466799..deba2f66446 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -950,7 +950,7 @@ RSpec.describe 'Projects index page',
end
describe 'order', with_ee: %i[custom_fields_in_projects_list] do
- shared_let(:integer_custom_field) { create(:int_project_custom_field) }
+ shared_let(:integer_custom_field) { create(:integer_project_custom_field) }
# order is important here as the implementation uses lft
# first but then reorders in ruby
shared_let(:child_project_z) do
diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb
index 777f7601a79..1d7f2c550d6 100644
--- a/spec/features/types/form_configuration_spec.rb
+++ b/spec/features/types/form_configuration_spec.rb
@@ -244,7 +244,7 @@ RSpec.describe 'form configuration', js: true do
describe 'required custom field' do
let(:custom_fields) { [custom_field] }
- let(:custom_field) { create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') }
+ let(:custom_field) { create(:issue_custom_field, :integer, is_required: true, name: 'MyNumber') }
let(:cf_identifier) { custom_field.attribute_name }
let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }
@@ -274,7 +274,7 @@ RSpec.describe 'form configuration', js: true do
let(:project_settings_page) { Pages::Projects::Settings.new(project) }
let(:custom_fields) { [custom_field] }
- let(:custom_field) { create(:integer_issue_custom_field, name: 'MyNumber') }
+ let(:custom_field) { create(:issue_custom_field, :integer, name: 'MyNumber') }
let(:cf_identifier) { custom_field.attribute_name }
let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }
diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb
index 3499a01e0f4..fb8cbf5b88b 100644
--- a/spec/features/types/reset_form_configuration_spec.rb
+++ b/spec/features/types/reset_form_configuration_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe 'Reset form configuration', js: true do
describe "with EE token and CFs", with_ee: %i[edit_attribute_groups] do
let(:custom_fields) { [custom_field] }
- let(:custom_field) { create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') }
+ let(:custom_field) { create(:issue_custom_field, :integer, is_required: true, name: 'MyNumber') }
let(:cf_identifier) { custom_field.attribute_name }
let(:cf_identifier_api) { cf_identifier.camelcase(:lower) }
diff --git a/spec/features/users/invite_user_modal/custom_fields_spec.rb b/spec/features/users/invite_user_modal/custom_fields_spec.rb
index 6896d26b27e..285d7231310 100644
--- a/spec/features/users/invite_user_modal/custom_fields_spec.rb
+++ b/spec/features/users/invite_user_modal/custom_fields_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-RSpec.describe 'Invite user modal custom fields', js: true, with_cuprite: true do
+RSpec.describe 'Invite user modal custom fields', :js, :with_cuprite do
shared_let(:project) { create(:project) }
let(:permissions) { %i[view_project manage_members] }
@@ -45,16 +45,16 @@ RSpec.describe 'Invite user modal custom fields', js: true, with_cuprite: true d
permissions:)
end
- let!(:boolean_cf) { create(:boolean_user_custom_field, name: 'bool', is_required: true) }
- let!(:integer_cf) { create(:integer_user_custom_field, name: 'int', is_required: true) }
- let!(:text_cf) { create(:text_user_custom_field, name: 'Text', is_required: true) }
- let!(:string_cf) { create(:string_user_custom_field, name: 'String', is_required: true) }
+ let!(:boolean_cf) { create(:user_custom_field, :boolean, name: 'bool', is_required: true) }
+ let!(:integer_cf) { create(:user_custom_field, :integer, name: 'int', is_required: true) }
+ let!(:text_cf) { create(:user_custom_field, :text, name: 'Text', is_required: true) }
+ let!(:string_cf) { create(:user_custom_field, :string, name: 'String', is_required: true) }
# TODO float not supported yet
- # let!(:float_cf) { create :float_user_custom_field, name: 'Float', is_required: true }
- let!(:list_cf) { create(:list_user_custom_field, name: 'List', is_required: true) }
- let!(:list_multi_cf) { create(:list_user_custom_field, name: 'Multi list', multi_value: true, is_required: true) }
+ # let!(:float_cf) { create :user_custom_field, :float, name: 'Float', is_required: true }
+ let!(:list_cf) { create(:user_custom_field, :list, name: 'List', is_required: true) }
+ let!(:list_multi_cf) { create(:user_custom_field, :list, name: 'Multi list', multi_value: true, is_required: true) }
- let!(:non_req_cf) { create(:string_user_custom_field, name: 'non req', is_required: false) }
+ let!(:non_req_cf) { create(:user_custom_field, :string, name: 'non req', is_required: false) }
let(:boolean_field) { FormFields::InputFormField.new boolean_cf }
let(:integer_field) { FormFields::InputFormField.new integer_cf }
@@ -113,8 +113,8 @@ RSpec.describe 'Invite user modal custom fields', js: true, with_cuprite: true d
text_field.set_value 'A **markdown** value'
string_field.set_value 'String value'
- list_field.select_option '1'
- list_multi_field.select_option '1', '2'
+ list_field.select_option 'A'
+ list_multi_field.select_option 'A', 'B'
modal.click_next
@@ -135,7 +135,7 @@ RSpec.describe 'Invite user modal custom fields', js: true, with_cuprite: true d
expect(invited.custom_value_for(integer_cf).typed_value).to eq 1234
expect(invited.custom_value_for(text_cf).typed_value).to eq 'A **markdown** value'
expect(invited.custom_value_for(string_cf).typed_value).to eq 'String value'
- expect(invited.custom_value_for(list_cf).typed_value).to eq '1'
- expect(invited.custom_value_for(list_multi_cf).map(&:typed_value)).to eq %w[1 2]
+ expect(invited.custom_value_for(list_cf).typed_value).to eq 'A'
+ expect(invited.custom_value_for(list_multi_cf).map(&:typed_value)).to eq %w[A B]
end
end
diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb
index 994853e257f..e35f97035de 100644
--- a/spec/features/work_packages/bulk/move_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/move_work_package_spec.rb
@@ -146,7 +146,7 @@ RSpec.describe 'Moving a work package through Rails view', js: true do
end
context 'when the target project has a type with a required field' do
- let(:required_cf) { create(:int_wp_custom_field, is_required: true) }
+ let(:required_cf) { create(:integer_wp_custom_field, is_required: true) }
let(:type2) { create(:type, name: 'Risk', custom_fields: [required_cf]) }
let!(:project2) { create(:project, name: 'Target', types: [type2], work_package_custom_fields: [required_cf]) }
diff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
index 936a4c56f8e..2c8bca8592a 100644
--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb
+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe 'Custom actions',
cf
end
let!(:int_custom_field) do
- create(:int_wp_custom_field)
+ create(:integer_wp_custom_field)
end
let(:selected_list_custom_field_options) do
[list_custom_field.custom_options.first, list_custom_field.custom_options.last]
diff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
index 6bb73cdc63c..ceeb3586bab 100644
--- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
+++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe 'custom field inplace editor', js: true do
describe 'long text' do
let(:custom_field) do
- create(:text_issue_custom_field, name: 'LongText')
+ create(:issue_custom_field, :text, name: 'LongText')
end
let(:field) { TextEditorField.new wp_page, property_name }
let(:initial_custom_values) { { custom_field.id => 'foo' } }
@@ -124,7 +124,7 @@ RSpec.describe 'custom field inplace editor', js: true do
describe 'integer type' do
let(:custom_field) do
- create(:integer_issue_custom_field, args.merge(name: 'MyNumber'))
+ create(:issue_custom_field, :integer, args.merge(name: 'MyNumber'))
end
let(:initial_custom_values) { { custom_field.id => 123 } }
diff --git a/spec/features/work_packages/index_sums_spec.rb b/spec/features/work_packages/index_sums_spec.rb
index 6890db35afb..817cb77959b 100644
--- a/spec/features/work_packages/index_sums_spec.rb
+++ b/spec/features/work_packages/index_sums_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe 'Work package index sums', js: true do
end
let(:type) { create(:type) }
let!(:int_cf) do
- create(:int_wp_custom_field).tap do |cf|
+ create(:integer_wp_custom_field) do |cf|
project.work_package_custom_fields << cf
type.custom_fields << cf
end
diff --git a/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb b/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
index e5f5a280853..d6e88bc981a 100644
--- a/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
+++ b/spec/features/work_packages/table/baseline/baseline_rendering_spec.rb
@@ -35,9 +35,9 @@ RSpec.describe 'baseline rendering',
shared_let(:list_wp_custom_field) { create(:list_wp_custom_field) }
shared_let(:multi_list_wp_custom_field) { create(:list_wp_custom_field, multi_value: true) }
shared_let(:version_wp_custom_field) { create(:version_wp_custom_field) }
- shared_let(:bool_wp_custom_field) { create(:bool_wp_custom_field) }
+ shared_let(:bool_wp_custom_field) { create(:boolean_wp_custom_field) }
shared_let(:user_wp_custom_field) { create(:user_wp_custom_field) }
- shared_let(:int_wp_custom_field) { create(:int_wp_custom_field) }
+ shared_let(:int_wp_custom_field) { create(:integer_wp_custom_field) }
shared_let(:float_wp_custom_field) { create(:float_wp_custom_field) }
shared_let(:string_wp_custom_field) { create(:string_wp_custom_field) }
shared_let(:date_wp_custom_field) { create(:date_wp_custom_field) }
diff --git a/spec/features/work_packages/table/group_by/group_by_boolean_spec.rb b/spec/features/work_packages/table/group_by/group_by_boolean_spec.rb
index f1270954fe3..79a3bae09a9 100644
--- a/spec/features/work_packages/table/group_by/group_by_boolean_spec.rb
+++ b/spec/features/work_packages/table/group_by/group_by_boolean_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe 'Work Package group by boolean field', js: true do
let(:user) { create(:admin) }
let(:project) { create(:project, types: [type], work_package_custom_fields: [bool_cf]) }
- let(:bool_cf) { create(:bool_wp_custom_field, name: 'booleanField', types: [type]) }
+ let(:bool_cf) { create(:boolean_wp_custom_field, name: 'booleanField', types: [type]) }
let(:type) { create(:type) }
let!(:wp1) { create(:work_package, project:, type:) }
diff --git a/spec/features/work_packages/table/queries/bool_cf_filter_spec.rb b/spec/features/work_packages/table/queries/bool_cf_filter_spec.rb
index ec8ef280076..582398da0c7 100644
--- a/spec/features/work_packages/table/queries/bool_cf_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/bool_cf_filter_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe 'Work package filtering by bool custom field', js: true do
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:filters) { Components::WorkPackages::Filters.new }
let!(:bool_cf) do
- create(:bool_wp_custom_field).tap do |cf|
+ create(:boolean_wp_custom_field) do |cf|
type.custom_fields << cf
project.work_package_custom_fields << cf
end
@@ -43,7 +43,7 @@ RSpec.describe 'Work package filtering by bool custom field', js: true do
let!(:work_package_true) do
create(:work_package,
type:,
- project:).tap do |wp|
+ project:) do |wp|
wp.custom_field_values = { bool_cf.id => true }
wp.save!
end
@@ -51,7 +51,7 @@ RSpec.describe 'Work package filtering by bool custom field', js: true do
let!(:work_package_false) do
create(:work_package,
type:,
- project:).tap do |wp|
+ project:) do |wp|
wp.custom_field_values = { bool_cf.id => false }
wp.save!
end
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index d0da27a9f15..476a21fd984 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -131,21 +131,21 @@ RSpec.describe UsersHelper do
end
context 'when user has a custom field with a present value' do
- let(:custom_field) { create(:string_user_custom_field) }
+ let(:custom_field) { create(:user_custom_field, :string) }
let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: 'Hello')]) }
it { is_expected.to be(true) }
end
context 'when user has a custom field with a blank value' do
- let(:custom_field) { create(:string_user_custom_field) }
+ let(:custom_field) { create(:user_custom_field, :string) }
let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: ' ')]) }
it { is_expected.to be(false) }
end
context 'when user has a non-visible custom field with a present value' do
- let(:custom_field) { create(:string_user_custom_field, visible: false) }
+ let(:custom_field) { create(:user_custom_field, :string, visible: false) }
let(:user) { build(:user, custom_values: [build(:custom_value, custom_field:, value: 'Hello')]) }
it { is_expected.to be(false) }
diff --git a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
index 4640c1e4344..c79090f6aad 100644
--- a/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/projects/project_representer_rendering_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, 'rendering' do
end
end
- let(:int_custom_field) { build_stubbed(:int_project_custom_field, visible: false) }
+ let(:int_custom_field) { build_stubbed(:integer_project_custom_field, visible: false) }
let(:version_custom_field) { build_stubbed(:version_project_custom_field, visible: true) }
let(:int_custom_value) do
CustomValue.new(custom_field: int_custom_field,
@@ -643,7 +643,7 @@ RSpec.describe API::V3::Projects::ProjectRepresenter, 'rendering' do
describe '.checked_permissions' do
it 'lists add_work_packages' do
- expect(described_class.checked_permissions).to match_array([:add_work_packages])
+ expect(described_class.checked_permissions).to contain_exactly(:add_work_packages)
end
end
end
diff --git a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
index 6f3eca2f989..6fe3e973098 100644
--- a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
+++ b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe API::V3::Projects::Schemas::ProjectSchemaRepresenter do
let(:new_record) { true }
let(:model_id) { 1 }
let(:custom_field) do
- build_stubbed(:int_project_custom_field)
+ build_stubbed(:integer_project_custom_field)
end
let(:allowed_status) { ['some status'] }
let(:contract) do
diff --git a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
index 73da8756ab0..dd9bb59b551 100644
--- a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
+++ b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
@@ -205,7 +205,7 @@ RSpec.describe API::V3::Queries::Filters::QueryFilterInstanceRepresenter do
end
context 'with a bool custom field filter' do
- let(:bool_cf) { create(:bool_wp_custom_field) }
+ let(:bool_cf) { create(:boolean_wp_custom_field) }
let(:filter) do
Queries::WorkPackages::Filter::CustomFieldFilter.create!(name: bool_cf.column_name, operator:, values:)
end
diff --git a/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb
index 2e7fccf2374..b71965a88bb 100644
--- a/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb
+++ b/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter do
include API::V3::Utilities::PathHelper
let(:project) { build_stubbed(:project) }
- let(:bool_cf) { build_stubbed(:bool_wp_custom_field) }
+ let(:bool_cf) { build_stubbed(:boolean_wp_custom_field) }
let(:filter) do
Queries::WorkPackages::Filter::CustomFieldFilter.from_custom_field! custom_field: bool_cf,
context: project
diff --git a/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb b/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb
index 997eec423ac..a415bdc7ef6 100644
--- a/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb
+++ b/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do
end
context 'type int' do
- let(:custom_field) { build_stubbed(:int_wp_custom_field) }
+ let(:custom_field) { build_stubbed(:integer_wp_custom_field) }
it 'is the integer dependency' do
expect(subject).to be_a(API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter)
@@ -160,7 +160,7 @@ RSpec.describe API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do
end
context 'type bool' do
- let(:custom_field) { build_stubbed(:bool_wp_custom_field) }
+ let(:custom_field) { build_stubbed(:boolean_wp_custom_field) }
it 'is the boolean filter dependency' do
expect(subject).to be_a(API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter)
diff --git a/spec/lib/api/v3/versions/schemas/version_schema_representer_spec.rb b/spec/lib/api/v3/versions/schemas/version_schema_representer_spec.rb
index 1ca23181970..ce62da65d46 100644
--- a/spec/lib/api/v3/versions/schemas/version_schema_representer_spec.rb
+++ b/spec/lib/api/v3/versions/schemas/version_schema_representer_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe API::V3::Versions::Schemas::VersionSchemaRepresenter do
let(:allowed_sharings) { %w(tree system) }
let(:allowed_status) { %w(open fixed closed) }
let(:custom_field) do
- build_stubbed(:int_version_custom_field)
+ build_stubbed(:version_custom_field, :integer)
end
let(:version) { build_stubbed(:version) }
diff --git a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb b/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
index 4e94dbe91b1..32eea69e983 100644
--- a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
@@ -132,7 +132,7 @@ RSpec.describe API::V3::Versions::VersionRepresenter, 'rendering' do
end
context 'custom value' do
- let(:custom_field) { build_stubbed(:list_version_custom_field) }
+ let(:custom_field) { build_stubbed(:version_custom_field, :list) }
let(:custom_value) do
build_stubbed(:custom_value, custom_field:, value: '1')
end
diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
index 6fa86bf4b73..8f332fab8d3 100644
--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
@@ -1053,7 +1053,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
describe 'custom fields' do
- let(:available_custom_fields) { [build_stubbed(:int_wp_custom_field)] }
+ let(:available_custom_fields) { [build_stubbed(:integer_wp_custom_field)] }
it 'uses a CustomFieldInjector' do
allow(API::V3::Utilities::CustomFieldInjector).to receive(:create_schema_representer)
diff --git a/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb
index e084e8784e2..686d86d7edf 100644
--- a/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSumsSchemaRepresenter do
include API::V3::Utilities::PathHelper
- let(:custom_field) { build_stubbed(:integer_issue_custom_field) }
+ let(:custom_field) { build_stubbed(:issue_custom_field, :integer) }
let(:available_custom_fields) { [custom_field] }
let(:schema) { double('wp_schema', available_custom_fields:) }
let(:current_user) { double('user', admin?: false) }
diff --git a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
index 26a4979ff29..a1a4dd3697d 100644
--- a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
@@ -447,7 +447,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
describe 'custom fields' do
- let(:available_custom_fields) { [build_stubbed(:int_wp_custom_field)] }
+ let(:available_custom_fields) { [build_stubbed(:integer_wp_custom_field)] }
it 'uses a CustomFieldInjector' do
allow(API::V3::Utilities::CustomFieldInjector).to receive(:create_value_representer)
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index 63fb3b53976..42e5e63cf87 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -423,7 +423,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter do
end
describe 'custom fields' do
- let(:available_custom_fields) { [build_stubbed(:int_wp_custom_field)] }
+ let(:available_custom_fields) { [build_stubbed(:integer_wp_custom_field)] }
it 'uses a CustomFieldInjector' do
allow(API::V3::Utilities::CustomFieldInjector).to receive(:create_value_representer).and_call_original
diff --git a/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb
index 4dde3cb81b9..f7d753e4e69 100644
--- a/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
RSpec.describe API::V3::WorkPackages::WorkPackageSumsRepresenter do
let(:custom_field) do
- build_stubbed(:int_wp_custom_field, id: 1).tap do |cf|
+ build_stubbed(:integer_wp_custom_field, id: 1) do |cf|
allow(WorkPackageCustomField)
.to receive(:summable)
.and_return([cf])
diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rb
index 508020fbd8e..b78689299a6 100644
--- a/spec/models/custom_actions/actions/custom_field_spec.rb
+++ b/spec/models/custom_actions/actions/custom_field_spec.rb
@@ -44,13 +44,13 @@ RSpec.describe CustomActions::Actions::CustomField do
build_stubbed(:version_wp_custom_field)
end
let(:bool_custom_field) do
- build_stubbed(:bool_wp_custom_field)
+ build_stubbed(:boolean_wp_custom_field)
end
let(:user_custom_field) do
build_stubbed(:user_wp_custom_field)
end
let(:int_custom_field) do
- build_stubbed(:int_wp_custom_field)
+ build_stubbed(:integer_wp_custom_field)
end
let(:float_custom_field) do
build_stubbed(:float_wp_custom_field)
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb
index 7304c1853a8..eba60dbf100 100644
--- a/spec/models/custom_field_spec.rb
+++ b/spec/models/custom_field_spec.rb
@@ -241,8 +241,7 @@ RSpec.describe CustomField do
context 'for a project' do
it 'is a list of name, id pairs' do
expect(field.possible_values_options(project))
- .to match_array [[user1.name, user1.id.to_s],
- [user2.name, user2.id.to_s]]
+ .to contain_exactly([user1.name, user1.id.to_s], [user2.name, user2.id.to_s])
end
end
@@ -251,15 +250,14 @@ RSpec.describe CustomField do
object = OpenStruct.new(project:) # rubocop:disable Style/OpenStructUse
expect(field.possible_values_options(object))
- .to match_array [[user1.name, user1.id.to_s],
- [user2.name, user2.id.to_s]]
+ .to contain_exactly([user1.name, user1.id.to_s], [user2.name, user2.id.to_s])
end
end
context 'for nil' do
it 'returns all principles visible to me' do
expect(field.possible_values_options)
- .to match_array [[user2.name, user2.id.to_s]]
+ .to contain_exactly([user2.name, user2.id.to_s])
end
end
end
@@ -276,8 +274,7 @@ RSpec.describe CustomField do
it 'is a list of name, id pairs' do
expect(field.possible_values_options)
- .to match_array [[option1.value, option1.id.to_s],
- [option2.value, option2.id.to_s]]
+ .to contain_exactly([option1.value, option1.id.to_s], [option2.value, option2.id.to_s])
end
end
@@ -336,7 +333,7 @@ RSpec.describe CustomField do
it 'accepts the values' do
expect(field.possible_values.map(&:value))
- .to match_array(['One value', 'Two values'])
+ .to contain_exactly('One value', 'Two values')
end
end
@@ -347,7 +344,7 @@ RSpec.describe CustomField do
it 'accepts the values' do
expect(field.possible_values.map(&:value))
- .to match_array(['One value'])
+ .to contain_exactly('One value')
end
end
@@ -358,7 +355,7 @@ RSpec.describe CustomField do
it 'accepts the values' do
expect(field.possible_values.map(&:value))
- .to match_array(['One value', 'Two values'])
+ .to contain_exactly('One value', 'Two values')
end
end
end
@@ -422,7 +419,7 @@ RSpec.describe CustomField do
end
context 'with a wp int cf' do
- let(:field) { build_stubbed(:int_wp_custom_field) }
+ let(:field) { build_stubbed(:integer_wp_custom_field) }
it 'is true' do
expect(field)
@@ -449,7 +446,7 @@ RSpec.describe CustomField do
end
context 'with a project int cf' do
- let(:field) { build_stubbed(:int_project_custom_field) }
+ let(:field) { build_stubbed(:integer_project_custom_field) }
it 'is true' do
expect(field)
@@ -458,7 +455,7 @@ RSpec.describe CustomField do
end
context 'with a time_entry user cf' do
- let(:field) { build_stubbed(:time_entry_custom_field, field_format: 'user') }
+ let(:field) { build_stubbed(:time_entry_custom_field, :user) }
it 'is true' do
expect(field)
@@ -467,7 +464,7 @@ RSpec.describe CustomField do
end
context 'with a time_entry list cf' do
- let(:field) { build_stubbed(:time_entry_custom_field, field_format: 'list') }
+ let(:field) { build_stubbed(:time_entry_custom_field, :list) }
it 'is true' do
expect(field)
diff --git a/spec/models/custom_value_spec.rb b/spec/models/custom_value_spec.rb
index 7a6a60b3a79..5cb82c58149 100644
--- a/spec/models/custom_value_spec.rb
+++ b/spec/models/custom_value_spec.rb
@@ -191,7 +191,7 @@ RSpec.describe CustomValue do
end
context 'for an integer custom field without default value' do
- shared_let(:custom_field) { create(:project_custom_field, :int) }
+ shared_let(:custom_field) { create(:project_custom_field, :integer) }
include_examples 'returns true for generated custom value'
include_examples 'returns false for custom value with value', value: 123
@@ -202,11 +202,11 @@ RSpec.describe CustomValue do
context 'for an integer custom field with default value' do
describe 'for a generated custom value' do
it 'returns true' do
- create(:project_custom_field, :int, default_value: 0)
- create(:project_custom_field, :int, default_value: 123)
- create(:project_custom_field, :int, default_value: '456')
- create(:project_custom_field, :int, default_value: -987)
- create(:project_custom_field, :int, default_value: '-678')
+ create(:project_custom_field, :integer, default_value: 0)
+ create(:project_custom_field, :integer, default_value: 123)
+ create(:project_custom_field, :integer, default_value: '456')
+ create(:project_custom_field, :integer, default_value: -987)
+ create(:project_custom_field, :integer, default_value: '-678')
custom_values = project.custom_field_values
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 715ced69696..16bdcffb18a 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -144,6 +144,6 @@ RSpec.describe Group do
it_behaves_like 'acts_as_customizable included' do
let(:model_instance) { group }
- let(:custom_field) { create(:string_group_custom_field) }
+ let(:custom_field) { create(:group_custom_field, :string) }
end
end
diff --git a/spec/models/projects/customizable_spec.rb b/spec/models/projects/customizable_spec.rb
index fb7e5c0f385..37ef97dca6c 100644
--- a/spec/models/projects/customizable_spec.rb
+++ b/spec/models/projects/customizable_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe Project, 'customizable' do
.and_return(available_custom_fields)
end
let(:custom_values) { [] }
- let(:bool_custom_field) { build_stubbed(:bool_project_custom_field) }
+ let(:bool_custom_field) { build_stubbed(:boolean_project_custom_field) }
let(:text_custom_field) { build_stubbed(:text_project_custom_field) }
let(:list_custom_field) { build_stubbed(:list_project_custom_field) }
diff --git a/spec/models/projects/exporter/exportable_project_context.rb b/spec/models/projects/exporter/exportable_project_context.rb
index 7b902044fe4..d97b7f6bbbc 100644
--- a/spec/models/projects/exporter/exportable_project_context.rb
+++ b/spec/models/projects/exporter/exportable_project_context.rb
@@ -28,9 +28,9 @@
RSpec.shared_context 'with a project with an arrangement of custom fields' do
shared_let(:version_cf) { create(:version_project_custom_field, position: 1) }
- shared_let(:bool_cf) { create(:bool_project_custom_field, position: 2) }
+ shared_let(:bool_cf) { create(:boolean_project_custom_field, position: 2) }
shared_let(:user_cf) { create(:user_project_custom_field, position: 3) }
- shared_let(:int_cf) { create(:int_project_custom_field, position: 4) }
+ shared_let(:int_cf) { create(:integer_project_custom_field, position: 4) }
shared_let(:float_cf) { create(:float_project_custom_field, position: 5) }
shared_let(:text_cf) { create(:text_project_custom_field, position: 6) }
shared_let(:string_cf) { create(:string_project_custom_field, position: 7) }
diff --git a/spec/models/queries/projects/filters/custom_field_filter_spec.rb b/spec/models/queries/projects/filters/custom_field_filter_spec.rb
index 677325d85f0..32260526985 100644
--- a/spec/models/queries/projects/filters/custom_field_filter_spec.rb
+++ b/spec/models/queries/projects/filters/custom_field_filter_spec.rb
@@ -30,8 +30,8 @@ require 'spec_helper'
RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
let(:query) { Queries::Projects::ProjectQuery.new }
- let(:bool_project_custom_field) { build_stubbed(:bool_project_custom_field) }
- let(:int_project_custom_field) { build_stubbed(:int_project_custom_field) }
+ let(:bool_project_custom_field) { build_stubbed(:boolean_project_custom_field) }
+ let(:int_project_custom_field) { build_stubbed(:integer_project_custom_field) }
let(:float_project_custom_field) { build_stubbed(:float_project_custom_field) }
let(:text_project_custom_field) { build_stubbed(:text_project_custom_field) }
let(:user_project_custom_field) { build_stubbed(:user_project_custom_field) }
@@ -78,12 +78,9 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
before do
instance.values = ['bogus']
- end
-
- before do
allow(ProjectCustomField)
- .to receive_message_chain(:visible, :exists?)
- .and_return(true)
+ .to receive_message_chain(:visible, :exists?) # rubocop:disable RSpec/MessageChain
+ .and_return(true)
end
shared_examples_for 'custom field type dependent validity' do
@@ -303,8 +300,8 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
it 'is list for a bool' do
expect(instance.allowed_values)
- .to match_array [[I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
- [I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE]]
+ .to contain_exactly([I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
+ [I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE])
end
end
@@ -370,8 +367,7 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
it 'returns an array with custom classes' do
expect(instance.value_objects)
- .to match_array([custom_field.custom_options.last,
- custom_field.custom_options.first])
+ .to contain_exactly(custom_field.custom_options.last, custom_field.custom_options.first)
end
it 'ignores invalid values' do
@@ -379,7 +375,7 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
custom_field.custom_options.last.id]
expect(instance.value_objects)
- .to match_array([custom_field.custom_options.last])
+ .to contain_exactly(custom_field.custom_options.last)
end
end
end
@@ -432,7 +428,7 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
it 'returns an array with users' do
expect(instance.value_objects)
- .to match_array([user1, user2])
+ .to contain_exactly(user1, user2)
end
end
end
@@ -462,7 +458,7 @@ RSpec.describe Queries::Projects::Filters::CustomFieldFilter do
it 'returns an array with users' do
expect(instance.value_objects)
- .to match_array([version1, version2])
+ .to contain_exactly(version1, version2)
end
end
end
diff --git a/spec/models/queries/work_packages/filter/custom_fields/contains_text_custom_field_filter_spec.rb b/spec/models/queries/work_packages/filter/custom_fields/contains_text_custom_field_filter_spec.rb
index ff76051a5c9..fa54598d4fe 100644
--- a/spec/models/queries/work_packages/filter/custom_fields/contains_text_custom_field_filter_spec.rb
+++ b/spec/models/queries/work_packages/filter/custom_fields/contains_text_custom_field_filter_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter,
work_package_custom_fields: [custom_field])
end
let(:custom_field) do
- create(:text_issue_custom_field, name: 'LongText')
+ create(:issue_custom_field, :text, name: 'LongText')
end
let(:type) { create(:type_standard, custom_fields: [custom_field]) }
diff --git a/spec/models/queries/work_packages/filter/custom_fields/custom_field_filter_spec.rb b/spec/models/queries/work_packages/filter/custom_fields/custom_field_filter_spec.rb
index d47b9f0c1a3..a38ee6b23c0 100644
--- a/spec/models/queries/work_packages/filter/custom_fields/custom_field_filter_spec.rb
+++ b/spec/models/queries/work_packages/filter/custom_fields/custom_field_filter_spec.rb
@@ -30,8 +30,8 @@ require 'spec_helper'
RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
let(:project) { build_stubbed(:project) }
- let(:bool_wp_custom_field) { build_stubbed(:bool_wp_custom_field) }
- let(:int_wp_custom_field) { build_stubbed(:int_wp_custom_field) }
+ let(:bool_wp_custom_field) { build_stubbed(:boolean_wp_custom_field) }
+ let(:int_wp_custom_field) { build_stubbed(:integer_wp_custom_field) }
let(:float_wp_custom_field) { build_stubbed(:float_wp_custom_field) }
let(:text_wp_custom_field) { build_stubbed(:text_wp_custom_field) }
let(:user_wp_custom_field) { build_stubbed(:user_wp_custom_field) }
@@ -306,8 +306,8 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
it 'is list for a bool' do
expect(instance.allowed_values)
- .to match_array [[I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
- [I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE]]
+ .to contain_exactly([I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
+ [I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE])
end
end
@@ -415,8 +415,7 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
it 'returns an array with custom classes' do
expect(instance.value_objects)
- .to match_array([custom_field.custom_options.last,
- custom_field.custom_options.first])
+ .to contain_exactly(custom_field.custom_options.last, custom_field.custom_options.first)
end
it 'ignores invalid values' do
@@ -424,7 +423,7 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
custom_field.custom_options.last.id]
expect(instance.value_objects)
- .to match_array([custom_field.custom_options.last])
+ .to contain_exactly(custom_field.custom_options.last)
end
end
end
@@ -478,7 +477,7 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
it 'returns an array with users' do
expect(instance.value_objects)
- .to match_array([user1, user2])
+ .to contain_exactly(user1, user2)
end
end
end
@@ -508,7 +507,7 @@ RSpec.describe Queries::WorkPackages::Filter::CustomFieldFilter do
it 'returns an array with users' do
expect(instance.value_objects)
- .to match_array([version1, version2])
+ .to contain_exactly(version1, version2)
end
end
end
diff --git a/spec/models/query/results_sort_intergration_spec.rb b/spec/models/query/results_sort_intergration_spec.rb
index f11e5e6466d..36dbf26a5e4 100644
--- a/spec/models/query/results_sort_intergration_spec.rb
+++ b/spec/models/query/results_sort_intergration_spec.rb
@@ -463,7 +463,7 @@ RSpec.describe Query::Results, 'sorting and grouping' do
let(:work_package1) { create(:work_package, project: project1) }
let(:work_package2) { create(:work_package, project: project1) }
let(:work_package3) { create(:work_package, project: project1) }
- let(:int_cf) { create(:int_wp_custom_field, is_filter: true) }
+ let(:int_cf) { create(:integer_wp_custom_field, is_filter: true) }
let!(:custom_value) do
create(:custom_value,
custom_field: int_cf,
diff --git a/spec/models/query/results_spec.rb b/spec/models/query/results_spec.rb
index 7afe200e166..38e4868afff 100644
--- a/spec/models/query/results_spec.rb
+++ b/spec/models/query/results_spec.rb
@@ -216,7 +216,7 @@ RSpec.describe Query::Results do
context 'when grouping by int custom field' do
let!(:custom_field) do
- create(:int_wp_custom_field,
+ create(:integer_wp_custom_field,
is_for_all: true,
is_filter: true,
projects: [project1],
@@ -260,7 +260,7 @@ RSpec.describe Query::Results do
context 'when grouping by bool custom field' do
let!(:custom_field) do
- create(:bool_wp_custom_field,
+ create(:boolean_wp_custom_field,
is_for_all: true,
is_filter: true,
projects: [project1],
@@ -353,7 +353,7 @@ RSpec.describe Query::Results do
let(:query) { build(:query, project: project2) }
it 'displays only wp for selected project and selected role' do
- expect(query_results.work_packages).to match_array([wp_p2])
+ expect(query_results.work_packages).to contain_exactly(wp_p2)
end
end
@@ -361,7 +361,7 @@ RSpec.describe Query::Results do
let(:query) { build(:query, project: nil) }
it 'displays all wp from projects where User.current has access' do
- expect(query_results.work_packages).to match_array([wp_p2, wp2_p2])
+ expect(query_results.work_packages).to contain_exactly(wp_p2, wp2_p2)
end
end
end
@@ -400,7 +400,7 @@ RSpec.describe Query::Results do
.page(1)
.per_page(10)
- expect(work_packages).to match_array([wp_p2, wp2_p2])
+ expect(work_packages).to contain_exactly(wp_p2, wp2_p2)
end
end
@@ -418,7 +418,7 @@ RSpec.describe Query::Results do
.page(1)
.per_page(10)
- expect(work_packages).to match_array([wp_p2, wp2_p2])
+ expect(work_packages).to contain_exactly(wp_p2, wp2_p2)
end
end
end
@@ -485,7 +485,7 @@ RSpec.describe Query::Results do
end
let(:bool_cf) do
- create(:bool_wp_custom_field,
+ create(:boolean_wp_custom_field,
is_filter: true,
projects: [work_package1.project],
types: [work_package1.type])
@@ -575,7 +575,7 @@ RSpec.describe Query::Results do
let(:custom_value) { nil }
let(:filter_value) { 'f' }
let(:bool_cf) do
- create(:bool_wp_custom_field,
+ create(:boolean_wp_custom_field,
is_filter: true,
types: [work_package1.type])
end
@@ -590,7 +590,7 @@ RSpec.describe Query::Results do
let(:custom_value) { nil }
let(:filter_value) { 'f' }
let(:bool_cf) do
- create(:bool_wp_custom_field,
+ create(:boolean_wp_custom_field,
is_filter: true,
is_for_all: true,
projects: [work_package1.project])
diff --git a/spec/models/query/results_sums_integration_spec.rb b/spec/models/query/results_sums_integration_spec.rb
index 33fb1908c64..784aabcf661 100644
--- a/spec/models/query/results_sums_integration_spec.rb
+++ b/spec/models/query/results_sums_integration_spec.rb
@@ -124,7 +124,7 @@ RSpec.describe Query::Results, 'sums' do
overridden_costs: 300)
end
let(:int_cf) do
- create(:int_wp_custom_field)
+ create(:integer_wp_custom_field)
end
let(:float_cf) do
create(:float_wp_custom_field)
diff --git a/spec/models/query_spec.rb b/spec/models/query_spec.rb
index f229902c334..6a349bb3f19 100644
--- a/spec/models/query_spec.rb
+++ b/spec/models/query_spec.rb
@@ -550,7 +550,7 @@ RSpec.describe Query,
context 'with a missing value for a custom field' do
let(:custom_field) do
- create(:text_issue_custom_field, is_filter: true, is_for_all: true)
+ create(:issue_custom_field, :text, is_filter: true, is_for_all: true)
end
before do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 34e2b5a5f1e..2f628a7b9dd 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -908,6 +908,6 @@ RSpec.describe User do
it_behaves_like 'acts_as_customizable included' do
let(:model_instance) { user }
- let(:custom_field) { create(:string_user_custom_field) }
+ let(:custom_field) { create(:user_custom_field, :string) }
end
end
diff --git a/spec/models/work_package/work_package_acts_as_journalized_spec.rb b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
index 8e7d5662628..8e98221bfdf 100644
--- a/spec/models/work_package/work_package_acts_as_journalized_spec.rb
+++ b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
@@ -871,7 +871,7 @@ RSpec.describe WorkPackage do
let(:project) { create(:project) }
let(:type) { create(:type) }
let(:custom_field) do
- create(:int_wp_custom_field).tap do |cf|
+ create(:integer_wp_custom_field) do |cf|
project.work_package_custom_fields << cf
type.custom_fields << cf
end
diff --git a/spec/models/work_package_custom_field_spec.rb b/spec/models/work_package_custom_field_spec.rb
index 6c3bcda61ce..599fdc26277 100644
--- a/spec/models/work_package_custom_field_spec.rb
+++ b/spec/models/work_package_custom_field_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe WorkPackageCustomField do
create(:list_wp_custom_field)
end
let!(:int_custom_field) do
- create(:int_wp_custom_field)
+ create(:integer_wp_custom_field)
end
let!(:float_custom_field) do
create(:float_wp_custom_field)
@@ -43,7 +43,7 @@ RSpec.describe WorkPackageCustomField do
context 'with a summable field' do
it 'contains the custom_field' do
expect(described_class.summable)
- .to match_array [int_custom_field, float_custom_field]
+ .to contain_exactly(int_custom_field, float_custom_field)
end
end
end
diff --git a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
index 351fbdb90a6..708cb510f21 100644
--- a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
+++ b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
@@ -152,7 +152,7 @@ RSpec.describe 'API v3 Custom Options resource', :aggregate_failures do
end
describe 'TimeEntryCustomField' do
- shared_let(:custom_field) { create(:list_time_entry_custom_field) }
+ shared_let(:custom_field) { create(:time_entry_custom_field, :list) }
shared_let(:custom_option) { create(:custom_option, custom_field:) }
context 'when being allowed with log_time' do
@@ -197,7 +197,7 @@ RSpec.describe 'API v3 Custom Options resource', :aggregate_failures do
end
describe 'UserCustomField' do
- shared_let(:custom_field) { create(:list_user_custom_field) }
+ shared_let(:custom_field) { create(:user_custom_field, :list) }
shared_let(:custom_option) { create(:custom_option, custom_field:) }
let(:permissions) { [] }
@@ -208,7 +208,7 @@ RSpec.describe 'API v3 Custom Options resource', :aggregate_failures do
end
describe 'GroupCustomField' do
- shared_let(:custom_field) { create(:list_group_custom_field) }
+ shared_let(:custom_field) { create(:group_custom_field, :list) }
shared_let(:custom_option) { create(:custom_option, custom_field:) }
let(:permissions) { [] }
diff --git a/spec/requests/api/v3/memberships/create_form_resource_spec.rb b/spec/requests/api/v3/memberships/create_form_resource_spec.rb
index 099fb46b9f7..2113382db2d 100644
--- a/spec/requests/api/v3/memberships/create_form_resource_spec.rb
+++ b/spec/requests/api/v3/memberships/create_form_resource_spec.rb
@@ -95,8 +95,8 @@ RSpec.describe API::V3::Memberships::CreateFormAPI, content_type: :json do
end
context 'with all parameters' do
- let!(:int_cf) { create(:int_version_custom_field) }
- let!(:list_cf) { create(:list_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
+ let!(:list_cf) { create(:version_custom_field, :list) }
let(:parameters) do
{
_links: {
diff --git a/spec/requests/api/v3/user/create_form_resource_spec.rb b/spec/requests/api/v3/user/create_form_resource_spec.rb
index 95716f48050..592b1549bc0 100644
--- a/spec/requests/api/v3/user/create_form_resource_spec.rb
+++ b/spec/requests/api/v3/user/create_form_resource_spec.rb
@@ -128,10 +128,10 @@ RSpec.describe API::V3::Users::CreateFormAPI, content_type: :json do
describe 'with custom fields' do
let!(:custom_field) do
- create(:string_user_custom_field)
+ create(:user_custom_field, :string)
end
let!(:list_custom_field) do
- create(:list_user_custom_field)
+ create(:user_custom_field, :list)
end
let(:custom_option_href) { api_v3_paths.custom_option(list_custom_field.custom_options.first.id) }
diff --git a/spec/requests/api/v3/user/update_form_resource_spec.rb b/spec/requests/api/v3/user/update_form_resource_spec.rb
index 9eefb8111ed..bed580b2635 100644
--- a/spec/requests/api/v3/user/update_form_resource_spec.rb
+++ b/spec/requests/api/v3/user/update_form_resource_spec.rb
@@ -33,10 +33,10 @@ RSpec.describe API::V3::Users::UpdateFormAPI, content_type: :json do
include API::V3::Utilities::PathHelper
shared_let(:text_custom_field) do
- create(:string_user_custom_field)
+ create(:user_custom_field, :string)
end
shared_let(:list_custom_field) do
- create(:list_user_custom_field)
+ create(:user_custom_field, :list)
end
shared_let(:user) do
create(:user,
diff --git a/spec/requests/api/v3/version_resource_spec.rb b/spec/requests/api/v3/version_resource_spec.rb
index 1835d57b0b2..23230d1ef43 100644
--- a/spec/requests/api/v3/version_resource_spec.rb
+++ b/spec/requests/api/v3/version_resource_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe 'API v3 Version resource', content_type: :json do
let(:permissions) { %i[view_work_packages manage_versions] }
let(:project) { create(:project, public: false) }
let(:other_project) { create(:project, public: false) }
- let!(:int_cf) { create(:int_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
let(:version_in_project) { build(:version, project:, custom_field_values: { int_cf.id => 123 }) }
let(:version_in_other_project) do
build(:version,
@@ -131,8 +131,8 @@ RSpec.describe 'API v3 Version resource', content_type: :json do
custom_field_values: { int_cf.id => 123,
list_cf.id => list_cf.custom_options.first.id })
end
- let!(:int_cf) { create(:int_version_custom_field) }
- let!(:list_cf) { create(:list_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
+ let!(:list_cf) { create(:version_custom_field, :list) }
let(:body) do
{
name: 'New name',
@@ -268,8 +268,8 @@ RSpec.describe 'API v3 Version resource', content_type: :json do
describe 'POST api/v3/versions' do
let(:path) { api_v3_paths.versions }
- let!(:int_cf) { create(:int_version_custom_field) }
- let!(:list_cf) { create(:list_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
+ let!(:list_cf) { create(:version_custom_field, :list) }
let(:body) do
{
name: 'New version',
diff --git a/spec/requests/api/v3/versions/create_form_resource_spec.rb b/spec/requests/api/v3/versions/create_form_resource_spec.rb
index f1389731c82..24e3f5cdabe 100644
--- a/spec/requests/api/v3/versions/create_form_resource_spec.rb
+++ b/spec/requests/api/v3/versions/create_form_resource_spec.rb
@@ -109,8 +109,8 @@ RSpec.describe API::V3::Versions::CreateFormAPI, content_type: :json do
end
context 'with all parameters' do
- let!(:int_cf) { create(:int_version_custom_field) }
- let!(:list_cf) { create(:list_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
+ let!(:list_cf) { create(:version_custom_field, :list) }
let(:parameters) do
{
name: 'New version',
diff --git a/spec/requests/api/v3/versions/update_form_resource_spec.rb b/spec/requests/api/v3/versions/update_form_resource_spec.rb
index e68c9e24bd1..d5b441b5a25 100644
--- a/spec/requests/api/v3/versions/update_form_resource_spec.rb
+++ b/spec/requests/api/v3/versions/update_form_resource_spec.rb
@@ -139,8 +139,8 @@ RSpec.describe API::V3::Versions::UpdateFormAPI, content_type: :json do
end
context 'with all parameters' do
- let!(:int_cf) { create(:int_version_custom_field) }
- let!(:list_cf) { create(:list_version_custom_field) }
+ let!(:int_cf) { create(:version_custom_field, :integer) }
+ let!(:list_cf) { create(:version_custom_field, :list) }
let(:parameters) do
{
name: 'New version',
diff --git a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
index 9e113bbdfd2..9bc9ab3b972 100644
--- a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
+++ b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
@@ -190,7 +190,7 @@ RSpec.describe API::V3::WorkPackageCollectionFromQueryService,
context 'work_packages' do
it "has the query's work_package results set" do
expect(subject.work_packages)
- .to match_array([work_package])
+ .to contain_exactly(work_package)
end
end
@@ -267,7 +267,7 @@ RSpec.describe API::V3::WorkPackageCollectionFromQueryService,
query.display_sums = true
custom_fields = [build_stubbed(:text_wp_custom_field),
- build_stubbed(:int_wp_custom_field)]
+ build_stubbed(:integer_wp_custom_field)]
allow(WorkPackageCustomField)
.to receive(:summable)
diff --git a/spec/services/projects/update_service_integration_spec.rb b/spec/services/projects/update_service_integration_spec.rb
index 4aa6ad66e08..b5a20aab90e 100644
--- a/spec/services/projects/update_service_integration_spec.rb
+++ b/spec/services/projects/update_service_integration_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Projects::UpdateService, 'integration', type: :model do
status_explanation:)
end
let(:instance) { described_class.new(user:, model: project) }
- let(:custom_field) { create(:int_project_custom_field) }
+ let(:custom_field) { create(:integer_project_custom_field) }
let(:status_code) { nil }
let(:status_explanation) { nil }
let(:attributes) { {} }
diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rb
index 1c452b86587..ee3c8e244ce 100644
--- a/spec/services/work_packages/update_service_integration_spec.rb
+++ b/spec/services/work_packages/update_service_integration_spec.rb
@@ -167,7 +167,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to be_success
expect(TimeEntry.where(id: time_entries.map(&:id)).pluck(:project_id).uniq)
- .to match_array [target_project.id]
+ .to contain_exactly(target_project.id)
end
end
@@ -424,9 +424,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to eql(sibling2_attributes[:due_date])
expect(subject.all_results)
- .to match_array([work_package,
- parent_work_package,
- grandparent_work_package])
+ .to contain_exactly(work_package, parent_work_package, grandparent_work_package)
end
end
@@ -493,9 +491,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
# Returns changed work packages
expect(subject.all_results)
- .to match_array([work_package,
- parent_work_package,
- grandparent_work_package])
+ .to contain_exactly(work_package, parent_work_package, grandparent_work_package)
end
end
@@ -560,9 +556,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
# Returns changed work packages
expect(subject.all_results)
- .to match_array([work_package,
- parent_work_package,
- grandparent_work_package])
+ .to contain_exactly(work_package, parent_work_package, grandparent_work_package)
end
end
@@ -591,9 +585,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
# Returns changed work packages
expect(subject.all_results)
- .to match_array([work_package,
- parent_work_package,
- grandparent_work_package])
+ .to contain_exactly(work_package, parent_work_package, grandparent_work_package)
end
end
@@ -794,13 +786,8 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
# Returns changed work packages
expect(subject.all_results)
- .to match_array([work_package,
- following_parent_work_package,
- following_work_package,
- following2_parent_work_package,
- following2_work_package,
- following3_parent_work_package,
- following3_work_package])
+ .to contain_exactly(work_package, following_parent_work_package, following_work_package, following2_parent_work_package,
+ following2_work_package, following3_parent_work_package, following3_work_package)
end
# rubocop:enable RSpec/ExampleLength
# rubocop:enable RSpec/MultipleExpectations
@@ -851,8 +838,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to eq(expected_child_dates)
expect(subject.all_results.uniq)
- .to match_array([work_package,
- parent_work_package])
+ .to contain_exactly(work_package, parent_work_package)
end
end
@@ -957,9 +943,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to eql new_sibling_attributes[:due_date]
expect(subject.all_results.uniq)
- .to match_array([work_package,
- former_parent_work_package,
- new_parent_work_package])
+ .to contain_exactly(work_package, former_parent_work_package, new_parent_work_package)
end
end
@@ -1039,8 +1023,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to eql new_parent_predecessor_attributes[:due_date] + 4.days
expect(subject.all_results.uniq)
- .to match_array([work_package,
- new_parent_work_package])
+ .to contain_exactly(work_package, new_parent_work_package)
end
end
@@ -1112,8 +1095,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to eql sibling_attributes[:due_date]
expect(subject.all_results.uniq)
- .to match_array([work_package,
- parent_work_package])
+ .to contain_exactly(work_package, parent_work_package)
end
end
@@ -1138,10 +1120,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to be_failure
expect(result.errors.symbols_for(:attachments))
- .to match_array [:does_not_exist]
+ .to contain_exactly(:does_not_exist)
expect(work_package.attachments.reload)
- .to match_array [old_attachment]
+ .to contain_exactly(old_attachment)
expect(other_users_attachment.reload.container)
.to be_nil
@@ -1152,7 +1134,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to be_success
expect(work_package.attachments.reload)
- .to match_array [new_attachment]
+ .to contain_exactly(new_attachment)
expect(new_attachment.reload.container)
.to eql work_package
@@ -1169,7 +1151,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
.to be_empty
expect(Attachment.all)
- .to match_array [other_users_attachment]
+ .to contain_exactly(other_users_attachment)
end
# rubocop:enable RSpec/ExampleLength
end
@@ -1241,7 +1223,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
due_date: Time.zone.today + 5.days)
end
let!(:custom_field) do
- create(:int_wp_custom_field, is_required: true, is_for_all: true, default_value: nil).tap do |cf|
+ create(:integer_wp_custom_field, is_required: true, is_for_all: true, default_value: nil) do |cf|
project.types.first.custom_fields << cf
project.work_package_custom_fields << cf
end
@@ -1283,7 +1265,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
describe 'updating an invalid work package' do
# The work package does not have a required custom field set.
let(:custom_field) do
- create(:int_wp_custom_field, is_required: true, is_for_all: true, default_value: nil).tap do |cf|
+ create(:integer_wp_custom_field, is_required: true, is_for_all: true, default_value: nil) do |cf|
project.types.first.custom_fields << cf
project.work_package_custom_fields << cf
end
@@ -1316,13 +1298,13 @@ RSpec.describe WorkPackages::UpdateService, 'integration tests', type: :model do
let(:project_types) { [type, new_type] }
let(:new_type) { create(:type) }
let!(:custom_field_of_current_type) do
- create(:int_wp_custom_field, default_value: nil).tap do |cf|
+ create(:integer_wp_custom_field, default_value: nil) do |cf|
type.custom_fields << cf
project.work_package_custom_fields << cf
end
end
let!(:custom_field_of_new_type) do
- create(:int_wp_custom_field, default_value: 8).tap do |cf|
+ create(:integer_wp_custom_field, default_value: 8) do |cf|
new_type.custom_fields << cf
project.work_package_custom_fields << cf
end
diff --git a/spec/views/users/show.html.erb_spec.rb b/spec/views/users/show.html.erb_spec.rb
index 4964ce145e4..49697fb9dc1 100644
--- a/spec/views/users/show.html.erb_spec.rb
+++ b/spec/views/users/show.html.erb_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
RSpec.describe 'users/show' do
let(:project) { create(:valid_project) }
let(:user) { create(:admin, member_in_project: project) }
- let(:custom_field) { create(:text_user_custom_field) }
+ let(:custom_field) { create(:user_custom_field, :text) }
let(:visibility_custom_value) do
create(:principal_custom_value,
customized: user,