提交 ba2d7eda 编写于 作者: D Dmitriy Zaporozhets

Improve search within group logic

Signed-off-by: NDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
上级 fae9814e
......@@ -225,6 +225,7 @@ class Project < ActiveRecord::Base
scope :with_project_feature, -> { joins('LEFT JOIN project_features ON projects.id = project_features.project_id') }
scope :with_statistics, -> { includes(:statistics) }
scope :with_shared_runners, -> { where(shared_runners_enabled: true) }
scope :inside_path, ->(path) { joins(:route).where('routes.path LIKE ?', "#{path}/%") }
# "enabled" here means "not disabled". It includes private features!
scope :with_feature_enabled, ->(feature) {
......
......@@ -11,8 +11,7 @@ module Search
projects = ProjectsFinder.new.execute(current_user)
if group
ids = group.descendants.push(group.id)
projects = projects.in_namespace(ids)
projects = projects.inside_path(group.full_path)
end
Gitlab::SearchResults.new(current_user, projects, params[:search])
......
......@@ -1833,6 +1833,14 @@ describe Project, models: true do
end
end
describe 'inside_path' do
let!(:project1) { create(:empty_project) }
let!(:project2) { create(:empty_project) }
let!(:path) { project1.namespace.path }
it { expect(Project.inside_path(path)).to eq([project1]) }
end
def enable_lfs
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册