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 tests for WP Representer
Klaus Zandersd6238ed6ec07
diff --git a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rbindex 6d74550b99a..c7358b24247 100644--- a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb@@ -220,10 +220,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter docontext 'when the user lacks the export_work_packages permission' dobefore do- allow(user)- .to receive(:allowed_to?)- .with(:export_work_packages, project, global: project.nil?)- .and_return(false)+ mock_permissions_for(user, &:forbid_everything)endit 'has no export links' do@@ -236,18 +233,11 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter dodescribe 'customFields' dolet(:project) { build_stubbed(:project) }- before do- allow(user)- .to receive(:allowed_to?)- .and_return(false)- end-context 'with the permission to select custom fields' dobefore do- allow(user)- .to receive(:allowed_to?)- .with(:select_custom_fields, project)- .and_return(true)+ mock_permissions_for(user) do |mock|+ mock.allow_in_project :select_custom_fields, project:+ endendit 'has a link to set the custom fields for that project' do@@ -264,6 +254,10 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter doendcontext 'without the permission to select custom fields' do+ before do+ mock_permissions_for(user, &:forbid_everything)+ end+it 'has no link to set the custom fields for that project' doexpect(collection).not_to have_json_path('_links/customFields')end@@ -330,18 +324,13 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter docontext 'when the user has the edit_work_package permission in any project' dobefore do- allow(user)- .to receive(:allowed_to?)- .and_return(false)-- allow(user)- .to receive(:allowed_to?)- .with(:edit_work_packages, nil, global: true)- .and_return(allowed)+ mock_permissions_for(user) do |mock|+ mock.allow_in_project *permissions, project: build_stubbed(:project) # any project+ endendcontext 'when allowed' do- let(:allowed) { true }+ let(:permissions) { [:edit_work_packages] }it 'has a link to templated edit work_package' doexpect(collection)@@ -351,7 +340,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter doendcontext 'when not allowed' do- let(:allowed) { false }+ let(:permissions) { [] }it 'has no link to templated edit work_package' doexpect(collection).not_to have_json_path('_links/editWorkPackage')@@ -361,14 +350,9 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter docontext 'when the user has the add_work_package permission in any project' dobefore do- allow(user)- .to receive(:allowed_to?)- .and_return(false)-- allow(user)- .to receive(:allowed_to?)- .with(:add_work_packages, nil, global: true)- .and_return(true)+ mock_permissions_for(user) do |mock|+ mock.allow_in_project :add_work_packages, project: build_stubbed(:project) # any project+ endendit 'has a link to create work_packages' do@@ -412,9 +396,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageCollectionRepresenter docontext 'when the user lacks the add_work_package permission' dobefore do- allow(user)- .to receive(:allowed_to?)- .and_return(false)+ mock_permissions_for(user, &:forbid_everything)endit 'has no link to create work_packages' do