Welcome to mirror list, hosted at ThFree Co, Russian Federation.

snippets_controller_spec.rb « explore « controllers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ab91faa6cef2736432252a3add3ba7d27e2a86ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

require 'spec_helper'

describe Explore::SnippetsController do
  describe 'GET #index' do
    let!(:project_snippet) { create_list(:project_snippet, 3, :public) }
    let!(:personal_snippet) { create_list(:personal_snippet, 3, :public) }

    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)
    end
  end
end