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
Clean up rubocop errors from work_package_representer_spec.rb
Dombi Attila7ba6e63917cf
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.rbindex a5632a3ddc0..5bf1c6c5764 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@@ -28,7 +28,6 @@require 'spec_helper'-# rubocop:disable RSpec:MultipleMemoizedHelpersdescribe ::API::V3::WorkPackages::WorkPackageRepresenter doinclude ::API::V3::Utilities::PathHelper@@ -118,7 +117,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:status) { build_stubbed(:status, updated_at: Time.zone.now) }let(:available_custom_fields) { [] }- before(:each) do+ before dologin_as current_userallow(current_user)@@ -136,7 +135,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doinclude_context 'eager loaded work package representer'- context 'generation' do+ describe 'generation' dosubject(:generated) { representer.to_json }it { is_expected.to include_json('WorkPackage'.to_json).at_path('_type') }@@ -151,25 +150,25 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doenddescribe 'scheduleManually' do- context 'no value' do+ context 'when no value' doit 'renders as false (default value)' do- is_expected.to be_json_eql(false.to_json).at_path('scheduleManually')+ expect(subject).to be_json_eql(false.to_json).at_path('scheduleManually')endend- context 'false' do+ context 'when false' dolet(:schedule_manually) { false }it 'renders as false' do- is_expected.to be_json_eql(false.to_json).at_path('scheduleManually')+ expect(subject).to be_json_eql(false.to_json).at_path('scheduleManually')endend- context 'true' do+ context 'when true' dolet(:schedule_manually) { true }it 'renders as true' do- is_expected.to be_json_eql(true.to_json).at_path('scheduleManually')+ expect(subject).to be_json_eql(true.to_json).at_path('scheduleManually')endendend@@ -180,11 +179,11 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:json_path) { 'startDate' }end- context 'no start date' do+ context 'when it\'s nil' dolet(:start_date) { nil }it 'renders as null' do- is_expected.to be_json_eql(nil.to_json).at_path('startDate')+ expect(subject).to be_json_eql(nil.to_json).at_path('startDate')endend@@ -192,7 +191,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:type_milestone) { true }it 'has no startDate' do- is_expected.to_not have_json_path('startDate')+ expect(subject).not_to have_json_path('startDate')endendend@@ -204,11 +203,11 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:json_path) { 'dueDate' }end- context 'no finish date' do+ context 'with no finish date' dolet(:due_date) { nil }it 'renders as null' do- is_expected.to be_json_eql(nil.to_json).at_path('dueDate')+ expect(subject).to be_json_eql(nil.to_json).at_path('dueDate')endendend@@ -216,8 +215,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'with a milestone type' dolet(:type_milestone) { true }- it 'has no startDate' do- is_expected.to_not have_json_path('dueDate')+ it 'with no startDate' do+ expect(subject).not_to have_json_path('dueDate')endendend@@ -231,18 +230,18 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:json_path) { 'date' }end- context 'no finish date' do+ context 'with no finish date' dolet(:due_date) { nil }it 'renders as null' do- is_expected.to be_json_eql(nil.to_json).at_path('date')+ expect(subject).to be_json_eql(nil.to_json).at_path('date')endendend- context 'with a milestone type' do- it 'has no date' do- is_expected.to_not have_json_path('date')+ context 'with not a milestone type' do+ it 'with no date' do+ expect(subject).not_to have_json_path('date')endendend@@ -253,11 +252,11 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:json_path) { 'derivedStartDate' }end- context 'no derived start date' do+ context 'with no derived start date' dolet(:derived_start_date) { nil }it 'renders as null' do- is_expected+ expect(subject).to be_json_eql(nil.to_json).at_path('derivedStartDate')end@@ -266,9 +265,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the work package has a milestone type' dolet(:type_milestone) { true }- it 'has no derivedStartDate' do- is_expected- .to_not have_json_path('derivedStartDate')+ it 'with no derivedStartDate' do+ expect(subject)+ .not_to have_json_path('derivedStartDate')endendend@@ -279,11 +278,11 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:json_path) { 'derivedDueDate' }end- context 'no derived due date' do+ context 'with no derived due date' dolet(:derived_due_date) { nil }it 'renders as null' do- is_expected+ expect(subject).to be_json_eql(nil.to_json).at_path('derivedDueDate')end@@ -292,9 +291,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the work package has a milestone type' dolet(:type_milestone) { true }- it 'has no derivedDueDate' do- is_expected- .to_not have_json_path('derivedDueDate')+ it 'with no derivedDueDate' do+ expect(subject)+ .not_to have_json_path('derivedDueDate')endendend@@ -304,25 +303,25 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doit { is_expected.to be_json_eql('P6D'.to_json).at_path('duration') }- context 'no duration' do+ context 'with no duration' dolet(:duration) { nil }it 'renders as null' do- is_expected.to be_json_eql(nil.to_json).at_path('duration')+ expect(subject).to be_json_eql(nil.to_json).at_path('duration')endendcontext 'when the work_package is a milestone' dolet(:type_milestone) { true }- it 'has no duration' do- is_expected.to_not have_json_path('duration')+ it 'with no duration' do+ expect(subject).not_to have_json_path('duration')endendcontext 'when the feature flag is off', with_flag: { work_packages_duration_field_active: false } do- it 'has no duration' do- is_expected.to_not have_json_path('duration')+ it 'with no duration' do+ expect(subject).not_to have_json_path('duration')endendend@@ -342,7 +341,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the feature flag is off', with_flag: { work_packages_duration_field_active: false } doit 'has no ignoreNonWorkingDays' do- is_expected.to_not have_json_path('ignoreNonWorkingDays')+ expect(subject).not_to have_json_path('ignoreNonWorkingDays')endendend@@ -372,26 +371,27 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doenddescribe 'readonly' do- context 'no status' do+ context 'with no status' dolet(:status) { nil }+it 'renders nothing' do- is_expected.not_to have_json_path('readonly')+ expect(subject).not_to have_json_path('readonly')endend- context 'false', with_ee: %i[readonly_work_packages] do+ context 'when false', with_ee: %i[readonly_work_packages] dolet(:status) { build_stubbed :status, is_readonly: false }it 'renders as false' do- is_expected.to be_json_eql(false.to_json).at_path('readonly')+ expect(subject).to be_json_eql(false.to_json).at_path('readonly')endend- context 'true', with_ee: %i[readonly_work_packages] do+ context 'when true', with_ee: %i[readonly_work_packages] dolet(:status) { build_stubbed :status, is_readonly: true }it 'renders as true' do- is_expected.to be_json_eql(true.to_json).at_path('readonly')+ expect(subject).to be_json_eql(true.to_json).at_path('readonly')endendend@@ -409,35 +409,38 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doit { is_expected.to be_json_eql('PT3H45M'.to_json).at_path('derivedEstimatedTime') }end- describe 'spentTime' do+ # rubocop:disable RSpec:MultipleMemoizedHelpers+ xdescribe 'spentTime' do# spentTime is completely overwritten by costs# TODO: move specs from costs to hereend+ # rubocop:enable RSpec:MultipleMemoizedHelpersdescribe 'percentageDone' dodescribe 'work package done ratio setting behavior' do- context 'setting enabled' do+ context 'when setting enabled' doit { expect(parse_json(subject)['percentageDone']).to eq(50) }end- context 'setting disabled' do+ context 'when setting disabled' dobefore doallow(Setting).to receive(:work_package_done_ratio).and_return('disabled')end- it { is_expected.to_not have_json_path('percentageDone') }+ it { is_expected.not_to have_json_path('percentageDone') }endendenddescribe 'custom fields' dolet(:available_custom_fields) { [build_stubbed(:int_wp_custom_field)] }+it 'uses a CustomFieldInjector' do- expect(::API::V3::Utilities::CustomFieldInjector).to receive(:create_value_representer)- .and_call_original+ allow(::API::V3::Utilities::CustomFieldInjector).to receive(:create_value_representer).and_call_originalrepresenter.to_json+ expect(::API::V3::Utilities::CustomFieldInjector).to have_received(:create_value_representer)endend@@ -456,7 +459,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'is a post link' do- is_expected.to be_json_eql('post'.to_json).at_path('_links/update/method')+ expect(subject).to be_json_eql('post'.to_json).at_path('_links/update/method')endend@@ -467,11 +470,11 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'is a patch link' do- is_expected.to be_json_eql('patch'.to_json).at_path('_links/updateImmediately/method')+ expect(subject).to be_json_eql('patch'.to_json).at_path('_links/updateImmediately/method')endend- context 'user is not allowed to edit work packages' do+ context 'when user is not allowed to edit work packages' dolet(:permissions) { all_permissions - [:edit_work_packages] }it_behaves_like 'has no link' do@@ -483,7 +486,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'user is lacks edit permission but has assign_versions' do+ context 'when user is lacks edit permission but has assign_versions' dolet(:permissions) { all_permissions - [:edit_work_packages] + [:assign_versions] }it_behaves_like 'has an untitled link' do@@ -523,7 +526,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doenddescribe 'assignee' do- context 'is user' do+ context 'as a user' dolet(:assignee) { build_stubbed(:user) }it_behaves_like 'has a titled link' do@@ -533,7 +536,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is group' do+ context 'as a group' dolet(:assignee) { build_stubbed(:group) }it_behaves_like 'has a titled link' do@@ -543,7 +546,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is placeholder user' do+ context 'as a placeholder user' dolet(:assignee) { build_stubbed(:placeholder_user) }it_behaves_like 'has a titled link' do@@ -553,7 +556,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is deleted user' do+ context 'as a deleted user' dolet(:assignee) { build_stubbed(:deleted_user) }it_behaves_like 'has a titled link' do@@ -563,7 +566,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is not set' do+ context 'as not set' doit_behaves_like 'has an empty link' dolet(:link) { 'assignee' }end@@ -571,7 +574,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doenddescribe 'responsible' do- context 'is user' do+ context 'as a user' dolet(:responsible) { build_stubbed(:user) }it_behaves_like 'has a titled link' do@@ -581,7 +584,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is group' do+ context 'as a group' dolet(:responsible) { build_stubbed(:group) }it_behaves_like 'has a titled link' do@@ -591,7 +594,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is placeholder user' do+ context 'as a placeholder user' dolet(:responsible) { build_stubbed(:placeholder_user) }it_behaves_like 'has a titled link' do@@ -601,7 +604,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is deleted user' do+ context 'as a deleted user' dolet(:responsible) { build_stubbed(:deleted_user) }it_behaves_like 'has a titled link' do@@ -611,7 +614,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'is not set' do+ context 'as not set' doit_behaves_like 'has an empty link' dolet(:link) { 'responsible' }end@@ -631,13 +634,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:embedded_path) { '_embedded/version' }let(:href_path) { '_links/version/href' }- context 'no version set' do+ context 'when no version set' doit_behaves_like 'has an empty link' dolet(:link) { 'version' }endend- context 'version set' do+ context 'when version is set' dolet!(:version) { create :version, project: }before do@@ -651,8 +654,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'has the version embedded' do- is_expected.to be_json_eql('Version'.to_json).at_path("#{embedded_path}/_type")- is_expected.to be_json_eql(version.name.to_json).at_path("#{embedded_path}/name")+ expect(subject).to be_json_eql('Version'.to_json).at_path("#{embedded_path}/_type")+ expect(subject).to be_json_eql(version.name.to_json).at_path("#{embedded_path}/name")endendend@@ -668,8 +671,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'has the project embedded' do- is_expected.to be_json_eql('Project'.to_json).at_path("#{embedded_path}/_type")- is_expected.to be_json_eql(project.name.to_json).at_path("#{embedded_path}/name")+ expect(subject).to be_json_eql('Project'.to_json).at_path("#{embedded_path}/_type")+ expect(subject).to be_json_eql(project.name.to_json).at_path("#{embedded_path}/name")endend@@ -677,13 +680,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:embedded_path) { '_embedded/category' }let(:href_path) { '_links/category/href' }- context 'no category set' do+ context 'when no category set' doit_behaves_like 'has an empty link' dolet(:link) { 'category' }endend- context 'category set' do+ context 'when category is set' dolet!(:category) { build_stubbed :category }before do@@ -697,9 +700,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'has the category embedded' do- is_expected.to have_json_type(Hash).at_path('_embedded/category')- is_expected.to be_json_eql('Category'.to_json).at_path("#{embedded_path}/_type")- is_expected.to be_json_eql(category.name.to_json).at_path("#{embedded_path}/name")+ expect(subject).to have_json_type(Hash).at_path('_embedded/category')+ expect(subject).to be_json_eql('Category'.to_json).at_path("#{embedded_path}/_type")+ expect(subject).to be_json_eql(category.name.to_json).at_path("#{embedded_path}/name")endendend@@ -712,8 +715,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'has the priority embedded' do- is_expected.to be_json_eql('Priority'.to_json).at_path('_embedded/priority/_type')- is_expected.to be_json_eql(priority.name.to_json).at_path('_embedded/priority/name')+ expect(subject).to be_json_eql('Priority'.to_json).at_path('_embedded/priority/_type')+ expect(subject).to be_json_eql(priority.name.to_json).at_path('_embedded/priority/name')endend@@ -728,7 +731,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'has the budget embedded' do- is_expected+ expect(subject).to be_json_eql(budget.subject.to_json).at_path('_embedded/budget/subject')end@@ -736,12 +739,12 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'with the user lacking the view_budgets permission' doit 'has no link to the budget' do- is_expected+ expect(subject).not_to have_json_path('_links/budget')endit 'has no budget embedded' do- is_expected+ expect(subject).not_to have_json_path('_embedded/budget')endend@@ -763,7 +766,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'embeds the attachments as collection' do- is_expected.to be_json_eql('Collection'.to_json).at_path('_embedded/attachments/_type')+ expect(subject).to be_json_eql('Collection'.to_json).at_path('_embedded/attachments/_type')endit_behaves_like 'has an untitled link' do@@ -782,10 +785,10 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'addAttachments is a post link' do- is_expected.to be_json_eql('post'.to_json).at_path('_links/addAttachment/method')+ expect(subject).to be_json_eql('post'.to_json).at_path('_links/addAttachment/method')end- context 'user is not allowed to edit work packages' do+ context 'when user is not allowed to edit work packages' dolet(:permissions) { all_permissions - %i[edit_work_packages] }it_behaves_like 'has no link' do@@ -807,7 +810,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:method) { 'post' }end- context 'if user has no permission to view file links' do+ context 'when user has no permission to view file links' dolet(:permissions) { all_permissions - %i[view_file_links] }it_behaves_like 'has no link' do@@ -817,13 +820,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendcontext 'when the user is not watching the work package' do- it 'should have a link to watch' do+ it 'has a link to watch' doexpect(subject).to be_json_eql(api_v3_paths.work_package_watchers(work_package.id).to_json).at_path('_links/watch/href')end- it 'should not have a link to unwatch' do+ it 'does not have a link to unwatch' doexpect(subject).not_to have_json_path('_links/unwatch/href')endend@@ -837,19 +840,19 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do.and_return(watchers)end- it 'should have a link to unwatch' do+ it 'has a link to unwatch' doexpect(subject).to be_json_eql(api_v3_paths.watcher(current_user.id, work_package.id).to_json).at_path('_links/unwatch/href')end- it 'should not have a link to watch' do+ it 'does not have a link to watch' doexpect(subject).not_to have_json_path('_links/watch/href')endendcontext 'when the user has permission to add comments' do- it 'should have a link to add comment' do+ it 'has a link to add comment' doexpect(subject).to have_json_path('_links/addComment')endend@@ -857,20 +860,20 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to add comments' dolet(:permissions) { all_permissions - [:add_work_package_notes] }- it 'should not have a link to add comment' do+ it 'does not have a link to add comment' doexpect(subject).not_to have_json_path('_links/addComment/href')endendcontext 'when the user has the permission to add and remove watchers' do- it 'should have a link to add watcher' do+ it 'has a link to add watcher' doexpect(subject).to be_json_eql(api_v3_paths.work_package_watchers(work_package.id).to_json).at_path('_links/addWatcher/href')end- it 'should have a link to remove watcher' do+ it 'has a link to remove watcher' doexpect(subject).to be_json_eql(api_v3_paths.watcher('{user_id}', work_package.id).to_json)@@ -881,7 +884,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to add watchers' dolet(:permissions) { all_permissions - [:add_work_package_watchers] }- it 'should not have a link to add watcher' do+ it 'does not have a link to add watcher' doexpect(subject).not_to have_json_path('_links/addWatcher/href')endend@@ -889,7 +892,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to remove watchers' dolet(:permissions) { all_permissions - [:delete_work_package_watchers] }- it 'should not have a link to remove watcher' do+ it 'does not have a link to remove watcher' doexpect(subject).not_to have_json_path('_links/removeWatcher/href')endend@@ -918,7 +921,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendcontext 'when the user has the permission to manage relations' do- it 'should have a link to add relation' do+ it 'has a link to add relation' doexpect(subject).to have_json_path('_links/addRelation/href')endend@@ -926,14 +929,14 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to manage relations' dolet(:permissions) { all_permissions - [:manage_work_package_relations] }- it 'should not have a link to add relation' do+ it 'does not have a link to add relation' doexpect(subject).not_to have_json_path('_links/addRelation/href')endendendcontext 'when the user has the permission to add work packages' do- it 'should have a link to add child' do+ it 'has a link to add child' doexpect(subject).to be_json_eql("/api/v3/projects/#{project.identifier}/work_packages".to_json).at_path('_links/addChild/href')end@@ -942,12 +945,12 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to add work packages' dolet(:permissions) { all_permissions - [:add_work_packages] }- it 'should not have a link to add child' do+ it 'does not have a link to add child' doexpect(subject).not_to have_json_path('_links/addChild/href')endend- context 'timeEntries' do+ describe 'timeEntries' docontext 'when the user has the permission to view time entries' doit_behaves_like 'has a titled link' dolet(:link) { 'timeEntries' }@@ -962,7 +965,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when the user does not have the permission to view time entries' dolet(:permissions) { all_permissions - [:view_time_entries] }- it 'should not have a link to timeEntries' do+ it 'does not have a link to timeEntries' doexpect(subject).not_to have_json_path('_links/timeEntries/href')endend@@ -994,13 +997,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'no parent' do+ context 'with no parent' doit_behaves_like 'has an empty link' dolet(:link) { 'parent' }endend- context 'parent is visible' do+ context 'when parent is visible' dolet(:parent) { visible_parent }it_behaves_like 'has a titled link' do@@ -1010,7 +1013,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'parent not visible' do+ context 'when parent not visible' dolet(:parent) { invisible_parent }it_behaves_like 'has an empty link' do@@ -1019,7 +1022,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendend- context 'ancestors' do+ describe 'ancestors' dolet(:root) { build_stubbed(:work_package, project:) }let(:intermediate) dobuild_stubbed(:work_package, parent: root, project:)@@ -1027,7 +1030,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'when ancestors are visible' dobefore do- expect(work_package).to receive(:visible_ancestors)+ allow(work_package).to receive(:visible_ancestors).and_return([root, intermediate])end@@ -1037,22 +1040,24 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do.to eq(root.subject)expect(parse_json(subject)['_links']['ancestors'][1]['title']).to eq(intermediate.subject)+ expect(work_package).to have_received(:visible_ancestors)endendcontext 'when ancestors are invisible' dobefore do- expect(work_package).to receive(:visible_ancestors)+ allow(work_package).to receive(:visible_ancestors).and_return([])endit 'renders empty ancestors' doexpect(subject).to have_json_size(0).at_path('_links/ancestors')+ expect(work_package).to have_received(:visible_ancestors)endendend- context 'children' do+ describe 'children' dolet(:work_package) { create(:work_package, project:) }let!(:forbidden_work_package) docreate(:work_package,@@ -1128,6 +1133,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter docontext 'with feeds disabled', with_settings: { feeds_enabled?: false } dolet(:permissions) { all_permissions + [:export_work_packages] }+it_behaves_like 'has no link' dolet(:link) { 'atom' }end@@ -1162,6 +1168,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dolet(:link) { 'formConfiguration' }endend+context 'when admin' dolet(:current_user) { build_stubbed :admin }@@ -1189,7 +1196,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do}]- is_expected+ expect(subject).to be_json_eql(expected.to_json).at_path('_links/customActions')end@@ -1207,13 +1214,13 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doit { is_expected.to be_json_eql(status.name.to_json).at_path('_embedded/status/name') }it {- is_expected.to be_json_eql(status.is_closed.to_json).at_path('_embedded/status/isClosed')+ expect(subject).to be_json_eql(status.is_closed.to_json).at_path('_embedded/status/isClosed')}enddescribe 'activities' doit 'is not embedded' do- is_expected.not_to have_json_path('_embedded/activities')+ expect(subject).not_to have_json_path('_embedded/activities')endend@@ -1224,7 +1231,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendbefore do- scope = instance_double('ActiveRecord::Relation')+ scope = instance_double(ActiveRecord::Relation)allow(work_package).to receive(:visible_relations)@@ -1236,23 +1243,23 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'embeds a collection' do- is_expected+ expect(subject).to be_json_eql('Collection'.to_json).at_path('_embedded/relations/_type')endit 'embeds with an href containing the work_package' do- is_expected+ expect(subject).to be_json_eql(api_v3_paths.work_package_relations(work_package.id).to_json).at_path('_embedded/relations/_links/self/href')endit 'embeds the visible relations' do- is_expected+ expect(subject).to be_json_eql(1.to_json).at_path('_embedded/relations/total')- is_expected+ expect(subject).to be_json_eql(api_v3_paths.relation(relation.id).to_json).at_path('_embedded/relations/_embedded/elements/0/_links/self/href')end@@ -1267,23 +1274,23 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'embeds a collection' do- is_expected+ expect(subject).to be_json_eql('Collection'.to_json).at_path('_embedded/fileLinks/_type')endit 'embeds with an href containing the work_package' do- is_expected+ expect(subject).to be_json_eql(api_v3_paths.file_links(work_package.id).to_json).at_path('_embedded/fileLinks/_links/self/href')endit 'embeds the visible file links' do- is_expected+ expect(subject).to be_json_eql(1.to_json).at_path('_embedded/fileLinks/total')- is_expected+ expect(subject).to be_json_eql(api_v3_paths.file_link(file_link.id).to_json).at_path('_embedded/fileLinks/_embedded/elements/0/_links/self/href')end@@ -1298,7 +1305,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do.to receive(:custom_actions).and_return([unassign_action])- is_expected+ expect(subject).to be_json_eql('Unassign'.to_json).at_path('_embedded/customActions/0/name')end@@ -1310,12 +1317,16 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doallow(OpenProject::Cache).to receive(:fetch).and_return({ _links: {} }.to_json)- expect(OpenProject::Cache)- .to receive(:fetch)- .with(representer.json_cache_key)- .and_call_original++ allow(OpenProject::Cache)+ .to receive(:fetch)+ .with(representer.json_cache_key)+ .and_call_originalrepresenter.to_json++ expect(OpenProject::Cache)+ .to have_received(:fetch).with(representer.json_cache_key)enddescribe '#json_cache_key' do@@ -1328,7 +1339,6 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter dowork_package.assigned_to = assigned_towork_package.responsible = responsibleend- let!(:former_cache_key) { representer.json_cache_key }it 'includes the name of the representer class' doexpect(representer.json_cache_key)@@ -1336,43 +1346,42 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendit 'changes when the locale changes' do- I18n.with_locale(:fr) do- expect(representer.json_cache_key)- .not_to eql former_cache_key- end+ expect(+ I18n.with_locale(:fr) { representer.json_cache_key }+ ).not_to eq(representer.json_cache_key)endit 'changes when the feeds_enabled? setting is switched' do- allow(Setting)- .to receive(:feeds_enabled?)- .and_return(!Setting.feeds_enabled?)-- expect(representer.json_cache_key)- .not_to eql former_cache_key+ expect do+ allow(Setting)+ .to receive(:feeds_enabled?)+ .and_return(!Setting.feeds_enabled?)+ end.to change(representer, :json_cache_key)endit 'changes when the work_package_done_ratio setting is changes' do- allow(Setting)- .to receive(:work_package_done_ratio)- .and_return('status')-- expect(representer.json_cache_key)- .not_to eql former_cache_key+ expect do+ allow(Setting)+ .to receive(:work_package_done_ratio)+ .and_return('status')+ end.to change(representer, :json_cache_key)endit 'changes when the work_package is updated' do- work_package.updated_at = 20.seconds.from_now-- expect(representer.json_cache_key)- .not_to eql former_cache_key+ expect do+ work_package.updated_at = 20.seconds.from_now+ end.to change(representer, :json_cache_key)endit 'factors in the eager loaded cache_checksum' do- expect(work_package)+ allow(work_package).to receive(:cache_checksum).and_return(srand)representer.json_cache_key++ expect(work_package)+ .to have_received(:cache_checksum)endendend@@ -1398,4 +1407,3 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter doendendend-# rubocop:enable RSpec:MultipleMemoizedHelpers