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
Move the visible scope after the merge, add tests
Klaus Zandersb5186eaf7821
diff --git a/app/models/query/results.rb b/app/models/query/results.rbindex d35e834590d..917732e08ed 100644--- a/app/models/query/results.rb+++ b/app/models/query/results.rb@@ -50,8 +50,8 @@ class ::Query::Resultsdef sorted_work_packages_matching_the_filters_todaysorted_work_packages- .visible.merge(filtered_work_packages.merge(filter_merges))+ .visibleend# For filtering on historic data, this returns the work packagesdiff --git a/spec/requests/api/v3/work_packages/available_relation_candidates_resource_spec.rb b/spec/requests/api/v3/work_packages/available_relation_candidates_resource_spec.rbindex 0d350e3c78f..7f8d57c4407 100644--- a/spec/requests/api/v3/work_packages/available_relation_candidates_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/available_relation_candidates_resource_spec.rb@@ -62,7 +62,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dorequestJSON.parse last_response.bodyend- let(:subjects) { work_packages.pluck("subject") }+ let(:subjects) { work_packages.pluck("id") }def work_packagesresult["_embedded"]["elements"]@@ -82,7 +82,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dowith_settings: { cross_project_work_package_relations: false } dodescribe "relation candidates for wp1 (in hierarchy)" doit "returns an empty list" do- expect(subjects).to contain_exactly("WP 1.2.1")+ expect(subjects).to contain_exactly(wp1_2_1.id)endend@@ -90,7 +90,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP" }it "returns WP 2.1 and 2.2" do- expect(subjects).to contain_exactly("WP 2.1", "WP 2.2")+ expect(subjects).to contain_exactly(wp2_1.id, wp2_2.id)endend@@ -98,7 +98,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=wp" }it "returns WP 2.1 and 2.2" do- expect(subjects).to contain_exactly("WP 2.1", "WP 2.2")+ expect(subjects).to contain_exactly(wp2_1.id, wp2_2.id)endend@@ -106,7 +106,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2_2.id}/available_relation_candidates?query=WP" }it "returns just WP 2, not WP 2.1" do- expect(subjects).to contain_exactly("WP 2")+ expect(subjects).to contain_exactly(wp2.id)endendend@@ -117,7 +117,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp1.id}/available_relation_candidates?query=WP" }it "returns WP 2 and all WP 2.x as well at the grandchild WP 1.2.1" do- expect(subjects).to contain_exactly("WP 2", "WP 2.1", "WP 2.2", "WP 1.2.1")+ expect(subjects).to contain_exactly(wp2.id, wp2_1.id, wp2_2.id, wp1_2_1.id)endend@@ -130,7 +130,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI doendit "returns WP 2 and all WP 2.x sorted by updated_at DESC" do- expect(subjects).to match ["WP 2.1", "WP 1.2.1", "WP 2", "WP 2.2"]+ expect(subjects).to match [wp2_1.id, wp1_2_1.id, wp2.id, wp2_2.id]endend@@ -138,7 +138,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP&type=follows" }it "returns WP 2.1 and 2.2, WP 1 and all WP 1.x" do- expect(subjects).to contain_exactly("WP 1", "WP 1.1", "WP 1.2", "WP 1.2.1", "WP 2.1", "WP 2.2")+ expect(subjects).to contain_exactly(wp1.id, wp1_1.id, wp1_2.id, wp1_2_1.id, wp2_1.id, wp2_2.id)enddescribe 'with an already existing relationship from the work package' do@@ -151,7 +151,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI doendcontext 'for a follows relationship' doit 'does not contain the work packages already related in the opposite direction nor the parent' do- expect(subjects).to contain_exactly("WP 1.2", "WP 1.2.1", "WP 2.1")+ expect(subjects).to contain_exactly(wp1_2.id, wp1_2_1.id, wp2_1.id)endend@@ -159,7 +159,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP&type=precedes" }it 'does not contain the work packages already related but the parent' do- expect(subjects).to contain_exactly("WP 1", "WP 1.2", "WP 1.2.1", "WP 2.1")+ expect(subjects).to contain_exactly(wp1.id, wp1_2.id, wp1_2_1.id, wp2_1.id)endend@@ -167,7 +167,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP&type=parent" }it 'does not contain the work packages already related but the parent' do- expect(subjects).to contain_exactly("WP 1", "WP 1.2", "WP 1.2.1", "WP 2.1")+ expect(subjects).to contain_exactly(wp1.id, wp1_2.id, wp1_2_1.id, wp2_1.id)endend@@ -175,7 +175,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP&type=child" }it 'does not contain the work packages already related nor the parent' do- expect(subjects).to contain_exactly("WP 1.2", "WP 1.2.1", "WP 2.1")+ expect(subjects).to contain_exactly(wp1_2.id, wp1_2_1.id, wp2_1.id)endend@@ -183,7 +183,7 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI dolet(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP&type=relates" }it 'does not contain the work packages already related but the parent' do- expect(subjects).to contain_exactly("WP 1", "WP 1.2", "WP 1.2.1", "WP 2.1")+ expect(subjects).to contain_exactly(wp1.id, wp1_2.id, wp1_2_1.id, wp2_1.id)endendend@@ -197,10 +197,17 @@ RSpec.describe API::V3::WorkPackages::AvailableRelationCandidatesAPI doendit 'does not return work packages from that project' do- # TODO: Remove and fix before merge- pending "Temporary disable"- expect(subjects).to contain_exactly("WP 2.1", "WP 2.2")+ expect(subjects).to contain_exactly(wp2_1.id, wp2_2.id)endendend++ context 'when the user is not an admin and has access to just one project' do+ let(:user) { create(:user, member_with_permissions: { project2 => %i[view_work_packages edit_work_packages] }) }+ let(:href) { "/api/v3/work_packages/#{wp2.id}/available_relation_candidates?query=WP" }++ it 'only includes work packages from the first project' do+ expect(subjects).to contain_exactly(wp2_1.id, wp2_2.id)+ end+ endend