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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix rubocop linting errors
Christophe Bliard745dafc424e8
diff --git a/modules/dashboards/spec/features/project_details_spec.rb b/modules/dashboards/spec/features/project_details_spec.rbindex 3d52b1ddcc2..24f0570b38e 100644--- a/modules/dashboards/spec/features/project_details_spec.rb+++ b/modules/dashboards/spec/features/project_details_spec.rb@@ -50,7 +50,7 @@ describe 'Project details widget on dashboard', js: true dop.send(float_cf.attribute_setter, 4.5)p.send(text_cf.attribute_setter, 'Some **long** text')p.send(string_cf.attribute_setter, 'Some small text')- p.send(date_cf.attribute_setter, Date.today)+ p.send(date_cf.attribute_setter, Date.current)p.send(user_cf.attribute_setter, other_user)p.save!(validate: false)diff --git a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb b/spec/lib/api/v3/utilities/custom_field_injector_spec.rbindex f7cb0125db1..87819a94262 100644--- a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb+++ b/spec/lib/api/v3/utilities/custom_field_injector_spec.rb@@ -54,12 +54,11 @@ describe API::V3::Utilities::CustomFieldInjector dolet(:schema_writable) { true }let(:model) { build_stubbed(:work_package) }let(:schema) do- double('WorkPackageSchema',- project_id: 42,- model:,- defines_assignable_values?: true,- available_custom_fields: [custom_field],- writable?: schema_writable)+ instance_double(API::V3::WorkPackages::Schema::SpecificWorkPackageSchema,+ project_id: 42,+ model:,+ available_custom_fields: [custom_field],+ writable?: schema_writable)endsubject { modified_class.new(schema, current_user: nil, form_embedded: true).to_json }@@ -112,7 +111,7 @@ describe API::V3::Utilities::CustomFieldInjector do# meaning they won't as no values are specifiedit_behaves_like 'indicates length requirements'- context 'custom field is not required' do+ context 'when custom field is not required' dolet(:custom_field) { build(:custom_field, is_required: false) }it 'marks the field as not required' do@@ -120,7 +119,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'custom field has regex' do+ context 'when custom field has regex' dolet(:custom_field) { build(:custom_field, regexp: 'Foo+bar') }it 'renders the regular expression' do@@ -128,7 +127,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'custom field has minimum length' do+ context 'when custom field has minimum length' dolet(:custom_field) { build(:custom_field, min_length: 5) }it_behaves_like 'indicates length requirements' do@@ -136,7 +135,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'custom field has maximum length' do+ context 'when custom field has maximum length' dolet(:custom_field) { build(:custom_field, max_length: 5) }it_behaves_like 'indicates length requirements' do@@ -295,11 +294,10 @@ describe API::V3::Utilities::CustomFieldInjector dodescribe 'user custom field on new project' dolet(:schema) do- double('ProjectSchema',- id: nil,- model: Project.new,- defines_assignable_values?: true,- available_custom_fields: [custom_field])+ instance_double(API::V3::WorkPackages::Schema::SpecificWorkPackageSchema,+ id: nil,+ model: Project.new,+ available_custom_fields: [custom_field])endlet(:custom_field) dobuild(:custom_field,@@ -331,13 +329,14 @@ describe API::V3::Utilities::CustomFieldInjector doendit 'on writing it sets on the represented' do- expected = { custom_field.id => expected_setter }- expect(represented)- .to receive(custom_field.attribute_setter)- .with(expected_setter)+ allow(represented).to receive(custom_field.attribute_setter)modified_class.new(represented, current_user: nil).from_json({ cf_path => json_value }.to_json)++ expect(represented)+ .to have_received(custom_field.attribute_setter)+ .with(expected_setter)endend@@ -348,7 +347,7 @@ describe API::V3::Utilities::CustomFieldInjector doavailable_custom_fields: [custom_field],custom_field.attribute_name => value)end- let(:custom_value) { double('CustomValue', value: raw_value, typed_value:) }+ let(:custom_value) { instance_double(CustomValue, value: raw_value, typed_value:) }let(:raw_value) { nil }let(:typed_value) { raw_value }let(:value) { '' }@@ -361,7 +360,7 @@ describe API::V3::Utilities::CustomFieldInjector doallow(represented).to receive(:custom_value_for).with(custom_field).and_return(custom_value)end- context 'user custom field' do+ context 'for user custom field' dolet(:raw_value) { value.id.to_s }let(:typed_value) { value }let(:field_format) { 'user' }@@ -383,7 +382,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'value is nil' do+ context 'when value is nil' dolet(:value) { nil }let(:raw_value) { '' }@@ -393,7 +392,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'version custom field' do+ context 'for version custom field' dolet(:value) { build_stubbed(:version, id: 2) }let(:raw_value) { value.id.to_s }let(:typed_value) { value }@@ -410,7 +409,7 @@ describe API::V3::Utilities::CustomFieldInjector doexpect(subject).to be_json_eql(value.name.to_json).at_path("_embedded/#{cf_path}/name")end- context 'value is nil' do+ context 'when value is nil' dolet(:value) { nil }let(:raw_value) { '' }@@ -420,7 +419,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'list custom field' do+ context 'for list custom field' dolet(:value) { build_stubbed(:custom_option) }let(:typed_value) { value.value }let(:raw_value) { value.id.to_s }@@ -432,7 +431,7 @@ describe API::V3::Utilities::CustomFieldInjector dolet(:title) { value.value }end- context 'value is nil' do+ context 'when value is nil' dolet(:value) { nil }let(:raw_value) { '' }let(:typed_value) { '' }@@ -442,7 +441,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'value is some invalid string' do+ context 'when value is some invalid string' dolet(:value) { 'some invalid string' }let(:raw_value) { 'some invalid string' }let(:typed_value) { 'some invalid string not found' }@@ -461,7 +460,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'string custom field' do+ context 'for string custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'string' }let(:value) { 'Foobar' }@@ -470,7 +469,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'int custom field' do+ context 'for int custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'int' }let(:value) { 42 }@@ -479,7 +478,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'float custom field' do+ context 'for float custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'float' }let(:value) { 3.14 }@@ -488,7 +487,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'bool custom field' do+ context 'for bool custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'bool' }let(:value) { true }@@ -497,16 +496,16 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'date custom field' do+ context 'for date custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'date' }- let(:value) { Date.today.to_date }+ let(:value) { Date.current }let(:json_value) { value.to_date.iso8601 }let(:expected_setter) { json_value }endend- context 'text custom field' do+ context 'for text custom field' doit_behaves_like 'injects property custom field' dolet(:field_format) { 'text' }let(:value) { '**Foobar**' }@@ -530,7 +529,7 @@ describe API::V3::Utilities::CustomFieldInjector dolet(:represented) dodouble('represented', available_custom_fields: [custom_field])end- let(:custom_value) { double('CustomValue', value:, typed_value:) }+ let(:custom_value) { instance_double(CustomValue, value:, typed_value:) }let(:value) { '' }let(:user) { build_stubbed(:user) }let(:typed_value) { value }@@ -542,7 +541,7 @@ describe API::V3::Utilities::CustomFieldInjector doallow(represented).to receive(custom_field.attribute_getter).and_return(typed_value)end- context 'reading' do+ context 'for reading' dolet(:value) { '2' }let(:field_format) { 'user' }@@ -558,7 +557,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'value is nil' do+ context 'when value is nil' dolet(:value) { nil }let(:typed_value) { nil }@@ -568,7 +567,7 @@ describe API::V3::Utilities::CustomFieldInjector doendend- context 'writing' do+ context 'for writing' dolet(:value) { nil }let(:field_format) { 'user' }@@ -578,8 +577,10 @@ describe API::V3::Utilities::CustomFieldInjector dojson = { cf_path => { href: path } }.to_jsonexpected = ['2']- expect(represented).to receive(custom_field.attribute_setter).with(expected)+ allow(represented).to receive(custom_field.attribute_setter)modified_class.new(represented, current_user: nil).from_json(json)++ expect(represented).to have_received(custom_field.attribute_setter).with(expected)endend@@ -587,8 +588,10 @@ describe API::V3::Utilities::CustomFieldInjector dojson = { cf_path => { href: nil } }.to_jsonexpected = []- expect(represented).to receive(custom_field.attribute_setter).with(expected)+ allow(represented).to receive(custom_field.attribute_setter)modified_class.new(represented, current_user: nil).from_json(json)++ expect(represented).to have_received(custom_field.attribute_setter).with(expected)endendenddiff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rbindex 30f075d095b..cde6ac76d3b 100644--- a/spec/models/custom_actions/actions/custom_field_spec.rb+++ b/spec/models/custom_actions/actions/custom_field_spec.rb@@ -105,8 +105,9 @@ describe CustomActions::Actions::CustomField doexpect(described_class.all.map(&:custom_field)).to match_array(custom_fields)- expect(described_class.all.all? { |a| described_class >= a })- .to be_truthy+ described_class.all.each do |subclass|+ expect(subclass.ancestors).to include(described_class)+ endendend@@ -334,7 +335,7 @@ describe CustomActions::Actions::CustomField doendend- context 'for a non multi value field' do+ context 'for a multi value field' dolet(:custom_field) { list_multi_custom_field }it 'is true' do@@ -477,6 +478,8 @@ describe CustomActions::Actions::CustomField doendcontext 'for a multi list custom field' do+ let(:custom_field) { list_multi_custom_field }+it_behaves_like 'associated custom action validations' dolet(:allowed_values) docustom_field@@ -571,7 +574,7 @@ describe CustomActions::Actions::CustomField doenddescribe '#apply' do- let(:work_package) { double('work_package') }+ let(:work_package) { build(:work_package) }%i[listversion@@ -586,13 +589,15 @@ describe CustomActions::Actions::CustomField dolet(:custom_field) { send(:"#{type}_custom_field") }it "sets the value for #{type} custom fields" do- expect(work_package)+ allow(work_package).to receive(custom_field.attribute_setter)- .with([42])instance.values = 42-instance.apply(work_package)++ expect(work_package)+ .to have_received(custom_field.attribute_setter)+ .with([42])endend@@ -600,13 +605,15 @@ describe CustomActions::Actions::CustomField dolet(:custom_field) { date_custom_field }it "sets the value to today for a dynamic value" do- expect(work_package)+ allow(work_package).to receive(custom_field.attribute_setter)- .with(Date.today)instance.values = '%CURRENT_DATE%'-instance.apply(work_package)++ expect(work_package)+ .to have_received(custom_field.attribute_setter)+ .with(Date.current)endendenddiff --git a/spec/models/query/results_spec.rb b/spec/models/query/results_spec.rbindex 610c887efcf..63566f400a6 100644--- a/spec/models/query/results_spec.rb+++ b/spec/models/query/results_spec.rb@@ -199,7 +199,7 @@ describe Query::Results, with_mail: false dowork_package1.send(custom_field.attribute_setter, first_value)work_package1.save!work_package2.send(custom_field.attribute_setter, [first_value,- last_value])+ last_value])work_package2.save!end