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

search_service_presenter_spec.rb « presenters « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 06ece838d8d063346f03ba324bd394c7c2e4e11a (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SearchServicePresenter do
  let(:user) { create(:user) }
  let(:search_service) { SearchService.new(user, search: search, scope: scope) }
  let(:presenter) { described_class.new(search_service, current_user: user) }

  describe '#show_results_status?' do
    using RSpec::Parameterized::TableSyntax

    let(:search) { '' }
    let(:scope) { nil }

    before do
      allow(presenter).to receive(:search_objects).and_return([])
      allow(presenter).to receive(:without_count?).and_return(!with_count)
      allow(presenter).to receive(:show_snippets?).and_return(show_snippets)
      allow(presenter).to receive(:show_sort_dropdown?).and_return(show_sort_dropdown)
    end

    where(:with_count, :show_snippets, :show_sort_dropdown, :result) do
      true  | true  | true  | true
      false | true  | false | true
      false | false | true  | true
      false | false | false | false
    end

    with_them do
      it { expect(presenter.show_results_status?).to eq(result) }
    end
  end
end