diff options
author | David Palubin <dpalubin@gmail.com> | 2019-07-04 12:29:06 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-07-04 12:29:06 +0300 |
commit | 643100a9b25253e122dcd2531e5457707d52818d (patch) | |
tree | 1cc45653bca744bebc1a0095efe2ec0bd270b9b7 | |
parent | c47eef94032ce1f08e05f7cb95bba9615cdc8a17 (diff) |
Set default project sort method prior to initial sort on page loading
-rw-r--r-- | app/controllers/dashboard/projects_controller.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/issue-63222.yml | 5 | ||||
-rw-r--r-- | spec/controllers/dashboard/projects_controller_spec.rb | 18 |
3 files changed, 23 insertions, 2 deletions
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index d43f5393ecc..daeb8fda417 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -7,8 +7,8 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController prepend_before_action(only: [:index]) { authenticate_sessionless_user!(:rss) } before_action :set_non_archived_param - before_action :projects, only: [:index] before_action :default_sorting + before_action :projects, only: [:index] skip_cross_project_access_check :index, :starred def index diff --git a/changelogs/unreleased/issue-63222.yml b/changelogs/unreleased/issue-63222.yml new file mode 100644 index 00000000000..bc6520b9fc5 --- /dev/null +++ b/changelogs/unreleased/issue-63222.yml @@ -0,0 +1,5 @@ +--- +title: Set default sort method for dashboard projects list +merge_request: 29830 +author: David Palubin +type: fixed diff --git a/spec/controllers/dashboard/projects_controller_spec.rb b/spec/controllers/dashboard/projects_controller_spec.rb index ea68eae12ed..6591901a9dc 100644 --- a/spec/controllers/dashboard/projects_controller_spec.rb +++ b/spec/controllers/dashboard/projects_controller_spec.rb @@ -11,8 +11,10 @@ describe Dashboard::ProjectsController do end context 'user logged in' do + let(:user) { create(:user) } + before do - sign_in create(:user) + sign_in(user) end context 'external authorization' do @@ -24,6 +26,20 @@ describe Dashboard::ProjectsController do expect(response).to have_gitlab_http_status(200) end end + + it 'orders the projects by last activity by default' do + project = create(:project) + project.add_developer(user) + project.update!(last_repository_updated_at: 3.days.ago, last_activity_at: 3.days.ago) + + project2 = create(:project) + project2.add_developer(user) + project2.update!(last_repository_updated_at: 10.days.ago, last_activity_at: 10.days.ago) + + get :index + + expect(assigns(:projects)).to eq([project, project2]) + end end end |