2019-09-03 13:45:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe Explore::SnippetsController do
|
2019-09-03 13:45:00 -04:00
|
|
|
describe 'GET #index' do
|
2020-02-25 16:09:23 -05:00
|
|
|
let!(:project_snippet) { create_list(:project_snippet, 3, :public) }
|
|
|
|
let!(:personal_snippet) { create_list(:personal_snippet, 3, :public) }
|
2019-09-03 13:45:00 -04:00
|
|
|
|
2020-02-25 16:09:23 -05:00
|
|
|
before do
|
|
|
|
allow(Kaminari.config).to receive(:default_per_page).and_return(2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
snippets = assigns(:snippets)
|
|
|
|
|
|
|
|
expect(snippets).to be_a(::Kaminari::PaginatableWithoutCount)
|
|
|
|
expect(snippets.size).to eq(2)
|
|
|
|
expect(snippets).to all(be_a(PersonalSnippet))
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders pagination' do
|
|
|
|
get :index, params: { page: 2 }
|
|
|
|
|
|
|
|
snippets = assigns(:snippets)
|
|
|
|
|
|
|
|
expect(snippets).to be_a(::Kaminari::PaginatableWithoutCount)
|
|
|
|
expect(snippets.size).to eq(1)
|
|
|
|
expect(assigns(:snippets)).to all(be_a(PersonalSnippet))
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-03 13:45:00 -04:00
|
|
|
end
|
2021-04-12 11:09:30 -04:00
|
|
|
|
|
|
|
it_behaves_like 'snippets views' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
end
|
2019-09-03 13:45:00 -04:00
|
|
|
end
|
|
|
|
end
|