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
Add more project attribute cases project index resource specs
Dombi Attiladda70439a71f
diff --git a/spec/requests/api/v3/projects/index_resource_spec.rb b/spec/requests/api/v3/projects/index_resource_spec.rbindex 3f47d723e6c..479b229612b 100644--- a/spec/requests/api/v3/projects/index_resource_spec.rb+++ b/spec/requests/api/v3/projects/index_resource_spec.rb@@ -398,55 +398,93 @@ RSpec.describe "API v3 Project resource index", content_type: :json docreate(:non_member) # Otherwise, the public project is invisiblecreate(:public_project)end- shared_let(:project_custom_field) do+ shared_let(:public_non_member_project) do+ create(:public_project)+ end+ shared_let(:public_wp_share_project) do+ create(:public_project)+ end+ shared_let(:work_package) do+ create(:work_package, project: public_wp_share_project)+ end+ shared_let(:project_cf) docreate(:project_custom_field_project_mapping, project:).project_custom_fieldend- shared_let(:other_project_custom_field) do+ shared_let(:other_cf) docreate(:project_custom_field_project_mapping, project: other_project).project_custom_fieldend- shared_let(:public_project_custom_field) do+ shared_let(:public_cf) docreate(:project_custom_field_project_mapping, project: public_project).project_custom_fieldend-- let(:permissions) { [] }- let(:view_attributes_permissions) { %i(view_project_attributes) }- let(:view_attributes_role) { create(:project_role, permissions: view_attributes_permissions) }+ shared_let(:public_non_member_cf) do+ create(:project_custom_field_project_mapping, project: public_non_member_project)+ .project_custom_field+ end+ shared_let(:public_wp_share_cf) do+ create(:project_custom_field_project_mapping, project: public_wp_share_project)+ .project_custom_field+ endlet(:current_user) do- create(:user, member_with_roles: { project => role,- other_project => view_attributes_role,- public_project_custom_field => role })+ create(:user, member_with_permissions: {+ project => [],+ other_project => %i(view_project_attributes),+ public_project => [],+ work_package => %i(view_work_packages)+ })end- it_behaves_like "API V3 collection response", 3, 3, "Project" do- let(:elements) { [public_project, project, other_project] }+ it_behaves_like "API V3 collection response", 5, 5, "Project" do+ let(:elements) do+ [public_wp_share_project, public_non_member_project, public_project, project, other_project]+ end- it "does not return the project attributes for the project" do+ it "does not return the project attributes for a public project as a work package member" doexpect(subject)- .to be_json_eql(public_project.name.to_json)+ .to be_json_eql(public_wp_share_project.name.to_json).at_path("_embedded/elements/0/name")expect(subject).not_to have_json_path(- "_embedded/elements/0/#{public_project_custom_field.attribute_name(:camel_case)}"+ "_embedded/elements/0/#{public_wp_share_cf.attribute_name(:camel_case)}")end- it "does not return the project attributes for the project" do+ it "does not return the project attributes for a public project as a non-member" doexpect(subject)- .to be_json_eql(project.name.to_json)+ .to be_json_eql(public_non_member_project.name.to_json).at_path("_embedded/elements/1/name")expect(subject).not_to have_json_path(- "_embedded/elements/1/#{project_custom_field.attribute_name(:camel_case)}"+ "_embedded/elements/1/#{public_non_member_cf.attribute_name(:camel_case)}")end- it "returns project attributes for other project with the view project permissions" do+ it "does not return the project attributes for a public project without view_project_attributes" doexpect(subject)- .to be_json_eql(other_project.name.to_json)+ .to be_json_eql(public_project.name.to_json).at_path("_embedded/elements/2/name")+ expect(subject).not_to have_json_path(+ "_embedded/elements/2#{public_cf.attribute_name(:camel_case)}"+ )+ end++ it "does not return the project attributes for a private project without view_project_attributes" do+ expect(subject)+ .to be_json_eql(project.name.to_json)+ .at_path("_embedded/elements/3/name")++ expect(subject).not_to have_json_path(+ "_embedded/elements/3/#{project_cf.attribute_name(:camel_case)}"+ )+ end++ it "returns project attributes for other project with view_project_attributes" do+ expect(subject)+ .to be_json_eql(other_project.name.to_json)+ .at_path("_embedded/elements/4/name")+expect(subject).to have_json_path(- "_embedded/elements/2/#{other_project_custom_field.attribute_name(:camel_case)}"+ "_embedded/elements/4/#{other_cf.attribute_name(:camel_case)}")endend