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
remove my specific links from project list sidebar
ulferts2459ca92909a
diff --git a/app/menus/projects/menu.rb b/app/menus/projects/menu.rbindex df94d327b01..f2c4a7c5ae2 100644--- a/app/menus/projects/menu.rb+++ b/app/menus/projects/menu.rb@@ -81,8 +81,8 @@ module Projectsdef main_static_filtersstatic_filters [ProjectQueries::Static::ACTIVE,- ProjectQueries::Static::MY,- ProjectQueries::Static::FAVORED,+ current_user.logged? ? ProjectQueries::Static::MY : nil,+ current_user.logged? ? ProjectQueries::Static::FAVORED : nil,current_user.admin? ? ProjectQueries::Static::ARCHIVED : nil].compactenddiff --git a/spec/menus/projects/menu_spec.rb b/spec/menus/projects/menu_spec.rbindex 0e916a730b5..1d393ee460d 100644--- a/spec/menus/projects/menu_spec.rb+++ b/spec/menus/projects/menu_spec.rb@@ -32,14 +32,13 @@ require "spec_helper"RSpec.describe Projects::Menu dolet(:instance) { described_class.new(controller_path:, params:, current_user:) }+ let!(:current_user_query) { ProjectQuery.create!(name: "Current user query", user:) }let(:controller_path) { "foo" }let(:params) { {} }- shared_let(:current_user) { build(:user) }+ let(:current_user) { user }- shared_let(:current_user_query) do- ProjectQuery.create!(name: "Current user query", user: current_user)- end+ shared_let(:user) { create(:user) }shared_let(:other_user_query) doProjectQuery.create!(name: "Other user query", user: build(:user))@@ -53,7 +52,7 @@ RSpec.describe Projects::Menu doshared_let(:shared_query) doProjectQuery.create!(name: "Shared query", user: build(:user)).tap do |query|- create(:project_query_member, entity: query, user: current_user, roles: [view_project_query_role])+ create(:project_query_member, entity: query, user:, roles: [view_project_query_role])endend@@ -67,9 +66,19 @@ RSpec.describe Projects::Menu dodescribe "children items" dosubject(:children_menu_items) { menu_items.flat_map(&:children) }- context "when the current user is an admin" do- before do- allow(current_user).to receive(:admin?).and_return(true)+ context "when the current user is logged in (admin)" do+ let(:current_user) { build(:admin) }++ it "has the active projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.active")))+ end++ it "has the my projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.my")))+ end++ it "has the favorite projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.favored")))endit "has an archived projects item" do@@ -77,34 +86,62 @@ RSpec.describe Projects::Menu doendend- context "when the current user is not an admin" do- before do- allow(current_user).to receive(:admin?).and_return(false)+ context "when the current user is logged in (no admin)" do+ it "has the active projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.active")))end- it "has an archived projects item" do+ it "has the my projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.my")))+ end++ it "has the favorite projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.favored")))+ end++ it "has no archived projects item" doexpect(children_menu_items).not_to include(have_attributes(title: I18n.t("projects.lists.archived")))end- end- it "contains menu items" do- expect(children_menu_items).to all(be_a(OpenProject::Menu::MenuItem))- end+ it "contains menu items" do+ expect(children_menu_items).to all(be_a(OpenProject::Menu::MenuItem))+ end- it "contains item for current user query" do- expect(children_menu_items).to include(have_attributes(title: "Current user query"))- end+ it "contains item for current user query" do+ expect(children_menu_items).to include(have_attributes(title: "Current user query"))+ end- it "doesn't contain item for other user query" do- expect(children_menu_items).not_to include(have_attributes(title: "Other user query"))- end+ it "doesn't contain item for other user query" do+ expect(children_menu_items).not_to include(have_attributes(title: "Other user query"))+ end++ it "contains item for public query" do+ expect(children_menu_items).to include(have_attributes(title: "Public query"))+ end- it "contains item for public query" do- expect(children_menu_items).to include(have_attributes(title: "Public query"))+ it "contains item for shared query" do+ expect(children_menu_items).to include(have_attributes(title: "Shared query"))+ endend- it "contains item for shared query" do- expect(children_menu_items).to include(have_attributes(title: "Shared query"))+ context "when the current user is not logged in" do+ let(:current_user) { build(:anonymous) }++ it "has the active projects item" do+ expect(children_menu_items).to include(have_attributes(title: I18n.t("projects.lists.active")))+ end++ it "has no my projects item" do+ expect(children_menu_items).not_to include(have_attributes(title: I18n.t("projects.lists.my")))+ end++ it "has no favorite projects item" do+ expect(children_menu_items).not_to include(have_attributes(title: I18n.t("projects.lists.favored")))+ end++ it "has no archived projects item" do+ expect(children_menu_items).not_to include(have_attributes(title: I18n.t("projects.lists.archived")))+ endendend@@ -112,7 +149,7 @@ RSpec.describe Projects::Menu dosubject(:titles) { menu_items.map { it.children.map(&:title) } }shared_let(:another_current_user_query) do- ProjectQuery.create!(name: "Another current user query", user: current_user)+ ProjectQuery.create!(name: "Another current user query", user:)endshared_let(:another_public_query) do@@ -121,7 +158,7 @@ RSpec.describe Projects::Menu doshared_let(:another_shared_query) doProjectQuery.create!(name: "Another shared query", user: build(:user)).tap do |query|- create(:project_query_member, entity: query, user: current_user, roles: [view_project_query_role])+ create(:project_query_member, entity: query, user:, roles: [view_project_query_role])endend