From 18907efbc9209ee39d8348eef5b3c7321b9aca26 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 11 Oct 2017 17:05:39 +0200 Subject: [PATCH] Pass `archived:` as a keyword argument --- app/controllers/concerns/group_tree.rb | 2 +- app/finders/group_descendants_finder.rb | 4 ++-- app/models/concerns/loaded_in_group_list.rb | 6 +++--- spec/models/concerns/loaded_in_group_list_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb index 71223b59808..9d4f97aa443 100644 --- a/app/controllers/concerns/group_tree.rb +++ b/app/controllers/concerns/group_tree.rb @@ -7,7 +7,7 @@ module GroupTree # Only show root groups if no parent-id is given groups.where(parent_id: params[:parent_id]) end - @groups = @groups.with_selects_for_list(params[:archived]) + @groups = @groups.with_selects_for_list(archived: params[:archived]) .sort(@sort = params[:sort]) .page(params[:page]) diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb index 7ceede3a31a..1a5f6063437 100644 --- a/app/finders/group_descendants_finder.rb +++ b/app/finders/group_descendants_finder.rb @@ -102,7 +102,7 @@ class GroupDescendantsFinder projects_to_load_ancestors_of = projects.where.not(namespace: parent_group) groups_to_load_ancestors_of = Group.where(id: projects_to_load_ancestors_of.select(:namespace_id)) ancestors_for_groups(groups_to_load_ancestors_of) - .with_selects_for_list(params[:archived]) + .with_selects_for_list(archived: params[:archived]) end def subgroups @@ -115,7 +115,7 @@ class GroupDescendantsFinder else direct_child_groups end - groups.with_selects_for_list(params[:archived]).order_by(sort) + groups.with_selects_for_list(archived: params[:archived]).order_by(sort) end def direct_child_projects diff --git a/app/models/concerns/loaded_in_group_list.rb b/app/models/concerns/loaded_in_group_list.rb index 8b519d742c5..4c4045fdab2 100644 --- a/app/models/concerns/loaded_in_group_list.rb +++ b/app/models/concerns/loaded_in_group_list.rb @@ -24,13 +24,13 @@ module LoadedInGroupList MEMBER_COUNT_SQL].freeze module ClassMethods - def with_counts(archived = nil) + def with_counts(archived:) selects = COUNT_SELECTS.dup << project_count(archived) select(selects) end - def with_selects_for_list(archived = nil) - with_route.with_counts(archived) + def with_selects_for_list(archived: nil) + with_route.with_counts(archived: archived) end def project_count(archived) diff --git a/spec/models/concerns/loaded_in_group_list_spec.rb b/spec/models/concerns/loaded_in_group_list_spec.rb index bf5bfaa76de..7a279547a3a 100644 --- a/spec/models/concerns/loaded_in_group_list_spec.rb +++ b/spec/models/concerns/loaded_in_group_list_spec.rb @@ -22,7 +22,7 @@ describe LoadedInGroupList do create(:project, namespace: parent, archived: true) create(:project, namespace: parent) - found_group = Group.with_selects_for_list('true').find_by(id: parent.id) + found_group = Group.with_selects_for_list(archived: 'true').find_by(id: parent.id) expect(found_group.preloaded_project_count).to eq(2) end @@ -31,7 +31,7 @@ describe LoadedInGroupList do create_list(:project, 2, namespace: parent, archived: true) create(:project, namespace: parent) - found_group = Group.with_selects_for_list('only').find_by(id: parent.id) + found_group = Group.with_selects_for_list(archived: 'only').find_by(id: parent.id) expect(found_group.preloaded_project_count).to eq(2) end