Skip to content
代码片段 群组 项目
未验证 提交 973cf98a 编辑于 作者: Adam Hegyi's avatar Adam Hegyi 提交者: GitLab
浏览文件

Merge branch '432410-update-personal-projects-sort-order' into 'master'

Sort personal projects on profile page by last_activity_at

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144309



Merged-by: default avatarAdam Hegyi <ahegyi@gitlab.com>
Approved-by: default avatarDavid Fernandez <dfernandez@gitlab.com>
Approved-by: default avatarRavi Kumar <rkumar@gitlab.com>
Approved-by: default avatarSuraj Tripathi <stripathi@gitlab.com>
Approved-by: default avatarAdam Hegyi <ahegyi@gitlab.com>
Co-authored-by: default avatarRutger Wessels <rwessels@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -22,7 +22,7 @@ def execute(current_user = nil) ...@@ -22,7 +22,7 @@ def execute(current_user = nil)
segments = all_projects(current_user) segments = all_projects(current_user)
find_union(segments, Project).with_namespace.order_updated_desc find_union(segments, Project).with_namespace.sorted_by_activity
end end
private private
......
...@@ -42,8 +42,8 @@ def click_nav_link(name) ...@@ -42,8 +42,8 @@ def click_nav_link(name)
end end
it 'paginates projects', :js do it 'paginates projects', :js do
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since) project = create(:project, namespace: user.namespace, last_activity_at: 2.minutes.since)
project2 = create(:project, namespace: user.namespace, updated_at: 1.minute.since) project2 = create(:project, namespace: user.namespace, last_activity_at: 1.minute.since)
allow(Project).to receive(:default_per_page).and_return(1) allow(Project).to receive(:default_per_page).and_return(1)
sign_in(user) sign_in(user)
......
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe PersonalProjectsFinder do RSpec.describe PersonalProjectsFinder, feature_category: :groups_and_projects do
let_it_be(:source_user) { create(:user) } let_it_be(:source_user) { create(:user) }
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let(:finder) { described_class.new(source_user) } let(:finder) { described_class.new(source_user) }
let!(:public_project) do let_it_be(:public_project) do
create(:project, :public, namespace: source_user.namespace, updated_at: 1.hour.ago, path: 'pblc') create(:project, :public, namespace: source_user.namespace, last_activity_at: 1.year.ago, path: 'pblc')
end end
let!(:private_project_shared) do let_it_be(:private_project_shared) do
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep') create(:project, :private, namespace: source_user.namespace, last_activity_at: 2.hours.ago, path: 'mepmep')
end end
let!(:internal_project) do let_it_be(:internal_project) do
create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C') create(:project, :internal, namespace: source_user.namespace, last_activity_at: 3.hours.ago, path: 'C')
end end
let!(:private_project_self) do let_it_be(:private_project_self) do
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'D') create(:project, :private, namespace: source_user.namespace, last_activity_at: 4.hours.ago, path: 'D')
end end
before do before_all do
private_project_shared.add_developer(current_user) private_project_shared.add_developer(current_user)
end end
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
context 'normal user' do context 'normal user' do
subject { finder.execute(current_user) } subject { finder.execute(current_user) }
it { is_expected.to match_array([public_project, internal_project, private_project_shared]) } it { is_expected.to eq([private_project_shared, internal_project, public_project]) }
end end
context 'external' do context 'external' do
...@@ -48,13 +48,13 @@ ...@@ -48,13 +48,13 @@
current_user.update!(external: true) current_user.update!(external: true)
end end
it { is_expected.to match_array([public_project, private_project_shared]) } it { is_expected.to eq([private_project_shared, public_project]) }
end end
context 'and searching with an admin user', :enable_admin_mode do context 'and searching with an admin user', :enable_admin_mode do
subject { finder.execute(admin) } subject { finder.execute(admin) }
it { is_expected.to match_array([public_project, internal_project, private_project_self, private_project_shared]) } it { is_expected.to eq([private_project_shared, internal_project, private_project_self, public_project]) }
end end
end end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册