2017-01-25 14:53:29 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Explore::ProjectsController do
|
|
|
|
describe 'GET #trending' do
|
2017-01-27 11:57:06 -05:00
|
|
|
context 'sorting by update date' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
|
|
|
|
let(:project2) { create(:project, :public, updated_at: 1.day.ago) }
|
2017-01-25 14:53:29 -05:00
|
|
|
|
2017-01-27 11:57:06 -05:00
|
|
|
before do
|
|
|
|
create(:trending_project, project: project1)
|
|
|
|
create(:trending_project, project: project2)
|
|
|
|
end
|
2017-01-25 14:53:29 -05:00
|
|
|
|
|
|
|
it 'sorts by last updated' do
|
|
|
|
get :trending, sort: 'updated_desc'
|
2017-01-27 11:57:06 -05:00
|
|
|
|
|
|
|
expect(assigns(:projects)).to eq [project2, project1]
|
2017-01-25 14:53:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts by oldest updated' do
|
|
|
|
get :trending, sort: 'updated_asc'
|
2017-01-27 11:57:06 -05:00
|
|
|
|
|
|
|
expect(assigns(:projects)).to eq [project1, project2]
|
2017-01-25 14:53:29 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|