2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Explore::ProjectsController do
|
|
|
|
describe 'GET #trending' do
|
|
|
|
context 'sorting by update date' do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
|
|
|
|
let(:project2) { create(:project, :public, updated_at: 1.day.ago) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
create(:trending_project, project: project1)
|
|
|
|
create(:trending_project, project: project2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by last updated' do
|
2019-02-13 22:33:31 +05:30
|
|
|
get :trending, params: { sort: 'updated_desc' }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(assigns(:projects)).to eq [project2, project1]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by oldest updated' do
|
2019-02-13 22:33:31 +05:30
|
|
|
get :trending, params: { sort: 'updated_asc' }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(assigns(:projects)).to eq [project1, project2]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|