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
tests[Op#54459]: Add API resource spec for new filter
Kabiru Mwenja522658630e4a
diff --git a/spec/requests/api/v3/projects/index_resource_spec.rb b/spec/requests/api/v3/projects/index_resource_spec.rbindex d330421e289..2918e8d98c6 100644--- a/spec/requests/api/v3/projects/index_resource_spec.rb+++ b/spec/requests/api/v3/projects/index_resource_spec.rb@@ -125,13 +125,13 @@ RSpec.describe "API v3 Project resource index", content_type: :json docontext "if using the equals operator" dolet(:operator) { "=" }- it_behaves_like "API V3 collection response", 2, 2, "Project"+ it_behaves_like "API V3 collection response", 1, 1, "Project"endcontext "if using the all operator" dolet(:operator) { "&=" }- it_behaves_like "API V3 collection response", 1, 1, "Project"+ it_behaves_like "API V3 collection response", 2, 2, "Project"it "returns the project the current user has the capabilities in" doexpect(response.body)@@ -141,6 +141,37 @@ RSpec.describe "API v3 Project resource index", content_type: :json doendend+ context "when filtering by available project attributes" do+ shared_let(:other_project) { create(:project) }+ shared_let(:project) { create(:project) }+ shared_let(:project_custom_field_mapping1) { create(:project_custom_field_project_mapping, project:) }+ shared_let(:project_custom_field_mapping2) { create(:project_custom_field_project_mapping, project:) }++ let(:valid_values) do+ [project_custom_field_mapping1.custom_field_id.to_s, project_custom_field_mapping2.custom_field_id.to_s]+ end++ let(:get_path) do+ api_v3_paths.path_for :projects, filters: [{ available_project_attributes: { operator:, values: valid_values } }]+ end++ context "if using the equals operator" do+ let(:operator) { "=" }++ it_behaves_like "API V3 collection response", 1, 1, "Project"+ end++ context "if using the not equals operator" do+ let(:operator) { "!" }++ it "returns the projects not matching the value" do+ expect(last_response.body)+ .to be_json_eql(other_project.id.to_json)+ .at_path("_embedded/elements/0/id")+ end+ end+ end+context "when filtering for principals (members)" dolet(:other_project) doProjectRole.non_member