Commit 18907efb authored by Bob Van Landuyt's avatar Bob Van Landuyt

Pass `archived:` as a keyword argument

parent 8cde1e32
...@@ -7,7 +7,7 @@ module GroupTree ...@@ -7,7 +7,7 @@ module GroupTree
# Only show root groups if no parent-id is given # Only show root groups if no parent-id is given
groups.where(parent_id: params[:parent_id]) groups.where(parent_id: params[:parent_id])
end end
@groups = @groups.with_selects_for_list(params[:archived]) @groups = @groups.with_selects_for_list(archived: params[:archived])
.sort(@sort = params[:sort]) .sort(@sort = params[:sort])
.page(params[:page]) .page(params[:page])
......
...@@ -102,7 +102,7 @@ class GroupDescendantsFinder ...@@ -102,7 +102,7 @@ class GroupDescendantsFinder
projects_to_load_ancestors_of = projects.where.not(namespace: parent_group) 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)) groups_to_load_ancestors_of = Group.where(id: projects_to_load_ancestors_of.select(:namespace_id))
ancestors_for_groups(groups_to_load_ancestors_of) ancestors_for_groups(groups_to_load_ancestors_of)
.with_selects_for_list(params[:archived]) .with_selects_for_list(archived: params[:archived])
end end
def subgroups def subgroups
...@@ -115,7 +115,7 @@ class GroupDescendantsFinder ...@@ -115,7 +115,7 @@ class GroupDescendantsFinder
else else
direct_child_groups direct_child_groups
end end
groups.with_selects_for_list(params[:archived]).order_by(sort) groups.with_selects_for_list(archived: params[:archived]).order_by(sort)
end end
def direct_child_projects def direct_child_projects
......
...@@ -24,13 +24,13 @@ module LoadedInGroupList ...@@ -24,13 +24,13 @@ module LoadedInGroupList
MEMBER_COUNT_SQL].freeze MEMBER_COUNT_SQL].freeze
module ClassMethods module ClassMethods
def with_counts(archived = nil) def with_counts(archived:)
selects = COUNT_SELECTS.dup << project_count(archived) selects = COUNT_SELECTS.dup << project_count(archived)
select(selects) select(selects)
end end
def with_selects_for_list(archived = nil) def with_selects_for_list(archived: nil)
with_route.with_counts(archived) with_route.with_counts(archived: archived)
end end
def project_count(archived) def project_count(archived)
......
...@@ -22,7 +22,7 @@ describe LoadedInGroupList do ...@@ -22,7 +22,7 @@ describe LoadedInGroupList do
create(:project, namespace: parent, archived: true) create(:project, namespace: parent, archived: true)
create(:project, namespace: parent) 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) expect(found_group.preloaded_project_count).to eq(2)
end end
...@@ -31,7 +31,7 @@ describe LoadedInGroupList do ...@@ -31,7 +31,7 @@ describe LoadedInGroupList do
create_list(:project, 2, namespace: parent, archived: true) create_list(:project, 2, namespace: parent, archived: true)
create(:project, namespace: parent) 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) expect(found_group.preloaded_project_count).to eq(2)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment