diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-19 15:07:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-19 15:07:15 +0300 |
commit | ba55ca9bc4bf2c85d2d78fcb11552ad130151110 (patch) | |
tree | 8a205191235a5b2b29e5eaacf9224c73052dddc9 /spec/controllers | |
parent | ee3d5f16e3aa642944b121645764e33604a31307 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/pages_domains_controller_spec.rb | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb index 9cc740fcbef..809d7a0774e 100644 --- a/spec/controllers/projects/pages_domains_controller_spec.rb +++ b/spec/controllers/projects/pages_domains_controller_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::PagesDomainsController, feature_category: :pages do let(:user) { create(:user) } let(:project) { create(:project) } let!(:pages_domain) { create(:pages_domain, project: project) } + let(:domain_presenter) { pages_domain.present(current_user: user) } let(:request_params) do { @@ -28,15 +29,42 @@ RSpec.describe Projects::PagesDomainsController, feature_category: :pages do end describe 'GET show' do + before do + controller.instance_variable_set(:@domain, pages_domain) + allow(pages_domain).to receive(:present).with(current_user: user).and_return(domain_presenter) + end + def make_request get(:show, params: request_params.merge(id: pages_domain.domain)) end - it "displays to the 'show' page" do - make_request + context 'when domain is verified' do + before do + allow(domain_presenter).to receive(:needs_verification?).and_return(false) + end - expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template('show') + it "displays to the 'show' page without warning" do + make_request + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('show') + expect(flash.now[:warning]).to be_nil + end + end + + context 'when domain is unverified' do + before do + allow(domain_presenter).to receive(:needs_verification?).and_return(true) + end + + it "displays to the 'show' page with warning" do + make_request + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('show') + expect(flash.now[:warning]) + .to eq('This domain is not verified. You will need to verify ownership before access is enabled.') + end end context 'when user is developer' do @@ -81,15 +109,6 @@ RSpec.describe Projects::PagesDomainsController, feature_category: :pages do end end - describe 'GET show' do - it "displays the 'show' page" do - get(:show, params: request_params.merge(id: pages_domain.domain)) - - expect(response).to have_gitlab_http_status(:ok) - expect(response).to render_template('show') - end - end - describe 'PATCH update' do before do controller.instance_variable_set(:@domain, pages_domain) |