diff options
Diffstat (limited to 'spec/presenters/pages_domain_presenter_spec.rb')
-rw-r--r-- | spec/presenters/pages_domain_presenter_spec.rb | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/spec/presenters/pages_domain_presenter_spec.rb b/spec/presenters/pages_domain_presenter_spec.rb index 731279ce5b9..f197daab759 100644 --- a/spec/presenters/pages_domain_presenter_spec.rb +++ b/spec/presenters/pages_domain_presenter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe PagesDomainPresenter do +RSpec.describe PagesDomainPresenter, feature_category: :pages do using RSpec::Parameterized::TableSyntax include LetsEncryptHelpers @@ -62,4 +62,46 @@ RSpec.describe PagesDomainPresenter do end end end + + describe 'user_defined_certificate?' do + subject { presenter.user_defined_certificate? } + + let(:domain) { create(:pages_domain) } + + context "when domain certificate is user provided" do + it { is_expected.to eq(true) } + end + + context "when domain is not persisted" do + before do + domain.destroy! + end + + it { is_expected.to eq(false) } + end + + context "when domain certificate is blank" do + before do + domain.update!(certificate: nil, key: nil) + end + + it { is_expected.to eq(false) } + end + + context "when domain certificate source is gitlab_provided" do + before do + domain.update!(certificate_source: :gitlab_provided) + end + + it { is_expected.to eq(false) } + end + + context "when domain certificate has error" do + before do + domain.errors.add(:certificate, "certificate error") + end + + it { is_expected.to eq(false) } + end + end end |