Commit d8a9bfb6 authored by Takuya Noguchi's avatar Takuya Noguchi

Order UsersController#projects.json by updated_at

parent 2e350216
......@@ -13,7 +13,7 @@ class PersonalProjectsFinder < UnionFinder
def execute(current_user = nil)
segments = all_projects(current_user)
find_union(segments, Project).includes(:namespace).order_id_desc
find_union(segments, Project).includes(:namespace).order_updated_desc
end
private
......
---
title: Order UsersController#projects.json by updated_at
merge_request: 18227
author: Takuya Noguchi
type: other
......@@ -27,8 +27,8 @@ describe 'Users > User browses projects on user page', :js do
end
it 'paginates projects', :js do
project = create(:project, namespace: user.namespace)
project2 = create(:project, namespace: user.namespace)
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since)
project2 = create(:project, namespace: user.namespace, updated_at: 1.minute.since)
allow(Project).to receive(:default_per_page).and_return(1)
sign_in(user)
......@@ -41,11 +41,11 @@ describe 'Users > User browses projects on user page', :js do
wait_for_requests
expect(page).to have_content(project2.name)
expect(page).to have_content(project.name)
click_link('Next')
expect(page).to have_content(project.name)
expect(page).to have_content(project2.name)
end
context 'when not signed in' do
......
......@@ -4,14 +4,16 @@ describe PersonalProjectsFinder do
let(:source_user) { create(:user) }
let(:current_user) { create(:user) }
let(:finder) { described_class.new(source_user) }
let!(:public_project) { create(:project, :public, namespace: source_user.namespace) }
let!(:public_project) do
create(:project, :public, namespace: source_user.namespace, updated_at: 1.hour.ago)
end
let!(:private_project) do
create(:project, :private, namespace: source_user.namespace, path: 'mepmep')
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep')
end
let!(:internal_project) do
create(:project, :internal, namespace: source_user.namespace, path: 'C')
create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C')
end
before do
......@@ -28,7 +30,7 @@ describe PersonalProjectsFinder do
subject { finder.execute(current_user) }
context 'normal user' do
it { is_expected.to eq([internal_project, private_project, public_project]) }
it { is_expected.to eq([public_project, internal_project, private_project]) }
end
context 'external' do
......@@ -36,7 +38,7 @@ describe PersonalProjectsFinder do
current_user.update_attributes(external: true)
end
it { is_expected.to eq([private_project, public_project]) }
it { is_expected.to eq([public_project, private_project]) }
end
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