summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-06-04 10:41:56 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-06-04 17:43:13 +0200
commit2f50b206f2921faf47637af526d810bc10ffb3ef (patch)
tree33d200cc365463a5949ca5ee84bf92c8eaa56693
parent35ba75f6b93c77f078ab2cf538a256f8aa534eb3 (diff)
downloadgitlab-ce-bvl-hide-archived-shared-projects.tar.gz
Hide archived projects from `shared_projects`bvl-hide-archived-shared-projects
Since we don't show the archived projects, we shouldnot load them and pass them to the fronted to be filtered out again.
-rw-r--r--app/controllers/groups/shared_projects_controller.rb4
-rw-r--r--spec/controllers/groups/shared_projects_controller_spec.rb11
2 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/groups/shared_projects_controller.rb b/app/controllers/groups/shared_projects_controller.rb
index f2f835767e0..7dec1f5f402 100644
--- a/app/controllers/groups/shared_projects_controller.rb
+++ b/app/controllers/groups/shared_projects_controller.rb
@@ -24,7 +24,9 @@ module Groups
# Make the `search` param consistent for the frontend,
# which will be using `filter`.
params[:search] ||= params[:filter] if params[:filter]
- params.permit(:sort, :search)
+ # Don't show archived projects
+ params[:non_archived] = true
+ params.permit(:sort, :search, :non_archived)
end
end
end
diff --git a/spec/controllers/groups/shared_projects_controller_spec.rb b/spec/controllers/groups/shared_projects_controller_spec.rb
index d8fa41abb18..003c8c262e7 100644
--- a/spec/controllers/groups/shared_projects_controller_spec.rb
+++ b/spec/controllers/groups/shared_projects_controller_spec.rb
@@ -38,7 +38,7 @@ describe Groups::SharedProjectsController do
end
it 'allows filtering shared projects' do
- project = create(:project, :archived, namespace: user.namespace, name: "Searching for")
+ project = create(:project, namespace: user.namespace, name: "Searching for")
share_project(project)
get_shared_projects(filter: 'search')
@@ -55,5 +55,14 @@ describe Groups::SharedProjectsController do
expect(json_project_ids).to eq([second_project.id, shared_project.id])
end
+
+ it 'does not include archived projects' do
+ archived_project = create(:project, :archived, namespace: user.namespace)
+ share_project(archived_project)
+
+ get_shared_projects
+
+ expect(json_project_ids).to contain_exactly(shared_project.id)
+ end
end
end