提交 18907efb 编写于 作者: B Bob Van Landuyt

Pass `archived:` as a keyword argument

上级 8cde1e32
......@@ -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])
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册