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

pages_domain_presenter_spec.rb « presenters « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 731279ce5b9a674e43cb78bd850dee2b31301e66 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe PagesDomainPresenter do
  using RSpec::Parameterized::TableSyntax
  include LetsEncryptHelpers

  let(:presenter) { Gitlab::View::Presenter::Factory.new(domain).fabricate! }

  describe 'needs_validation?' do
    where(:pages_verification_enabled, :traits, :expected) do
      false | :unverified | false
      false | []          | false
      true  | :unverified | true
      true  | []          | false
    end

    with_them do
      before do
        stub_application_setting(pages_domain_verification_enabled: pages_verification_enabled)
      end

      let(:domain) { create(:pages_domain, *traits) }

      it { expect(presenter.needs_verification?).to eq(expected) }
    end
  end

  describe 'show_auto_ssl_failed_warning?' do
    subject { presenter.show_auto_ssl_failed_warning? }

    let(:domain) { create(:pages_domain) }

    before do
      stub_lets_encrypt_settings
    end

    it { is_expected.to eq(false) }

    context "when we failed to obtain Let's Encrypt's certificate" do
      before do
        domain.update!(auto_ssl_failed: true)
      end

      it { is_expected.to eq(true) }

      context "when Let's Encrypt integration is disabled" do
        before do
          allow(::Gitlab::LetsEncrypt).to receive(:enabled?).and_return false
        end

        it { is_expected.to eq(false) }
      end

      context "when domain is unverified" do
        before do
          domain.update!(verified_at: nil)
        end

        it { is_expected.to eq(false) }
      end
    end
  end
end