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
Include only active projects
Klaus Zanders6a4adcaa2b48
diff --git a/app/models/projects/scopes/visible.rb b/app/models/projects/scopes/visible.rbindex b6a70bca54e..ddffd7bdbb4 100644--- a/app/models/projects/scopes/visible.rb+++ b/app/models/projects/scopes/visible.rb@@ -39,9 +39,9 @@ module Projects::Scopes# Use a shortcut for admins and anonymous where# we don't need to calculate for work package roles which is more expensiveif user.admin? || user.anonymous?- Project.allowed_to(user, :view_project)+ allowed_to(user, :view_project)else- Project.where(id: user.members.select(:project_id))+ active.public_projects.or(active.where(id: user.members.select(:project_id)))endendenddiff --git a/spec/models/projects/scopes/visible_spec.rb b/spec/models/projects/scopes/visible_spec.rbindex 1f0a0e8060d..8b25872b08f 100644--- a/spec/models/projects/scopes/visible_spec.rb+++ b/spec/models/projects/scopes/visible_spec.rb@@ -78,8 +78,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { admin_user }it 'list all projects' do- expect(subject)- .to contain_exactly(shared_in_project, project, public_project)+ expect(subject).to contain_exactly(shared_in_project, project, public_project)endend@@ -87,8 +86,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { shared_user }it 'list all projects' do- expect(subject)- .to contain_exactly(shared_in_project, project, public_project)+ expect(subject).to contain_exactly(shared_in_project, project, public_project)endend@@ -96,8 +94,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { only_project_user }it 'list only the project in which the user has the membership and the public project' do- expect(subject)- .to contain_exactly(project, public_project)+ expect(subject).to contain_exactly(project, public_project)endend@@ -105,8 +102,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { only_shared_user }it 'list only the project in which the shared work package is and the public project' do- expect(subject)- .to contain_exactly(shared_in_project, public_project)+ expect(subject).to contain_exactly(shared_in_project, public_project)endend@@ -114,8 +110,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { no_membership_user }it 'list only the public project' do- expect(subject)- .to contain_exactly(public_project)+ expect(subject).to contain_exactly(public_project)endend@@ -123,8 +118,7 @@ RSpec.describe Projects::Scopes::Visible dolet(:current_user) { create(:anonymous) }it 'list only the public project' do- expect(subject)- .to contain_exactly(public_project)+ expect(subject).to contain_exactly(public_project)endendend