Commit caf2b686 authored by Vladimir Shushlin's avatar Vladimir Shushlin

Fix stylistic comments

use .present instead of fabricate
fix typo in the method name
fix specs after rebase
parent b27ed1b9
......@@ -10,7 +10,7 @@ class Projects::PagesController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def show
@domains = @project.pages_domains.order(:domain)
@domains = @project.pages_domains.order(:domain).present(current_user: current_user)
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -88,10 +88,6 @@ class Projects::PagesDomainsController < Projects::ApplicationController
end
def domain
@domain ||=
begin
domain = @project.pages_domains.find_by_domain!(params[:id].to_s)
Gitlab::View::Presenter::Factory.new(domain, current_user: current_user).fabricate!
end
@domain ||= @project.pages_domains.find_by_domain!(params[:id].to_s).present(current_user: current_user)
end
end
# frozen_string_literal: true
class PagesDomain < ApplicationRecord
include Presentable
VERIFICATION_KEY = 'gitlab-pages-verification-code'
VERIFICATION_THRESHOLD = 3.days.freeze
SSL_RENEWAL_THRESHOLD = 30.days.freeze
......@@ -13,7 +15,7 @@ class PagesDomain < ApplicationRecord
has_many :acme_orders, class_name: "PagesDomainAcmeOrder"
has_many :serverless_domain_clusters, class_name: 'Serverless::DomainCluster', inverse_of: :pages_domain
before_validation :clear_auto_ssl_fauilure, unless: :auto_ssl_enabled
before_validation :clear_auto_ssl_failure, unless: :auto_ssl_enabled
validates :domain, hostname: { allow_numeric_hostname: true }
validates :domain, uniqueness: { case_sensitive: false }
......@@ -210,7 +212,7 @@ class PagesDomain < ApplicationRecord
Pages::VirtualDomain.new([project], domain: self)
end
def clear_auto_ssl_fauilure
def clear_auto_ssl_failure
self.auto_ssl_failed = false
end
......
- verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled?
- if can?(current_user, :update_pages, @project) && @domains.load.any?
- if can?(current_user, :update_pages, @project) && @domains.any?
.card
.card-header
Domains (#{@domains.size})
%ul.list-group.list-group-flush.pages-domain-list{ class: ("has-verification-status" if verification_enabled) }
- @domains.each do |domain|
- domain = Gitlab::View::Presenter::Factory.new(domain, current_user: current_user).fabricate!
%li.pages-domain-list-item.list-group-item.d-flex.justify-content-between
- if verification_enabled
- tooltip, status = domain.unverified? ? [s_('GitLabPages|Unverified'), 'failed'] : [s_('GitLabPages|Verified'), 'success']
......
......@@ -7,7 +7,7 @@
.bs-callout.bs-callout-warning.mt-0
.row.align-items-center.mx-2
= icon('warning', class: 'mr-2')
= _("Something went wrong while the obtaining Let's Encrypt certificate.")
= _("Something went wrong while obtaining the Let's Encrypt certificate.")
.row.mx-0.mt-3
= link_to s_('GitLabPagesDomains|Retry'), retry_auto_ssl_project_pages_domain_path(@project, @domain), class: "btn btn-sm btn-grouped btn-warning", method: :post
- elsif !@domain.certificate_gitlab_provided?
......
......@@ -93,7 +93,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
it 'user can retry obtaining certificate' do
visit project_pages_domain_path(project, domain)
expect(page).to have_text("Something went wrong while obtaining Let's Encrypt certificate.")
expect(page).to have_text("Something went wrong while obtaining the Let's Encrypt certificate.")
click_on('Retry')
......
......@@ -17,7 +17,7 @@ describe 'projects/pages/show' do
assign(:project, project)
allow(view).to receive(:current_user).and_return(user)
assign(:domains, project.pages_domains)
assign(:domains, [domain.present(current_user: user)])
end
describe 'validation warning' do
......
......@@ -7,7 +7,7 @@ describe 'projects/pages_domains/show' do
before do
assign(:project, project)
assign(:domain, Gitlab::View::Presenter::Factory.new(domain).fabricate!)
assign(:domain, domain.present)
stub_pages_setting(external_https: true)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment