diff options
author | Fatih Acet <acetfatih@gmail.com> | 2017-01-26 20:36:31 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-01-26 20:36:31 +0000 |
commit | c5bea1d2e84adaeac54451c843e0d924cd62166b (patch) | |
tree | 0ea04d30f42478c81becc02f579261394ca91eae /spec | |
parent | 04e01b6771c2d0a9eb960117c7e34e32567e3886 (diff) | |
parent | 6fbf24af278ecbb818471fae7108b669b51613e1 (diff) | |
download | gitlab-ce-c5bea1d2e84adaeac54451c843e0d924cd62166b.tar.gz |
Merge branch '27044-fix-explore-sorting-on-trending' into 'master'
Fix /explore sorting (trending)
Closes #27044
See merge request !8792
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/explore/projects_controller_spec.rb | 30 | ||||
-rw-r--r-- | spec/factories/trending_project.rb | 6 |
2 files changed, 36 insertions, 0 deletions
diff --git a/spec/controllers/explore/projects_controller_spec.rb b/spec/controllers/explore/projects_controller_spec.rb new file mode 100644 index 00000000000..6128091f543 --- /dev/null +++ b/spec/controllers/explore/projects_controller_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe Explore::ProjectsController do + let(:user) { create(:user) } + let(:visibility) { :public } + + describe 'GET #trending' do + let!(:project_1) { create(:project, visibility, ci_id: 1) } + let!(:project_2) { create(:project, visibility, ci_id: 2) } + + let!(:trending_project_1) { create(:trending_project, project: project_1) } + let!(:trending_project_2) { create(:trending_project, project: project_2) } + + before do + sign_in(user) + end + + context 'sorting by update date' do + it 'sorts by last updated' do + get :trending, sort: 'updated_desc' + expect(assigns(:projects)).to eq [project_2, project_1] + end + + it 'sorts by oldest updated' do + get :trending, sort: 'updated_asc' + expect(assigns(:projects)).to eq [project_1, project_2] + end + end + end +end diff --git a/spec/factories/trending_project.rb b/spec/factories/trending_project.rb new file mode 100644 index 00000000000..246176611dc --- /dev/null +++ b/spec/factories/trending_project.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + # TrendingProject + factory :trending_project, class: 'TrendingProject' do + project + end +end |