Commit 3c793920 authored by Mario de la Ossa's avatar Mario de la Ossa Committed by Sean McGivern

use Gitlab::UserSettings directly as a singleton instead of including/extending it

parent f32b4108
class Admin::CohortsController < Admin::ApplicationController
def index
if current_application_settings.usage_ping_enabled
if Gitlab::CurrentSettings.usage_ping_enabled
cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
CohortsService.new.execute
end
......
......@@ -2,7 +2,6 @@ require 'gon'
require 'fogbugz'
class ApplicationController < ActionController::Base
include Gitlab::CurrentSettings
include Gitlab::GonHelper
include GitlabRoutingHelper
include PageLayoutHelper
......@@ -28,7 +27,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
helper_method :can?, :current_application_settings
helper_method :can?
helper_method :import_sources_enabled?, :github_import_enabled?, :gitea_import_enabled?, :github_import_configured?, :gitlab_import_enabled?, :gitlab_import_configured?, :bitbucket_import_enabled?, :bitbucket_import_configured?, :google_code_import_enabled?, :fogbugz_import_enabled?, :git_import_enabled?, :gitlab_project_import_enabled?
rescue_from Encoding::CompatibilityError do |exception|
......@@ -108,7 +107,7 @@ class ApplicationController < ActionController::Base
end
def verify_namespace_plan_check_enabled
render_404 unless current_application_settings.should_check_namespace_plan?
render_404 unless Gitlab::CurrentSettings.should_check_namespace_plan?
end
def log_exception(exception)
......@@ -127,7 +126,7 @@ class ApplicationController < ActionController::Base
if Gitlab::Geo.secondary?
Gitlab::Geo.primary_node.oauth_logout_url(@geo_logout_state)
else
current_application_settings.after_sign_out_path.presence || new_user_session_path
Gitlab::CurrentSettings.after_sign_out_path.presence || new_user_session_path
end
end
......@@ -276,15 +275,15 @@ class ApplicationController < ActionController::Base
end
def import_sources_enabled?
!current_application_settings.import_sources.empty?
!Gitlab::CurrentSettings.import_sources.empty?
end
def github_import_enabled?
current_application_settings.import_sources.include?('github')
Gitlab::CurrentSettings.import_sources.include?('github')
end
def gitea_import_enabled?
current_application_settings.import_sources.include?('gitea')
Gitlab::CurrentSettings.import_sources.include?('gitea')
end
def github_import_configured?
......@@ -292,7 +291,7 @@ class ApplicationController < ActionController::Base
end
def gitlab_import_enabled?
request.host != 'gitlab.com' && current_application_settings.import_sources.include?('gitlab')
request.host != 'gitlab.com' && Gitlab::CurrentSettings.import_sources.include?('gitlab')
end
def gitlab_import_configured?
......@@ -300,7 +299,7 @@ class ApplicationController < ActionController::Base
end
def bitbucket_import_enabled?
current_application_settings.import_sources.include?('bitbucket')
Gitlab::CurrentSettings.import_sources.include?('bitbucket')
end
def bitbucket_import_configured?
......@@ -308,19 +307,19 @@ class ApplicationController < ActionController::Base
end
def google_code_import_enabled?
current_application_settings.import_sources.include?('google_code')
Gitlab::CurrentSettings.import_sources.include?('google_code')
end
def fogbugz_import_enabled?
current_application_settings.import_sources.include?('fogbugz')
Gitlab::CurrentSettings.import_sources.include?('fogbugz')
end
def git_import_enabled?
current_application_settings.import_sources.include?('git')
Gitlab::CurrentSettings.import_sources.include?('git')
end
def gitlab_project_import_enabled?
current_application_settings.import_sources.include?('gitlab_project')
Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
end
# U2F (universal 2nd factor) devices need a unique identifier for the application
......
......@@ -20,13 +20,13 @@ module EnforcesTwoFactorAuthentication
end
def two_factor_authentication_required?
current_application_settings.require_two_factor_authentication? ||
Gitlab::CurrentSettings.require_two_factor_authentication? ||
current_user.try(:require_two_factor_authentication_from_group?)
end
def two_factor_authentication_reason(global: -> {}, group: -> {})
if two_factor_authentication_required?
if current_application_settings.require_two_factor_authentication?
if Gitlab::CurrentSettings.require_two_factor_authentication?
global.call
else
groups = current_user.expanded_groups_requiring_two_factor_authentication.reorder(name: :asc)
......@@ -36,7 +36,7 @@ module EnforcesTwoFactorAuthentication
end
def two_factor_grace_period
periods = [current_application_settings.two_factor_grace_period]
periods = [Gitlab::CurrentSettings.two_factor_grace_period]
periods << current_user.two_factor_grace_period if current_user.try(:require_two_factor_authentication_from_group?)
periods.min
end
......
module RequiresWhitelistedMonitoringClient
extend ActiveSupport::Concern
include Gitlab::CurrentSettings
included do
before_action :validate_ip_whitelisted_or_valid_token!
end
......@@ -26,7 +24,7 @@ module RequiresWhitelistedMonitoringClient
token.present? &&
ActiveSupport::SecurityUtils.variable_size_secure_compare(
token,
current_application_settings.health_check_access_token
Gitlab::CurrentSettings.health_check_access_token
)
end
......
......@@ -51,7 +51,7 @@ class InvitesController < ApplicationController
return if current_user
notice = "To accept this invitation, sign in"
notice << " or create an account" if current_application_settings.allow_signup?
notice << " or create an account" if Gitlab::CurrentSettings.allow_signup?
notice << "."
store_location_for :user, request.fullpath
......
......@@ -10,6 +10,6 @@ class KodingController < ApplicationController
private
def check_integration!
render_404 unless current_application_settings.koding_enabled?
render_404 unless Gitlab::CurrentSettings.koding_enabled?
end
end
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
include Gitlab::CurrentSettings
include Gitlab::GonHelper
include PageLayoutHelper
include OauthApplications
......@@ -31,7 +30,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
private
def verify_user_oauth_applications_enabled
return if current_application_settings.user_oauth_applications?
return if Gitlab::CurrentSettings.user_oauth_applications?
redirect_to profile_path
end
......
......@@ -158,7 +158,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
label = Gitlab::OAuth::Provider.label_for(oauth['provider'])
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
if current_application_settings.allow_signup?
if Gitlab::CurrentSettings.allow_signup?
message << " Create a GitLab account first, and then connect it to your #{label} account."
end
......
class PasswordsController < Devise::PasswordsController
include Gitlab::CurrentSettings
skip_before_action :require_no_authentication, only: [:edit, :update]
before_action :resource_from_email, only: [:create]
......@@ -48,7 +46,7 @@ class PasswordsController < Devise::PasswordsController
if resource
return if resource.allow_password_authentication?
else
return if current_application_settings.password_authentication_enabled?
return if Gitlab::CurrentSettings.password_authentication_enabled?
end
redirect_to after_sending_reset_password_instructions_path_for(resource_name),
......
......@@ -24,7 +24,7 @@ module Projects
end
def slack_service
if current_application_settings.slack_app_enabled
if Gitlab::CurrentSettings.slack_app_enabled
'slack_slash_commands'
else
'gitlab_slack_application'
......
......@@ -404,7 +404,7 @@ class ProjectsController < Projects::ApplicationController
end
def project_export_enabled
render_404 unless current_application_settings.project_export_enabled?
render_404 unless Gitlab::CurrentSettings.project_export_enabled?
end
def redirect_git_extension
......
......@@ -23,7 +23,7 @@ class RootController < Dashboard::ProjectsController
def redirect_unlogged_user
if redirect_to_home_page_url?
redirect_to(current_application_settings.home_page_url)
redirect_to(Gitlab::CurrentSettings.home_page_url)
else
redirect_to(new_user_session_path)
end
......@@ -48,9 +48,9 @@ class RootController < Dashboard::ProjectsController
def redirect_to_home_page_url?
# If user is not signed-in and tries to access root_path - redirect him to landing page
# Don't redirect to the default URL to prevent endless redirections
return false unless current_application_settings.home_page_url.present?
return false unless Gitlab::CurrentSettings.home_page_url.present?
home_page_url = current_application_settings.home_page_url.chomp('/')
home_page_url = Gitlab::CurrentSettings.home_page_url.chomp('/')
root_urls = [Gitlab.config.gitlab['url'].chomp('/'), root_url.chomp('/')]
root_urls.exclude?(home_page_url)
......
......@@ -2,25 +2,23 @@ module ApplicationSettingsHelper
prepend EE::ApplicationSettingsHelper
extend self
include Gitlab::CurrentSettings
delegate :allow_signup?,
:gravatar_enabled?,
:password_authentication_enabled_for_web?,
:akismet_enabled?,
:koding_enabled?,
to: :current_application_settings
to: :'Gitlab::CurrentSettings.current_application_settings'
def user_oauth_applications?
current_application_settings.user_oauth_applications
Gitlab::CurrentSettings.user_oauth_applications
end
def allowed_protocols_present?
current_application_settings.enabled_git_access_protocol.present?
Gitlab::CurrentSettings.enabled_git_access_protocol.present?
end
def enabled_protocol
case current_application_settings.enabled_git_access_protocol
case Gitlab::CurrentSettings.enabled_git_access_protocol
when 'http'
gitlab_config.protocol
when 'ssh'
......@@ -58,7 +56,7 @@ module ApplicationSettingsHelper
# toggle button effect.
def import_sources_checkboxes(help_block_id)
Gitlab::ImportSources.options.map do |name, source|
checked = current_application_settings.import_sources.include?(source)
checked = Gitlab::CurrentSettings.import_sources.include?(source)
css_class = checked ? 'active' : ''
checkbox_name = 'application_setting[import_sources][]'
......@@ -73,7 +71,7 @@ module ApplicationSettingsHelper
def oauth_providers_checkboxes
button_based_providers.map do |source|
disabled = current_application_settings.disabled_oauth_sign_in_sources.include?(source.to_s)
disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s)
css_class = 'btn'
css_class << ' active' unless disabled
checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
......
module AuthHelper
include Gitlab::CurrentSettings
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze
FORM_BASED_PROVIDERS = [/\Aldap/, 'kerberos', 'crowd'].freeze
delegate :slack_app_id, to: :current_application_settings
delegate :slack_app_id, to: :'Gitlab::CurrentSettings.current_application_settings'
def ldap_enabled?
Gitlab::LDAP::Config.enabled?
......@@ -47,7 +45,7 @@ module AuthHelper
end
def enabled_button_based_providers
disabled_providers = current_application_settings.disabled_oauth_sign_in_sources || []
disabled_providers = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources || []
button_based_providers.map(&:to_s) - disabled_providers
end
......
module ProjectsHelper
include Gitlab::CurrentSettings
prepend ::EE::ProjectsHelper
def link_to_project(project)
......@@ -216,7 +214,7 @@ module ProjectsHelper
project.cache_key,
controller.controller_name,
controller.action_name,
current_application_settings.cache_key,
Gitlab::CurrentSettings.cache_key,
'v2.5'
]
......@@ -468,10 +466,10 @@ module ProjectsHelper
path = "#{import_path}?repo=#{repo}&branch=#{branch}&sha=#{sha}"
return URI.join(current_application_settings.koding_url, path).to_s
return URI.join(Gitlab::CurrentSettings.koding_url, path).to_s
end
current_application_settings.koding_url
Gitlab::CurrentSettings.koding_url
end
def contribution_guide_path(project)
......@@ -588,7 +586,7 @@ module ProjectsHelper
def restricted_levels
return [] if current_user.admin?
current_application_settings.restricted_visibility_levels || []
Gitlab::CurrentSettings.restricted_visibility_levels || []
end
def project_permissions_settings(project)
......
module VersionCheckHelper
def version_status_badge
if Rails.env.production? && current_application_settings.version_check_enabled
if Rails.env.production? && Gitlab::CurrentSettings.version_check_enabled
image_url = VersionCheck.new.url
image_tag image_url, class: 'js-version-status-badge'
end
......
......@@ -151,12 +151,12 @@ module VisibilityLevelHelper
def restricted_visibility_levels(show_all = false)
return [] if current_user.admin? && !show_all
current_application_settings.restricted_visibility_levels || []
Gitlab::CurrentSettings.restricted_visibility_levels || []
end
delegate :default_project_visibility,
:default_group_visibility,
to: :current_application_settings
to: :'Gitlab::CurrentSettings.current_application_settings'
def disallowed_visibility_level?(form_model, level)
return false unless form_model.respond_to?(:visibility_level_allowed?)
......
class AbuseReportMailer < BaseMailer
include Gitlab::CurrentSettings
def notify(abuse_report_id)
return unless deliverable?
@abuse_report = AbuseReport.find(abuse_report_id)
mail(
to: current_application_settings.admin_notification_email,
to: Gitlab::CurrentSettings.admin_notification_email,
subject: "#{@abuse_report.user.name} (#{@abuse_report.user.username}) was reported for abuse"
)
end
......@@ -15,6 +13,6 @@ class AbuseReportMailer < BaseMailer
private
def deliverable?
current_application_settings.admin_notification_email.present?
Gitlab::CurrentSettings.admin_notification_email.present?
end
end
class BaseMailer < ActionMailer::Base
include Gitlab::CurrentSettings
around_action :render_with_default_locale
helper ApplicationHelper
helper MarkupHelper
attr_accessor :current_user
helper_method :current_user, :can?, :current_application_settings
helper_method :current_user, :can?
default from: proc { default_sender_address.format }
default reply_to: proc { default_reply_to_address.format }
......
module Clusters
module Platforms
class Kubernetes < ActiveRecord::Base
include Gitlab::CurrentSettings
include Gitlab::Kubernetes
include ReactiveCaching
......@@ -171,7 +170,7 @@ module Clusters
{
token: token,
ca_pem: ca_pem,
max_session_time: current_application_settings.terminal_max_session_time
max_session_time: Gitlab::CurrentSettings.terminal_max_session_time
}
end
......
......@@ -230,7 +230,7 @@ class Group < Namespace
end
def actual_size_limit
return current_application_settings.repository_size_limit if repository_size_limit.nil?
return Gitlab::CurrentSettings.repository_size_limit if repository_size_limit.nil?
repository_size_limit
end
......
require 'digest/md5'
class Key < ActiveRecord::Base
include Gitlab::CurrentSettings
include AfterCommitQueue
include Sortable
......@@ -107,7 +106,7 @@ class Key < ActiveRecord::Base
end
def key_meets_restrictions
restriction = current_application_settings.key_restriction_for(public_key.type)
restriction = Gitlab::CurrentSettings.key_restriction_for(public_key.type)
if restriction == ApplicationSetting::FORBIDDEN_KEY_VALUE
errors.add(:key, forbidden_key_type_message)
......@@ -118,7 +117,7 @@ class Key < ActiveRecord::Base
def forbidden_key_type_message
allowed_types =
current_application_settings
Gitlab::CurrentSettings
.allowed_key_types
.map(&:upcase)
.to_sentence(last_word_connector: ', or ', two_words_connector: ' or ')
......
......@@ -3,7 +3,6 @@ class Namespace < ActiveRecord::Base
include CacheMarkdownField
include Sortable
include Gitlab::ShellAdapter
include Gitlab::CurrentSettings
include Gitlab::VisibilityLevel
include Routable
include AfterCommitQueue
......@@ -162,7 +161,7 @@ class Namespace < ActiveRecord::Base
end
def actual_size_limit
current_application_settings.repository_size_limit
Gitlab::CurrentSettings.repository_size_limit
end
def shared_runners_enabled?
......
......@@ -5,7 +5,6 @@ class Note < ActiveRecord::Base
extend ActiveModel::Naming
prepend EE::Note
include Gitlab::CurrentSettings
include Participable
include Mentionable
include Elastic::NotesSearch
......@@ -204,7 +203,7 @@ class Note < ActiveRecord::Base
end
def max_attachment_size
current_application_settings.max_attachment_size.megabytes.to_i
Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i
end
def hook_attrs
......
......@@ -4,7 +4,6 @@ class Project < ActiveRecord::Base
include Gitlab::ConfigHelper
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
include Gitlab::CurrentSettings
include AccessRequestable
include Avatarable
include CacheMarkdownField
......@@ -26,7 +25,6 @@ class Project < ActiveRecord::Base
prepend EE::Project
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
BoardLimitExceeded = Class.new(StandardError)
......@@ -54,8 +52,8 @@ class Project < ActiveRecord::Base
default_value_for :visibility_level, gitlab_config_features.visibility_level
default_value_for :resolve_outdated_diff_discussions, false
default_value_for :container_registry_enabled, gitlab_config_features.container_registry
default_value_for(:repository_storage) { current_application_settings.pick_repository_storage }
default_value_for(:shared_runners_enabled) { current_application_settings.shared_runners_enabled }
default_value_for(:repository_storage) { Gitlab::CurrentSettings.pick_repository_storage }
default_value_for(:shared_runners_enabled) { Gitlab::CurrentSettings.shared_runners_enabled }
default_value_for :issues_enabled, gitlab_config_features.issues
default_value_for :merge_requests_enabled, gitlab_config_features.merge_requests
default_value_for :builds_enabled, gitlab_config_features.builds
......@@ -495,14 +493,14 @@ class Project < ActiveRecord::Base
def auto_devops_enabled?
if auto_devops&.enabled.nil?
current_application_settings.auto_devops_enabled?
Gitlab::CurrentSettings.auto_devops_enabled?
else
auto_devops.enabled?
end
end
def has_auto_devops_implicitly_disabled?
auto_devops&.enabled.nil? && !current_application_settings.auto_devops_enabled?
auto_devops&.enabled.nil? && !Gitlab::CurrentSettings.auto_devops_enabled?
end
def empty_repo?
......@@ -1483,14 +1481,14 @@ class Project < ActiveRecord::Base
# Ensure HEAD points to the default branch in case it is not master
change_head(default_branch)
if current_application_settings.default_branch_protection != Gitlab::Access::PROTECTION_NONE && !ProtectedBranch.protected?(self, default_branch)
if Gitlab::CurrentSettings.default_branch_protection != Gitlab::Access::PROTECTION_NONE && !ProtectedBranch.protected?(self, default_branch)
params = {
name: default_branch,
push_access_levels_attributes: [{
access_level: current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_PUSH ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER
access_level: Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_PUSH ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER
}],
merge_access_levels_attributes: [{
access_level: current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER
access_level: Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE ? Gitlab::Access::DEVELOPER : Gitlab::Access::MASTER
}]
}
......@@ -1779,7 +1777,7 @@ class Project < ActiveRecord::Base
end
def use_hashed_storage
if self.new_record? && current_application_settings.hashed_storage_enabled
if self.new_record? && Gitlab::CurrentSettings.hashed_storage_enabled
self.storage_version = LATEST_STORAGE_VERSION
end
end
......
......@@ -4,7 +4,6 @@
# After we've migrated data, we'll remove KubernetesService. This would happen in a few months.
# If you're modyfiyng this class, please note that you should update the same change in Clusters::Platforms::Kubernetes.
class KubernetesService < DeploymentService
include Gitlab::CurrentSettings
include Gitlab::Kubernetes
include ReactiveCaching
......@@ -233,7 +232,7 @@ class KubernetesService < DeploymentService
{
token: token,
ca_pem: ca_pem,
max_session_time: current_application_settings.terminal_max_session_time
max_session_time: Gitlab::CurrentSettings.terminal_max_session_time
}
end
......
......@@ -4,7 +4,6 @@ class ProjectWiki
# EE only modules
include Elastic::WikiRepositoriesSearch
include Gitlab::CurrentSettings
MARKUPS = {
'Markdown' => :markdown,
......@@ -204,7 +203,7 @@ class ProjectWiki
# EE only
def update_elastic_index
index_blobs if current_application_settings.elasticsearch_indexing?
index_blobs if Gitlab::CurrentSettings.elasticsearch_indexing?
end
def path_to_repo
......
......@@ -3,8 +3,6 @@ class ProtectedBranch < ActiveRecord::Base
include ProtectedRef
prepend EE::ProtectedRef
extend Gitlab::CurrentSettings
protected_ref_access_levels :merge, :push
# Check if branch name is marked as protected in the system
......@@ -17,7 +15,7 @@ class ProtectedBranch < ActiveRecord::Base
end
def self.default_branch_protected?
current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_FULL ||
current_application_settings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE
Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_FULL ||
Gitlab::CurrentSettings.default_branch_protection == Gitlab::Access::PROTECTION_DEV_CAN_MERGE
end
end
......@@ -12,8 +12,6 @@ class Snippet < ActiveRecord::Base
include Editable
include Gitlab::SQL::Pattern
extend Gitlab::CurrentSettings
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description
cache_markdown_field :content
......@@ -29,7 +27,7 @@ class Snippet < ActiveRecord::Base
default_content_html_invalidator || file_name_changed?
end
default_value_for(:visibility_level) { current_application_settings.default_snippet_visibility }
default_value_for(:visibility_level) { Gitlab::CurrentSettings.default_snippet_visibility }
belongs_to :author, class_name: 'User'
belongs_to :project
......
......@@ -2,10 +2,8 @@ require 'carrierwave/orm/activerecord'
class User < ActiveRecord::Base
extend Gitlab::ConfigHelper
extend Gitlab::CurrentSettings
include Gitlab::ConfigHelper
include Gitlab::CurrentSettings
include Gitlab::SQL::Pattern
include AfterCommitQueue
include Avatarable
......@@ -32,7 +30,7 @@ class User < ActiveRecord::Base
add_authentication_token_field :rss_token
default_value_for :admin, false
default_value_for(:external) { current_application_settings.user_default_external }
default_value_for(:external) { Gitlab::CurrentSettings.user_default_external }
default_value_for :can_create_group, gitlab_config.default_can_create_group
default_value_for :can_create_team, false
default_value_for :hide_no_ssh_key, false
......@@ -678,11 +676,11 @@ class User < ActiveRecord::Base
end
def allow_password_authentication_for_web?
current_application_settings.password_authentication_enabled_for_web? && !ldap_user?
Gitlab::CurrentSettings.password_authentication_enabled_for_web? && !ldap_user?
end
def allow_password_authentication_for_git?
current_application_settings.password_authentication_enabled_for_git? && !ldap_user?
Gitlab::CurrentSettings.password_authentication_enabled_for_git? && !ldap_user?
end
def can_change_username?
......@@ -810,7 +808,7 @@ class User < ActiveRecord::Base
# without this safeguard!
return unless has_attribute?(:projects_limit) && projects_limit.nil?
self.projects_limit = current_application_settings.default_projects_limit
self.projects_limit = Gitlab::CurrentSettings.default_projects_limit
end
def requires_ldap_check?
......@@ -1237,7 +1235,7 @@ class User < ActiveRecord::Base
else
# Only revert these back to the default if they weren't specifically changed in this update.
self.can_create_group = gitlab_config.default_can_create_group unless can_create_group_changed?
self.projects_limit = current_application_settings.default_projects_limit unless projects_limit_changed?
self.projects_limit = Gitlab::CurrentSettings.default_projects_limit unless projects_limit_changed?
end
end
......@@ -1245,15 +1243,15 @@ class User < ActiveRecord::Base
valid = true
error = nil
if current_application_settings.domain_blacklist_enabled?
blocked_domains = current_application_settings.domain_blacklist
if Gitlab::CurrentSettings.domain_blacklist_enabled?
blocked_domains = Gitlab::CurrentSettings.domain_blacklist
if domain_matches?(blocked_domains, email)
error = 'is not from an allowed domain.'
valid = false
end
end
allowed_domains = current_application_settings.domain_whitelist
allowed_domains = Gitlab::CurrentSettings.domain_whitelist
unless allowed_domains.blank?
if domain_matches?(allowed_domains, email)
valid = true
......
class AkismetService
include Gitlab::CurrentSettings
attr_accessor :owner, :text, :options
def initialize(owner, text, options = {})
......@@ -41,12 +39,12 @@ class AkismetService
private
def akismet_client
@akismet_client ||= ::Akismet::Client.new(current_application_settings.akismet_api_key,
@akismet_client ||= ::Akismet::Client.new(Gitlab::CurrentSettings.akismet_api_key,
Gitlab.config.gitlab.url)
end
def akismet_enabled?
current_application_settings.akismet_enabled
Gitlab::CurrentSettings.akismet_enabled
end
def submit(type)
......
module Auth
class ContainerRegistryAuthenticationService < BaseService
extend Gitlab::CurrentSettings
AUDIENCE = 'container_registry'.freeze
def execute(authentication_abilities:)
......@@ -32,7 +30,7 @@ module Auth
end
def self.token_expire_at
Time.now + current_application_settings.container_registry_token_expire_delay.minutes
Time.now + Gitlab::CurrentSettings.container_registry_token_expire_delay.minutes
end
private
......
class BaseService
include Gitlab::Allowable
include Gitlab::CurrentSettings
attr_accessor :project, :current_user, :params
......
......@@ -2,7 +2,6 @@ module Ci
# This class responsible for assigning
# proper pending build to runner on runner API request
class RegisterJobService
include Gitlab::CurrentSettings
prepend EE::Ci::RegisterJobService
attr_reader :runner
......
class GitPushService < BaseService
attr_accessor :push_data, :push_commits
include Gitlab::CurrentSettings
include Gitlab::Access
# The N most recent commits to process in a single push payload.
......@@ -53,7 +52,7 @@ class GitPushService < BaseService
update_gitattributes if default_branch?
end
if current_application_settings.elasticsearch_indexing? && default_branch?
if Gitlab::CurrentSettings.elasticsearch_indexing? && default_branch?
ElasticCommitIndexerWorker.perform_async(@project.id, params[:oldrev], params[:newrev])
end
......
class GravatarService
include Gitlab::CurrentSettings
def execute(email, size = nil, scale = 2, username: nil)
return unless current_application_settings.gravatar_enabled?
return unless Gitlab::CurrentSettings.gravatar_enabled?
identifier = email.presence || username.presence
return unless identifier
......
......@@ -7,8 +7,6 @@
#
module Projects
class HousekeepingService < BaseService
include Gitlab::CurrentSettings
# Timeout set to 24h
LEASE_TIMEOUT = 86400
......@@ -83,19 +81,19 @@ module Projects
end
def housekeeping_enabled?
current_application_settings.housekeeping_enabled
Gitlab::CurrentSettings.housekeeping_enabled
end
def gc_period
current_application_settings.housekeeping_gc_period
Gitlab::CurrentSettings.housekeeping_gc_period
end
def full_repack_period
current_application_settings.housekeeping_full_repack_period
Gitlab::CurrentSettings.housekeeping_full_repack_period
end
def repack_period
current_application_settings.housekeeping_incremental_repack_period
Gitlab::CurrentSettings.housekeeping_incremental_repack_period
end
end
end
module Projects
class UpdatePagesService < BaseService
include Gitlab::CurrentSettings
BLOCK_SIZE = 32.kilobytes
MAX_SIZE = 1.terabyte
SITE_PATH = 'public/'.freeze
......@@ -142,7 +140,7 @@ module Projects
end
def max_size
max_pages_size = current_application_settings.max_pages_size.megabytes
max_pages_size = Gitlab::CurrentSettings.max_pages_size.megabytes
return MAX_SIZE if max_pages_size.zero?
......
......@@ -44,7 +44,7 @@ module Projects
def run_auto_devops_pipeline?
return false if project.repository.gitlab_ci_yml || !project.auto_devops.previous_changes.include?('enabled')
project.auto_devops.enabled? || (project.auto_devops.enabled.nil? && current_application_settings.auto_devops_enabled?)
project.auto_devops.enabled? || (project.auto_devops.enabled.nil? && Gitlab::CurrentSettings.auto_devops_enabled?)
end
private
......
module Search
class GlobalService
include Gitlab::CurrentSettings
attr_accessor :current_user, :params
attr_reader :default_project_filter
......@@ -11,7 +9,7 @@ module Search
end
def execute
if current_application_settings.elasticsearch_search?
if Gitlab::CurrentSettings.elasticsearch_search?
Gitlab::Elastic::SearchResults.new(current_user, params[:search], elastic_projects, elastic_global)
else
Gitlab::SearchResults.new(current_user, projects, params[:search],
......@@ -41,7 +39,7 @@ module Search
def scope
@scope ||= begin
allowed_scopes = %w[issues merge_requests milestones]
allowed_scopes += %w[wiki_blobs blobs commits] if current_application_settings.elasticsearch_search?
allowed_scopes += %w[wiki_blobs blobs commits] if Gitlab::CurrentSettings.elasticsearch_search?
allowed_scopes.delete(params[:scope]) { 'projects' }
end
......
module Search
class ProjectService
include Gitlab::CurrentSettings
attr_accessor :project, :current_user, :params
def initialize(project, user, params)
......@@ -9,7 +7,7 @@ module Search
end
def execute
if current_application_settings.elasticsearch_search?
if Gitlab::CurrentSettings.elasticsearch_search?
Gitlab::Elastic::ProjectSearchResults.new(current_user,
params[:search],
project.id,
......
......@@ -11,10 +11,8 @@ class SubmitUsagePingService
percentage_projects_prometheus_active leader_service_desk_issues instance_service_desk_issues
percentage_service_desk_issues].freeze
include Gitlab::CurrentSettings
def execute
return false unless current_application_settings.usage_ping_enabled?
return false unless Gitlab::CurrentSettings.usage_ping_enabled?
response = HTTParty.post(
URL,
......
class UploadService
include Gitlab::CurrentSettings
def initialize(model, file, uploader_class = FileUploader)
@model, @file, @uploader_class = model, file, uploader_class
end
......@@ -17,6 +15,6 @@ class UploadService
private
def max_attachment_size
current_application_settings.max_attachment_size.megabytes.to_i
Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i
end
end
module Users
class BuildService < BaseService
prepend ::EE::Users::BuildService
include Gitlab::CurrentSettings
def initialize(current_user, params = {})
@current_user = current_user
......@@ -35,7 +34,7 @@ module Users
private
def can_create_user?
(current_user.nil? && current_application_settings.allow_signup?) || current_user&.admin?
(current_user.nil? && Gitlab::CurrentSettings.allow_signup?) || current_user&.admin?
end
# Allowed params for creating a user (admins only)
......@@ -103,7 +102,7 @@ module Users
end
def skip_user_confirmation_email_from_setting
!current_application_settings.send_user_confirmation_email
!Gitlab::CurrentSettings.send_user_confirmation_email
end
end
end
......@@ -6,7 +6,7 @@
= render 'callout'
.prepend-top-default
- if !current_application_settings.usage_ping_enabled
- if !Gitlab::CurrentSettings.usage_ping_enabled
= render 'disabled'
- elsif @metric.blank?
= render 'no_data'
......
......@@ -102,10 +102,10 @@
= boolean_to_icon Gitlab::IncomingEmail.enabled?
- elastic = "Elasticsearch"
%p{ "aria-label" => "#{elastic}: status " + (current_application_settings.elasticsearch_search? ? "on" : "off") }
%p{ "aria-label" => "#{elastic}: status " + (Gitlab::CurrentSettings.elasticsearch_search? ? "on" : "off") }
= elastic
%span.light.pull-right
= boolean_to_icon current_application_settings.elasticsearch_search?
= boolean_to_icon Gitlab::CurrentSettings.elasticsearch_search?
- geo = link_to 'Geo', admin_geo_nodes_path
%p{ "aria-label" => "#{geo}: status " + (Gitlab::Geo.enabled? ? "on" : "off") }
= geo
......@@ -134,7 +134,7 @@
.well-segment.admin-well
%h4
Components
- if current_application_settings.version_check_enabled
- if Gitlab::CurrentSettings.version_check_enabled
.pull-right
= version_status_badge
%p
......
......@@ -4,7 +4,7 @@
= render 'shared/repository_size_limit_setting', form: f, type: :group
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= render 'admin/namespace_plan', f: f
.form-group.group-description-holder
......
......@@ -8,7 +8,7 @@
.pull-left
%p
#{ s_('HealthCheck|Access token is') }
%code#health-check-token= current_application_settings.health_check_access_token
%code#health-check-token= Gitlab::CurrentSettings.health_check_access_token
.prepend-top-10
= button_to _("Reset health check access token"), reset_health_check_token_admin_application_settings_path,
method: :put, class: 'btn btn-default',
......@@ -18,14 +18,14 @@
= link_to s_('More information is available|here'), help_page_path('user/admin_area/monitoring/health_check')
%ul
%li
%code= readiness_url(token: current_application_settings.health_check_access_token)
%code= readiness_url(token: Gitlab::CurrentSettings.health_check_access_token)
%li
%code= liveness_url(token: current_application_settings.health_check_access_token)
%code= liveness_url(token: Gitlab::CurrentSettings.health_check_access_token)
%li
%code= metrics_url(token: current_application_settings.health_check_access_token)
%code= metrics_url(token: Gitlab::CurrentSettings.health_check_access_token)
- if Gitlab::Geo.secondary?
%li
%code= health_check_url(token: current_application_settings.health_check_access_token, checks: :geo)
%code= health_check_url(token: Gitlab::CurrentSettings.health_check_access_token, checks: :geo)
%hr
.panel.panel-default
.panel-heading
......
......@@ -36,7 +36,7 @@
data: { confirm: _("Are you sure you want to reset registration token?") }
= render partial: 'ci/runner/how_to_setup_runner',
locals: { registration_token: current_application_settings.runners_registration_token,
locals: { registration_token: Gitlab::CurrentSettings.runners_registration_token,
type: 'shared' }
.append-bottom-20.clearfix
......
......@@ -42,7 +42,7 @@
= render partial: 'access_levels', locals: { f: f }
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= f.fields_for :namespace do |namespace_form|
%fieldset
%legend Licensed Features
......
......@@ -4,9 +4,9 @@
%p.lead.append-bottom-20
Please check your email to confirm your account
%hr
- if current_application_settings.after_sign_up_text.present?
- if Gitlab::CurrentSettings.after_sign_up_text.present?
.well-confirmation.text-center
= markdown_field(current_application_settings, :after_sign_up_text)
= markdown_field(Gitlab::CurrentSettings, :after_sign_up_text)
%p.text-center
No confirmation email received? Please check your spam folder or
.append-bottom-20.prepend-top-20.text-center
......
= webpack_bundle_tag 'docs'
%div
- if current_application_settings.help_page_text.present?
= markdown(current_application_settings.help_page_text)
- if Gitlab::CurrentSettings.help_page_text.present?
= markdown(Gitlab::CurrentSettings.help_page_text)
%hr
%h1
......@@ -14,7 +14,7 @@
= version_status_badge
%hr
- unless current_application_settings.help_page_hide_commercial_content?
- unless Gitlab::CurrentSettings.help_page_hide_commercial_content?
%p.slead
GitLab is open source software to collaborate on code.
%br
......@@ -46,6 +46,6 @@
%li
%button.btn-blank.btn-link.js-trigger-shortcut{ type: 'button' }
Use shortcuts
- unless current_application_settings.help_page_hide_commercial_content?
- unless Gitlab::CurrentSettings.help_page_hide_commercial_content?
%li= link_to 'Get a support subscription', 'https://about.gitlab.com/pricing/'
%li= link_to 'Compare GitLab editions', 'https://about.gitlab.com/features/#compare'
......@@ -3,4 +3,4 @@
= icon('circle', class: 'cgreen')
Integration is active for
= link_to koding_project_url, target: '_blank', rel: 'noopener noreferrer' do
#{current_application_settings.koding_url}
#{Gitlab::CurrentSettings.koding_url}
......@@ -41,7 +41,7 @@
= webpack_bundle_tag "webpack_runtime"
= webpack_bundle_tag "common"
= webpack_bundle_tag "main"
= webpack_bundle_tag "raven" if current_application_settings.clientside_sentry_enabled
= webpack_bundle_tag "raven" if Gitlab::CurrentSettings.clientside_sentry_enabled
= webpack_bundle_tag "test" if Rails.env.test?
- if content_for?(:page_specific_javascripts)
......
......@@ -26,13 +26,13 @@
Perform code reviews and enhance collaboration with merge requests.
Each project can also have an issue tracker and a wiki.
- if current_application_settings.sign_in_text.present?
= markdown_field(current_application_settings, :sign_in_text)
- if current_application_settings.help_text.present?
- if Gitlab::CurrentSettings.sign_in_text.present?
= markdown_field(Gitlab::CurrentSettings.current_application_settings, :sign_in_text)
- if Gitlab::CurrentSettings.help_text.present?
%h3 Need help?
%hr
%p.slead
= markdown(current_application_settings.help_text)
= markdown(Gitlab::CurrentSettings.help_text)
%hr.footer-fixed
.container.footer-container
......
......@@ -28,7 +28,7 @@
= link_to profile_account_path do
%strong.fly-out-top-item-name
#{ _('Account') }
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= nav_link(controller: :billings) do
= link_to profile_billings_path do
.nav-icon-container
......@@ -40,7 +40,7 @@
= link_to profile_billings_path do
%strong.fly-out-top-item-name
#{ _('Billing') }
- if current_application_settings.user_oauth_applications?
- if Gitlab::CurrentSettings.user_oauth_applications?
= nav_link(controller: 'oauth/applications') do
= link_to applications_profile_path do
.nav-icon-container
......
......@@ -22,7 +22,7 @@
- else
commented on a #{link_to 'discussion', @target_url}
- elsif current_application_settings.email_author_in_body
- elsif Gitlab::CurrentSettings.email_author_in_body
%p.details
#{link_to @note.author_name, user_url(@note.author)} commented:
......
......@@ -12,7 +12,7 @@
<%= ":" -%>
<% elsif current_application_settings.email_author_in_body -%>
<% elsif Gitlab::CurrentSettings.email_author_in_body -%>
<%= "#{@note.author_name} commented:" -%>
......
- if current_application_settings.email_author_in_body
- if Gitlab::CurrentSettings.email_author_in_body
%p.details
#{link_to @issue.author_name, user_url(@issue.author)} created an issue:
......
- if current_application_settings.email_author_in_body
- if Gitlab::CurrentSettings.email_author_in_body
%p.details
#{link_to @merge_request.author_name, user_url(@merge_request.author)} created a merge request:
......
%p
Hi #{@user['name']}!
%p
- if current_application_settings.allow_signup?
- if Gitlab::CurrentSettings.allow_signup?
Your account has been created successfully.
- else
The Administrator created an account for you. Now you are a member of the company GitLab application.
......
- return unless current_application_settings.project_export_enabled?
- return unless Gitlab::CurrentSettings.project_export_enabled?
- project = local_assigns.fetch(:project)
- expanded = Rails.env.test?
......
......@@ -6,7 +6,7 @@
- link = commit_path(project, commit, merge_request: merge_request)
- cache_key = [project.full_path,
commit.id,
current_application_settings,
Gitlab::CurrentSettings.current_application_settings,
@path.presence,
current_controller?(:commits),
merge_request&.iid,
......
......@@ -31,7 +31,7 @@
.radio
= form.label :enabled_ do
= form.radio_button :enabled, ''
%strong Instance default (#{current_application_settings.auto_devops_enabled? ? 'enabled' : 'disabled'})
%strong Instance default (#{Gitlab::CurrentSettings.auto_devops_enabled? ? 'enabled' : 'disabled'})
%br
%span.descr
Follow the instance default to either have Auto DevOps enabled or disabled when there is no project specific <code>.gitlab-ci.yml</code>.
......
%h3 Shared Runners
.bs-callout.bs-callout-warning.shared-runners-description
- if current_application_settings.shared_runners_text.present?
= markdown_field(current_application_settings, :shared_runners_text)
- if Gitlab::CurrentSettings.shared_runners_text.present?
= markdown_field(Gitlab::CurrentSettings.current_application_settings, :shared_runners_text)
- else
GitLab Shared Runners execute code of different projects on the same Runner
unless you configure GitLab Runner Autoscale with MaxBuilds 1 (which it is
......
......@@ -78,7 +78,7 @@
Milestones
%span.badge
= limited_count(@search_results.limited_milestones_count)
- if current_application_settings.elasticsearch_search?
- if Gitlab::CurrentSettings.elasticsearch_search?
%li{ class: active_when(@scope == 'blobs') }
= link_to search_filter_path(scope: 'blobs') do
Code
......
......@@ -13,7 +13,7 @@
- unless params[:snippets].eql? 'true'
= render 'filter'
= button_tag "Search", class: "btn btn-success btn-search"
- if current_application_settings.elasticsearch_search?
- if Gitlab::CurrentSettings.elasticsearch_search?
.help-block
= link_to 'Advanced search functionality', help_page_path('user/search/advanced_search_syntax.md'), target: '_blank'
is enabled.
class GitGarbageCollectWorker
include ApplicationWorker
include Gitlab::CurrentSettings
sidekiq_options retry: false
......@@ -102,7 +101,7 @@ class GitGarbageCollectWorker
end
def bitmaps_enabled?
current_application_settings.housekeeping_bitmaps_enabled
Gitlab::CurrentSettings.housekeeping_bitmaps_enabled
end
def git(write_bitmaps:)
......
......@@ -13,8 +13,6 @@ module Elasticsearch
cattr_accessor :cached_config
module ClassMethods
include Gitlab::CurrentSettings
# Override the default ::Elasticsearch::Model::Client implementation to
# return a client configured from application settings. All including
# classes will use the same instance, which is refreshed automatically
......@@ -28,7 +26,7 @@ module Elasticsearch
store = ::Elasticsearch::Model::Client
store::CLIENT_MUTEX.synchronize do
config = current_application_settings.elasticsearch_config
config = Gitlab::CurrentSettings.elasticsearch_config
if store.cached_client.nil? || config != store.cached_config
store.cached_client = ::Gitlab::Elastic::Client.build(config)
......
......@@ -11,7 +11,7 @@ class Profiles::SlacksController < Profiles::ApplicationController
def slack_link
project = disabled_projects.find(params[:project_id])
link = add_to_slack_link(project, current_application_settings.slack_app_id)
link = add_to_slack_link(project, Gitlab::CurrentSettings.slack_app_id)
render json: { add_to_slack_link: link }
end
......
......@@ -101,7 +101,7 @@ module LicenseHelper
end
def show_advanced_search_promotion?
!current_application_settings.should_check_namespace_plan? && show_promotions? && show_callout?('promote_advanced_search_dismissed') && !License.feature_available?(:elastic_search)
!Gitlab::CurrentSettings.should_check_namespace_plan? && show_promotions? && show_callout?('promote_advanced_search_dismissed') && !License.feature_available?(:elastic_search)
end
extend self
......
......@@ -4,7 +4,6 @@ module Elastic
included do
include Elasticsearch::Model
include Gitlab::CurrentSettings
index_name [Rails.application.class.parent_name.downcase, Rails.env].join('-')
......@@ -39,13 +38,13 @@ module Elastic
}
after_commit on: :create do
if current_application_settings.elasticsearch_indexing? && self.searchable?
if Gitlab::CurrentSettings.elasticsearch_indexing? && self.searchable?
ElasticIndexerWorker.perform_async(:index, self.class.to_s, self.id)
end
end
after_commit on: :update do
if current_application_settings.elasticsearch_indexing? && self.searchable?
if Gitlab::CurrentSettings.elasticsearch_indexing? && self.searchable?
ElasticIndexerWorker.perform_async(
:update,
self.class.to_s,
......@@ -56,7 +55,7 @@ module Elastic
end
after_commit on: :destroy do
if current_application_settings.elasticsearch_indexing? && self.searchable?
if Gitlab::CurrentSettings.elasticsearch_indexing? && self.searchable?
ElasticIndexerWorker.perform_async(
:delete,
self.class.to_s,
......
......@@ -60,7 +60,7 @@ module EE
end
def project_creation_level
super || current_application_settings.default_project_creation
super || ::Gitlab::CurrentSettings.default_project_creation
end
end
end
......@@ -108,7 +108,7 @@ module EE
def actual_shared_runners_minutes_limit
shared_runners_minutes_limit ||
current_application_settings.shared_runners_minutes
::Gitlab::CurrentSettings.shared_runners_minutes
end
def shared_runners_minutes_limit_enabled?
......@@ -170,7 +170,7 @@ module EE
def load_feature_available(feature)
globally_available = License.feature_available?(feature)
if current_application_settings.should_check_namespace_plan?
if ::Gitlab::CurrentSettings.should_check_namespace_plan?
globally_available && feature_available_in_plan?(feature)
else
globally_available
......
......@@ -15,7 +15,7 @@ module EE
before_validation :mark_remote_mirrors_for_removal
before_save :set_override_pull_mirror_available, unless: -> { ::Gitlab::CurrentSettings.current_application_settings.mirror_available }
before_save :set_override_pull_mirror_available, unless: -> { ::Gitlab::CurrentSettings.mirror_available }
after_save :create_mirror_data, if: ->(project) { project.mirror? && project.mirror_changed? }
after_save :destroy_mirror_data, if: ->(project) { !project.mirror? && project.mirror_changed? }
......@@ -449,12 +449,12 @@ module EE
def remote_mirror_available?
remote_mirror_available_overridden ||
current_application_settings.mirror_available
::Gitlab::CurrentSettings.mirror_available
end
def pull_mirror_available?
pull_mirror_available_overridden ||
current_application_settings.mirror_available
::Gitlab::CurrentSettings.mirror_available
end
private
......@@ -477,7 +477,7 @@ module EE
def load_licensed_feature_available(feature)
globally_available = License.feature_available?(feature)
if namespace && current_application_settings.should_check_namespace_plan?
if namespace && ::Gitlab::CurrentSettings.should_check_namespace_plan?
globally_available &&
(public? && namespace.public? || namespace.feature_available_in_plan?(feature))
else
......
class Geo::DeletedProject
include Gitlab::CurrentSettings
attr_reader :id, :name, :disk_path
def initialize(id:, name:, disk_path:, repository_storage:)
......@@ -17,7 +15,7 @@ class Geo::DeletedProject
end
def repository_storage
@repository_storage ||= current_application_settings.pick_repository_storage
@repository_storage ||= Gitlab::CurrentSettings.pick_repository_storage
end
def repository_storage_path
......
......@@ -36,7 +36,7 @@ module EE
end
def application_shared_runners_minutes
current_application_settings.shared_runners_minutes
::Gitlab::CurrentSettings.shared_runners_minutes
end
def shared_runner_build_limits_feature_enabled?
......
module Geo
class NodeStatusFetchService
include Gitlab::CurrentSettings
include HTTParty
def call(geo_node)
......@@ -48,7 +47,7 @@ module Geo
end
def timeout
current_application_settings.geo_status_timeout
Gitlab::CurrentSettings.geo_status_timeout
end
end
end
......@@ -53,8 +53,8 @@ module Projects
def exchange_slack_token
HTTParty.get(SLACK_EXCHANGE_TOKEN_URL, query: {
client_id: current_application_settings.slack_app_id,
client_secret: current_application_settings.slack_app_secret,
client_id: Gitlab::CurrentSettings.slack_app_id,
client_secret: Gitlab::CurrentSettings.slack_app_secret,
redirect_uri: slack_auth_project_settings_slack_url(project),
code: params[:code]
})
......
- namespace = local_assigns[:namespace]
- if current_application_settings.should_check_namespace_plan? && namespace && namespace.plan.present?
- if Gitlab::CurrentSettings.should_check_namespace_plan? && namespace && namespace.plan.present?
%span.plan-badge.has-tooltip{ data: { plan: namespace.plan.name }, title: "#{namespace.plan.title} Plan" }
= custom_icon('icon_premium')
- namespace = local_assigns[:namespace]
- if current_application_settings.should_check_namespace_plan? && namespace
- if Gitlab::CurrentSettings.should_check_namespace_plan? && namespace
%li
%span.light Plan:
- if namespace.plan.present?
......
......@@ -22,7 +22,7 @@
%span
Pipelines quota
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= nav_link(path: 'billings#index') do
= link_to group_billings_path(@group), title: 'Billing' do
%span
......
......@@ -7,5 +7,5 @@
%span.help-block#shared_runners_minutes_limit_help_block
Set the maximum number of pipeline minutes that a group can use on shared Runners per month.
Set 0 for unlimited.
Set empty to inherit the global setting of #{current_application_settings.shared_runners_minutes}.
Set empty to inherit the global setting of #{Gitlab::CurrentSettings.shared_runners_minutes}.
= link_to icon('question-circle'), help_page_path("user/admin_area/settings/continuous_integration", anchor: "shared-runners-build-minutes-quota"), target: '_blank'
- if current_application_settings.email_author_in_body
- if Gitlab::CurrentSettings.email_author_in_body
%div
#{link_to @updated_by.name, user_url(@updated_by)} added you as an approver for:
%p.details
......
- if current_application_settings.email_author_in_body
- if Gitlab::CurrentSettings.email_author_in_body
%div
#{link_to @note.author_name, user_url(@note.author)} wrote:
%div
......
......@@ -4,7 +4,7 @@
Web IDE (Beta)
%p
Enable the new web IDE on this device to make it possible to open and edit multiple files with a single commit.
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Available for public GitLab.com projects or those using Gold.
.col-lg-8.multi-file-editor-options
= label_tag do
......
......@@ -7,7 +7,7 @@
.help-block
Automatically update this project's branches and tags from the upstream
repository every hour. The Git LFS objects will not be synced.
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
.help-block
Mirroring will only be available if the feature is included in the plan of the selected group or user.
......
......@@ -7,7 +7,7 @@
= custom_icon('icon_search_avatar')
.user-callout-copy
%h5
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= _('Upgrade your plan to activate Advanced Global Search.')
- else
= _('Improve search with Advanced Global Search and GitLab Enterprise Edition.')
......
......@@ -3,7 +3,7 @@
= custom_icon('icon_audit_events_purple')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to activate Audit Events.
- else
Track your project with Audit Events.
......
......@@ -7,7 +7,7 @@
= custom_icon('icon_burndown_charts')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to improve milestones with Burndown Charts.
- else
Improve milestones with Burndown Charts.
......
......@@ -3,7 +3,7 @@
= custom_icon('icon_contribution_analytics')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= _('Upgrade your plan to activate Contribution Analytics.')
- else
= _('Track activity with Contribution Analytics.')
......
......@@ -9,7 +9,7 @@
= custom_icon('icon_export_issues')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to export issues.
- else
Export issues with GitLab Enterprise Edition.
......
......@@ -3,7 +3,7 @@
= custom_icon('icon_group_webhook')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= _('Upgrade your plan to activate Group Webhooks.')
- else
= _('Add Group Webhooks and GitLab Enterprise Edition.')
......
......@@ -4,7 +4,7 @@
.svg-container.center
= custom_icon('icon_issue_board')
%p
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= _('Upgrade your plan to improve Issue boards.')
- else
= _('Improve Issue boards with GitLab Enterprise Edition.')
......
......@@ -16,7 +16,7 @@
%i.fa.fa-times.dropdown-menu-close-icon{ "aria-hidden" => "true", "data-hidden" => "true" }
%div
%p
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= _('Upgrade your plan to activate Issue weight.')
- else
= _('Improve issues management with Issue weight and GitLab Enterprise Edition.')
......
......@@ -5,7 +5,7 @@
= icon('times', class: 'dismiss-icon', 'aria-hidden' => 'true')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to improve Merge Requests.
- else
Improve Merge Requests and customer support with GitLab Enterprise Edition.
......
......@@ -7,7 +7,7 @@
= custom_icon('icon_push_rules')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to improve repositories.
- else
Improve repositories with GitLab Enterprise Edition.
......
......@@ -6,7 +6,7 @@
= custom_icon('icon_service_desk')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to activate Service Desk.
- else
Improve customer support with GitLab Service Desk.
......
......@@ -4,7 +4,7 @@
= icon('times', class: 'dismiss-icon', 'aria-hidden' => 'true')
.user-callout-copy
%h4
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
Upgrade your plan to improve Merge Requests with Squash Commit.
- else
Improve Merge Requests with Squash Commit and GitLab Enterprise Edition.
......
- short_form = local_assigns.fetch :short_form, false
- if current_application_settings.should_check_namespace_plan?
- if Gitlab::CurrentSettings.should_check_namespace_plan?
- namespace = @project&.namespace || @group
- if can?(current_user, :admin_namespace, namespace)
= link_to 'Upgrade your plan', upgrade_plan_url, class: 'btn btn-primary'
......
class ElasticBatchProjectIndexerWorker
include ApplicationWorker
include Gitlab::CurrentSettings
# Batch indexing is a generally a onetime option, so give finer control over
# queuing and concurrency
......
class ElasticCommitIndexerWorker
include ApplicationWorker
include Gitlab::CurrentSettings
sidekiq_options retry: 2
def perform(project_id, oldrev = nil, newrev = nil)
return true unless current_application_settings.elasticsearch_indexing?
return true unless Gitlab::CurrentSettings.elasticsearch_indexing?
project = Project.find(project_id)
......
class ElasticIndexerWorker
include ApplicationWorker
include Elasticsearch::Model::Client::ClassMethods
include Gitlab::CurrentSettings
sidekiq_options retry: 2
ISSUE_TRACKED_FIELDS = %w(assignee_ids author_id confidential).freeze
def perform(operation, class_name, record_id, options = {})
return true unless current_application_settings.elasticsearch_indexing?
return true unless Gitlab::CurrentSettings.elasticsearch_indexing?
klass = class_name.constantize
......
......@@ -4,8 +4,6 @@
module Gitlab
module Elastic
class Indexer
include Gitlab::CurrentSettings
EXPERIMENTAL_INDEXER = 'gitlab-elasticsearch-indexer'.freeze
Error = Class.new(StandardError)
......@@ -22,7 +20,7 @@ module Gitlab
# We accept any form of settings, including string and array
# This is why JSON is needed
@vars = {
'ELASTIC_CONNECTION_INFO' => current_application_settings.elasticsearch_config.to_json,
'ELASTIC_CONNECTION_INFO' => Gitlab::CurrentSettings.elasticsearch_config.to_json,
'RAILS_ENV' => Rails.env
}
end
......@@ -50,7 +48,7 @@ module Gitlab
end
def path_to_indexer
if current_application_settings.elasticsearch_experimental_indexer? && self.class.experimental_indexer_present?
if Gitlab::CurrentSettings.elasticsearch_experimental_indexer? && self.class.experimental_indexer_present?
EXPERIMENTAL_INDEXER
else
Rails.root.join('bin', 'elastic_repo_indexer').to_s
......
module Gitlab
module Mirror
extend Gitlab::CurrentSettings
# Runs scheduler every minute
SCHEDULER_CRON = '* * * * *'.freeze
PULL_CAPACITY_KEY = 'MIRROR_PULL_CAPACITY'.freeze
......@@ -65,7 +63,7 @@ module Gitlab
end
def max_delay
current_application_settings.mirror_max_delay.minutes + rand(JITTER)
Gitlab::CurrentSettings.mirror_max_delay.minutes + rand(JITTER)
end
def min_delay_upper_bound
......@@ -77,11 +75,11 @@ module Gitlab
end
def max_capacity
current_application_settings.mirror_max_capacity
Gitlab::CurrentSettings.mirror_max_capacity
end
def capacity_threshold
current_application_settings.mirror_capacity_threshold
Gitlab::CurrentSettings.mirror_capacity_threshold
end
private
......
......@@ -2,7 +2,6 @@ module API
module Helpers
module Runner
prepend EE::API::Helpers::Runner
include Gitlab::CurrentSettings
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
JOB_TOKEN_PARAM = :token
......@@ -10,7 +9,7 @@ module API
def runner_registration_token_valid?
ActiveSupport::SecurityUtils.variable_size_secure_compare(params[:token],
current_application_settings.runners_registration_token)
Gitlab::CurrentSettings.runners_registration_token)
end
def get_runner_version_from_params
......@@ -71,7 +70,7 @@ module API
end
def max_artifacts_size
current_application_settings.max_artifacts_size.megabytes.to_i
Gitlab::CurrentSettings.max_artifacts_size.megabytes.to_i
end
end
end
......
# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class EmailTemplateInterceptor
extend Gitlab::CurrentSettings
def self.delivering_email(message)
# Remove HTML part if HTML emails are disabled.
unless current_application_settings.html_emails_enabled
unless Gitlab::CurrentSettings.html_emails_enabled
message.parts.delete_if do |part|
part.content_type.start_with?('text/html')
end
......
......@@ -6,8 +6,6 @@ module Gitlab
# Parser/renderer for the AsciiDoc format that uses Asciidoctor and filters
# the resulting HTML through HTML pipeline filters.
module Asciidoc
extend Gitlab::CurrentSettings
DEFAULT_ADOC_ATTRS = [
'showtitle', 'idprefix=user-content-', 'idseparator=-', 'env=gitlab',
'env-gitlab', 'source-highlighter=html-pipeline', 'icons=font'
......@@ -33,9 +31,9 @@ module Gitlab
def self.plantuml_setup
Asciidoctor::PlantUml.configure do |conf|
conf.url = current_application_settings.plantuml_url
conf.svg_enable = current_application_settings.plantuml_enabled
conf.png_enable = current_application_settings.plantuml_enabled
conf.url = Gitlab::CurrentSettings.plantuml_url
conf.svg_enable = Gitlab::CurrentSettings.plantuml_enabled
conf.png_enable = Gitlab::CurrentSettings.plantuml_enabled
conf.txt_enable = false
end
end
......
......@@ -15,7 +15,6 @@ module Gitlab
class << self
prepend EE::Gitlab::Auth
include Gitlab::CurrentSettings
def find_for_git_client(login, password, project:, ip:)
raise "Must provide an IP for rate limiting" if ip.nil?
......@@ -58,7 +57,7 @@ module Gitlab
if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication
Gitlab::LDAP::Authentication.login(login, password)
elsif current_application_settings.password_authentication_enabled_for_git?
elsif Gitlab::CurrentSettings.password_authentication_enabled_for_git?
user if user.active? && user.valid_password?(password)
end
end
......@@ -88,7 +87,7 @@ module Gitlab
private
def authenticate_using_internal_or_ldap_password?
current_application_settings.password_authentication_enabled_for_git? || Gitlab::LDAP::Config.enabled?
Gitlab::CurrentSettings.password_authentication_enabled_for_git? || Gitlab::LDAP::Config.enabled?
end
def service_request_check(login, password, project)
......
module Gitlab
module CurrentSettings
extend self
class << self
def current_application_settings
if RequestStore.active?
RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
else
ensure_application_settings!
end
end
def current_application_settings
if RequestStore.active?
RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
else
ensure_application_settings!
def fake_application_settings(defaults = ::ApplicationSetting.defaults)
Gitlab::FakeApplicationSettings.new(defaults)
end
end
delegate :sidekiq_throttling_enabled?, to: :current_application_settings
def method_missing(name, *args, &block)
current_application_settings.send(name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend
end
def fake_application_settings(defaults = ::ApplicationSetting.defaults)
FakeApplicationSettings.new(defaults)
end
def respond_to_missing?(name, include_private = false)
current_application_settings.respond_to?(name, include_private) || super
end
private
private
def ensure_application_settings!
return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
def ensure_application_settings!
return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
cached_application_settings || uncached_application_settings
end
cached_application_settings || uncached_application_settings
end
def cached_application_settings
begin
::ApplicationSetting.cached
rescue ::Redis::BaseError, ::Errno::ENOENT, ::Errno::EADDRNOTAVAIL
# In case Redis isn't running or the Redis UNIX socket file is not available
def cached_application_settings
begin
::ApplicationSetting.cached
rescue ::Redis::BaseError, ::Errno::ENOENT, ::Errno::EADDRNOTAVAIL
# In case Redis isn't running or the Redis UNIX socket file is not available
end
end
end
def uncached_application_settings
return fake_application_settings unless connect_to_db?
def uncached_application_settings
return fake_application_settings unless connect_to_db?
db_settings = ::ApplicationSetting.current
db_settings = ::ApplicationSetting.current
# If there are pending migrations, it's possible there are columns that
# need to be added to the application settings. To prevent Rake tasks
# and other callers from failing, use any loaded settings and return
# defaults for missing columns.
if ActiveRecord::Migrator.needs_migration?
defaults = ::ApplicationSetting.defaults
defaults.merge!(db_settings.attributes.symbolize_keys) if db_settings.present?
return fake_application_settings(defaults)
end
# If there are pending migrations, it's possible there are columns that
# need to be added to the application settings. To prevent Rake tasks
# and other callers from failing, use any loaded settings and return
# defaults for missing columns.
if ActiveRecord::Migrator.needs_migration?
defaults = ::ApplicationSetting.defaults
defaults.merge!(db_settings.attributes.symbolize_keys) if db_settings.present?
return fake_application_settings(defaults)
end
return db_settings if db_settings.present?
return db_settings if db_settings.present?
::ApplicationSetting.create_from_defaults || in_memory_application_settings
end
::ApplicationSetting.create_from_defaults || in_memory_application_settings
end
def in_memory_application_settings
@in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults) # rubocop:disable Gitlab/ModuleWithInstanceVariables
rescue ActiveRecord::StatementInvalid, ActiveRecord::UnknownAttributeError
# In case migrations the application_settings table is not created yet,
# we fallback to a simple OpenStruct
fake_application_settings
end
def in_memory_application_settings
@in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults) # rubocop:disable Gitlab/ModuleWithInstanceVariables
rescue ActiveRecord::StatementInvalid, ActiveRecord::UnknownAttributeError
# In case migrations the application_settings table is not created yet,
# we fallback to a simple OpenStruct
fake_application_settings
end
def connect_to_db?
# When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
active_db_connection = ActiveRecord::Base.connection.active? rescue false
def connect_to_db?
# When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
active_db_connection = ActiveRecord::Base.connection.active? rescue false
active_db_connection &&
ActiveRecord::Base.connection.table_exists?('application_settings')
rescue ActiveRecord::NoDatabaseError
false
active_db_connection &&
ActiveRecord::Base.connection.table_exists?('application_settings')
rescue ActiveRecord::NoDatabaseError
false
end
end
end
end
......@@ -3,12 +3,11 @@
module Gitlab
module GonHelper
include WebpackHelper
include Gitlab::CurrentSettings
def add_gon_variables
gon.api_version = 'v4'
gon.default_avatar_url = URI.join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
gon.max_file_size = current_application_settings.max_attachment_size
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
gon.asset_host = ActionController::Base.asset_host
gon.webpack_public_path = webpack_public_path
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
......@@ -16,7 +15,7 @@ module Gitlab
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.katex_css_url = ActionController::Base.helpers.asset_path('katex.css')
gon.katex_js_url = ActionController::Base.helpers.asset_path('katex.js')
gon.sentry_dsn = current_application_settings.clientside_sentry_dsn if current_application_settings.clientside_sentry_enabled
gon.sentry_dsn = Gitlab::CurrentSettings.clientside_sentry_dsn if Gitlab::CurrentSettings.clientside_sentry_enabled
gon.gitlab_url = Gitlab.config.gitlab.url
gon.revision = Gitlab::REVISION
gon.gitlab_logo = ActionController::Base.helpers.asset_path('gitlab_logo.png')
......
module Gitlab
module LegacyGithubImport
class ProjectCreator
include Gitlab::CurrentSettings
attr_reader :repo, :name, :namespace, :current_user, :session_data, :type
def initialize(repo, name, namespace, current_user, session_data, type: 'github')
......@@ -36,7 +34,7 @@ module Gitlab
end
def visibility_level
repo.private ? Gitlab::VisibilityLevel::PRIVATE : current_application_settings.default_project_visibility
repo.private ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.default_project_visibility
end
#
......
......@@ -71,8 +71,7 @@ module Gitlab
end
def prometheus_metrics_enabled_unmemoized
metrics_folder_present? &&
Gitlab::CurrentSettings.current_application_settings[:prometheus_metrics_enabled] || false
metrics_folder_present? && Gitlab::CurrentSettings.prometheus_metrics_enabled || false
end
end
end
......
......@@ -4,7 +4,6 @@ module Gitlab
module Middleware
class Go
include ActionView::Helpers::TagHelper
include Gitlab::CurrentSettings
PROJECT_PATH_REGEX = %r{\A(#{Gitlab::PathRegex.full_namespace_route_regex}/#{Gitlab::PathRegex.project_route_regex})/}.freeze
......@@ -42,7 +41,7 @@ module Gitlab
project_url = URI.join(config.gitlab.url, path)
import_prefix = strip_url(project_url.to_s)
repository_url = if current_application_settings.enabled_git_access_protocol == 'ssh'
repository_url = if Gitlab::CurrentSettings.enabled_git_access_protocol == 'ssh'
shell = config.gitlab_shell
port = ":#{shell.ssh_port}" unless shell.ssh_port == 22
"ssh://#{shell.ssh_user}@#{shell.ssh_host}#{port}/#{path}.git"
......
module Gitlab
module PerformanceBar
extend Gitlab::CurrentSettings
ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze
EXPIRY_TIME = 5.minutes
......@@ -13,7 +11,7 @@ module Gitlab
end
def self.allowed_group_id
current_application_settings.performance_bar_allowed_group_id
Gitlab::CurrentSettings.performance_bar_allowed_group_id
end
def self.allowed_user_ids
......
module Gitlab
class PollingInterval
extend Gitlab::CurrentSettings
HEADER_NAME = 'Poll-Interval'.freeze
def self.set_header(response, interval:)
if polling_enabled?
multiplier = current_application_settings.polling_interval_multiplier
multiplier = Gitlab::CurrentSettings.polling_interval_multiplier
value = (interval * multiplier).to_i
else
value = -1
......@@ -16,7 +14,7 @@ module Gitlab
end
def self.polling_enabled?
!current_application_settings.polling_interval_multiplier.zero?
!Gitlab::CurrentSettings.polling_interval_multiplier.zero?
end
end
end
module Gitlab
module ProtocolAccess
extend Gitlab::CurrentSettings
def self.allowed?(protocol)
if protocol == 'web'
true
elsif current_application_settings.enabled_git_access_protocol.blank?
elsif Gitlab::CurrentSettings.enabled_git_access_protocol.blank?
true
else
protocol == current_application_settings.enabled_git_access_protocol
protocol == Gitlab::CurrentSettings.enabled_git_access_protocol
end
end
end
......
module Gitlab
module Recaptcha
extend Gitlab::CurrentSettings
def self.load_configurations!
if current_application_settings.recaptcha_enabled
if Gitlab::CurrentSettings.recaptcha_enabled
::Recaptcha.configure do |config|
config.public_key = current_application_settings.recaptcha_site_key
config.private_key = current_application_settings.recaptcha_private_key
config.public_key = Gitlab::CurrentSettings.recaptcha_site_key
config.private_key = Gitlab::CurrentSettings.recaptcha_private_key
end
true
......@@ -14,7 +12,7 @@ module Gitlab
end
def self.enabled?
current_application_settings.recaptcha_enabled
Gitlab::CurrentSettings.recaptcha_enabled
end
end
end
module Gitlab
module Sentry
extend Gitlab::CurrentSettings
def self.enabled?
Rails.env.production? && current_application_settings.sentry_enabled?
Rails.env.production? && Gitlab::CurrentSettings.sentry_enabled?
end
def self.context(current_user = nil)
......
module Gitlab
class UsageData
class << self
include Gitlab::CurrentSettings
def data(force_refresh: false)
Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data }
end
......@@ -19,7 +17,7 @@ module Gitlab
def license_usage_data
usage_data = {
uuid: current_application_settings.uuid,
uuid: Gitlab::CurrentSettings.uuid,
hostname: Gitlab.config.gitlab.host,
version: Gitlab::VERSION,
active_user_count: User.active.count,
......@@ -115,9 +113,9 @@ module Gitlab
def features_usage_data_ce
{
signup: current_application_settings.allow_signup?,
signup: Gitlab::CurrentSettings.allow_signup?,
ldap: Gitlab.config.ldap.enabled,
gravatar: current_application_settings.gravatar_enabled?,
gravatar: Gitlab::CurrentSettings.gravatar_enabled?,
omniauth: Gitlab.config.omniauth.enabled,
reply_by_email: Gitlab::IncomingEmail.enabled?,
container_registry: Gitlab.config.registry.enabled,
......@@ -127,7 +125,7 @@ module Gitlab
def features_usage_data_ee
{
elasticsearch: current_application_settings.elasticsearch_search?,
elasticsearch: Gitlab::CurrentSettings.elasticsearch_search?,
geo: Gitlab::Geo.enabled?
}
end
......
......@@ -5,7 +5,6 @@
#
module Gitlab
module VisibilityLevel
extend CurrentSettings
extend ActiveSupport::Concern
included do
......@@ -58,7 +57,7 @@ module Gitlab
end
def allowed_levels
restricted_levels = current_application_settings.restricted_visibility_levels
restricted_levels = Gitlab::CurrentSettings.restricted_visibility_levels
self.values - restricted_levels
end
......@@ -81,7 +80,7 @@ module Gitlab
end
def non_restricted_level?(level)
restricted_levels = current_application_settings.restricted_visibility_levels
restricted_levels = Gitlab::CurrentSettings.restricted_visibility_levels
if restricted_levels.nil?
true
......
......@@ -5,7 +5,7 @@ describe HealthCheckController do
let(:json_response) { JSON.parse(response.body) }
let(:xml_response) { Hash.from_xml(response.body)['hash'] }
let(:token) { current_application_settings.health_check_access_token }
let(:token) { Gitlab::CurrentSettings.health_check_access_token }
let(:whitelisted_ip) { '127.0.0.1' }
let(:not_whitelisted_ip) { '127.0.0.2' }
......
......@@ -4,7 +4,7 @@ describe HealthController do
include StubENV
let(:json_response) { JSON.parse(response.body) }
let(:token) { current_application_settings.health_check_access_token }
let(:token) { Gitlab::CurrentSettings.health_check_access_token }
let(:whitelisted_ip) { '127.0.0.1' }
let(:not_whitelisted_ip) { '127.0.0.2' }
......
......@@ -16,8 +16,7 @@ describe Oauth::ApplicationsController do
end
it 'redirects back to profile page if OAuth applications are disabled' do
settings = double(user_oauth_applications?: false)
allow_any_instance_of(Gitlab::CurrentSettings).to receive(:current_application_settings).and_return(settings)
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:user_oauth_applications?).and_return(false)
get :index
......
......@@ -69,7 +69,7 @@ describe Projects::Settings::IntegrationsController do
context 'when checking of namespace plan is enabled' do
before do
allow_any_instance_of(Project).to receive_message_chain(:current_application_settings, :should_check_namespace_plan?) { true }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { true }
end
context 'and namespace does not have a plan' do
......@@ -85,7 +85,7 @@ describe Projects::Settings::IntegrationsController do
context 'when checking of namespace plan is not enabled' do
before do
allow_any_instance_of(Project).to receive_message_chain(:current_application_settings, :should_check_namespace_plan?) { false }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:should_check_namespace_plan?) { false }
end
it_behaves_like 'endpoint without disabled services'
......
......@@ -121,7 +121,7 @@ describe Group do
group = create(:group, project_creation_level: nil)
expect(group.project_creation_level).to eq(current_application_settings.default_project_creation)
expect(group.project_creation_level).to eq(Gitlab::CurrentSettings.default_project_creation)
end
end
end
......@@ -19,7 +19,7 @@ describe Projects::DestroyService do
context 'when project is a mirror' do
it 'decrements capacity if mirror was scheduled' do
max_capacity = current_application_settings.mirror_max_capacity
max_capacity = Gitlab::CurrentSettings.mirror_max_capacity
project_mirror = create(:project, :mirror, :repository, :import_scheduled)
Gitlab::Mirror.increment_capacity(project_mirror.id)
......
......@@ -18,7 +18,7 @@ module EE
def enable_namespace_license_check!
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
current_application_settings.update!(check_namespace_plan: true)
::Gitlab::CurrentSettings.update!(check_namespace_plan: true)
end
end
end
......@@ -17,7 +17,7 @@ feature "Admin Health Check", :feature do
page.has_text? 'Health Check'
page.has_text? 'Health information can be retrieved'
token = current_application_settings.health_check_access_token
token = Gitlab::CurrentSettings.health_check_access_token
expect(page).to have_content("Access token is #{token}")
expect(page).to have_selector('#health-check-token', text: token)
......@@ -25,7 +25,7 @@ feature "Admin Health Check", :feature do
describe 'reload access token' do
it 'changes the access token' do
orig_token = current_application_settings.health_check_access_token
orig_token = Gitlab::CurrentSettings.health_check_access_token
click_button 'Reset health check access token'
expect(page).to have_content('New health check access token has been generated!')
......
......@@ -156,7 +156,7 @@ describe "Admin Runners" do
end
describe 'runners registration token' do
let!(:token) { current_application_settings.runners_registration_token }
let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
before do
visit admin_runners_path
......
......@@ -61,12 +61,12 @@ feature 'Admin updates settings' do
uncheck 'Project export enabled'
click_button 'Save'
expect(current_application_settings.gravatar_enabled).to be_falsey
expect(current_application_settings.home_page_url).to eq "https://about.gitlab.com/"
expect(current_application_settings.help_page_text).to eq "Example text"
expect(current_application_settings.help_page_hide_commercial_content).to be_truthy
expect(current_application_settings.help_page_support_url).to eq "http://example.com/help"
expect(current_application_settings.project_export_enabled).to be_falsey
expect(Gitlab::CurrentSettings.gravatar_enabled).to be_falsey
expect(Gitlab::CurrentSettings.home_page_url).to eq "https://about.gitlab.com/"
expect(Gitlab::CurrentSettings.help_page_text).to eq "Example text"
expect(Gitlab::CurrentSettings.help_page_hide_commercial_content).to be_truthy
expect(Gitlab::CurrentSettings.help_page_support_url).to eq "http://example.com/help"
expect(Gitlab::CurrentSettings.project_export_enabled).to be_falsey
expect(page).to have_content "Application settings saved successfully"
end
......
......@@ -9,7 +9,7 @@ describe 'New issue', :js do
before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
current_application_settings.update!(
Gitlab::CurrentSettings.update!(
akismet_enabled: true,
akismet_api_key: 'testkey',
recaptcha_enabled: true,
......
......@@ -4,7 +4,7 @@ describe VersionCheckHelper do
describe '#version_status_badge' do
it 'should return nil if not dev environment and not enabled' do
allow(Rails.env).to receive(:production?) { false }
allow(helper.current_application_settings).to receive(:version_check_enabled) { false }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { false }
expect(helper.version_status_badge).to be(nil)
end
......@@ -12,7 +12,7 @@ describe VersionCheckHelper do
context 'when production and enabled' do
before do
allow(Rails.env).to receive(:production?) { true }
allow(helper.current_application_settings).to receive(:version_check_enabled) { true }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { true }
allow_any_instance_of(VersionCheck).to receive(:url) { 'https://version.host.com/check.svg?gitlab_info=xxx' }
@image_tag = helper.version_status_badge
......
......@@ -8,9 +8,24 @@ describe Gitlab::CurrentSettings do
end
describe '#current_application_settings' do
it 'allows keys to be called directly' do
db_settings = create(:application_setting,
home_page_url: 'http://mydomain.com',
signup_enabled: false)
expect(described_class.home_page_url).to eq(db_settings.home_page_url)
expect(described_class.signup_enabled?).to be_falsey
expect(described_class.signup_enabled).to be_falsey
expect(described_class.metrics_sample_interval).to be(15)
end
context 'with DB available' do
before do
allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(true)
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(true)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
allow(ActiveRecord::Base.connection).to receive(:active?).and_return(true)
allow(ActiveRecord::Base.connection).to receive(:table_exists?).and_call_original
allow(ActiveRecord::Base.connection).to receive(:table_exists?).with('application_settings').and_return(true)
end
# This method returns the ::ApplicationSetting.defaults hash
......@@ -24,14 +39,14 @@ describe Gitlab::CurrentSettings do
it 'attempts to use cached values first' do
expect(ApplicationSetting).to receive(:cached)
expect(current_application_settings).to be_a(ApplicationSetting)
expect(described_class.current_application_settings).to be_a(ApplicationSetting)
end
it 'falls back to DB if Caching returns an empty value' do
expect(ApplicationSetting).to receive(:cached).and_return(nil)
expect(ApplicationSetting).to receive(:last).and_call_original.twice
expect(current_application_settings).to be_a(ApplicationSetting)
expect(described_class.current_application_settings).to be_a(ApplicationSetting)
end
it 'falls back to DB if Caching fails' do
......@@ -40,14 +55,14 @@ describe Gitlab::CurrentSettings do
expect(ApplicationSetting).to receive(:cached).and_raise(::Redis::BaseError)
expect(Rails.cache).to receive(:fetch).with(ApplicationSetting::CACHE_KEY).and_raise(Redis::BaseError)
expect(current_application_settings).to eq(db_settings)
expect(described_class.current_application_settings).to eq(db_settings)
end
it 'creates default ApplicationSettings if none are present' do
expect(ApplicationSetting).to receive(:cached).and_raise(::Redis::BaseError)
expect(Rails.cache).to receive(:fetch).with(ApplicationSetting::CACHE_KEY).and_raise(Redis::BaseError)
settings = current_application_settings
settings = described_class.current_application_settings
expect(settings).to be_a(ApplicationSetting)
expect(settings).to be_persisted
......@@ -60,7 +75,7 @@ describe Gitlab::CurrentSettings do
end
it 'returns an in-memory ApplicationSetting object' do
settings = current_application_settings
settings = described_class.current_application_settings
expect(settings).to be_a(OpenStruct)
expect(settings.sign_in_enabled?).to eq(settings.sign_in_enabled)
......@@ -71,7 +86,7 @@ describe Gitlab::CurrentSettings do
db_settings = create(:application_setting,
home_page_url: 'http://mydomain.com',
signup_enabled: false)
settings = current_application_settings
settings = described_class.current_application_settings
app_defaults = ApplicationSetting.last
expect(settings).to be_a(OpenStruct)
......@@ -88,15 +103,16 @@ describe Gitlab::CurrentSettings do
context 'with DB unavailable' do
before do
allow_any_instance_of(described_class).to receive(:connect_to_db?).and_return(false)
allow_any_instance_of(described_class).to receive(:retrieve_settings_from_database_cache?).and_return(nil)
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
allow(ActiveRecord::Base.connection).to receive(:active?).and_return(false)
end
it 'returns an in-memory ApplicationSetting object' do
expect(ApplicationSetting).not_to receive(:current)
expect(ApplicationSetting).not_to receive(:last)
expect(current_application_settings).to be_a(OpenStruct)
expect(described_class.current_application_settings).to be_a(OpenStruct)
end
end
......@@ -109,8 +125,8 @@ describe Gitlab::CurrentSettings do
expect(ApplicationSetting).not_to receive(:current)
expect(ApplicationSetting).not_to receive(:last)
expect(current_application_settings).to be_a(ApplicationSetting)
expect(current_application_settings).not_to be_persisted
expect(described_class.current_application_settings).to be_a(ApplicationSetting)
expect(described_class.current_application_settings).not_to be_persisted
end
end
end
......
......@@ -51,7 +51,7 @@ describe Gitlab::Elastic::Indexer do
],
nil,
hash_including(
'ELASTIC_CONNECTION_INFO' => current_application_settings.elasticsearch_config.to_json,
'ELASTIC_CONNECTION_INFO' => Gitlab::CurrentSettings.elasticsearch_config.to_json,
'RAILS_ENV' => Rails.env,
'FROM_SHA' => from_sha,
'TO_SHA' => to_sha
......
......@@ -20,7 +20,7 @@ describe Gitlab::Metrics do
context 'prometheus metrics enabled in config' do
before do
allow(Gitlab::CurrentSettings).to receive(:current_application_settings).and_return(prometheus_metrics_enabled: true)
allow(Gitlab::CurrentSettings).to receive(:prometheus_metrics_enabled).and_return(true)
end
context 'when metrics folder is present' do
......
require 'spec_helper'
describe Gitlab::Mirror do
include Gitlab::CurrentSettings
before do
Sidekiq::Logging.logger = nil
end
......@@ -66,7 +64,7 @@ describe Gitlab::Mirror do
end
describe '#reschedule_immediately?' do
let(:mirror_capacity_threshold) { current_application_settings.mirror_capacity_threshold }
let(:mirror_capacity_threshold) { Gitlab::CurrentSettings.mirror_capacity_threshold }
context 'with number of mirrors to sync equal to the available capacity' do
it 'returns true if available capacity surpassed defined threshold' do
......@@ -128,7 +126,7 @@ describe Gitlab::Mirror do
describe '#available_capacity' do
context 'when redis key does not exist' do
it 'returns mirror_max_capacity' do
expect(described_class.available_capacity).to eq(current_application_settings.mirror_max_capacity)
expect(described_class.available_capacity).to eq(Gitlab::CurrentSettings.mirror_max_capacity)
end
end
......@@ -142,7 +140,7 @@ describe Gitlab::Mirror do
end
end
expect(described_class.available_capacity).to eq(current_application_settings.mirror_max_capacity - current_capacity)
expect(described_class.available_capacity).to eq(Gitlab::CurrentSettings.mirror_max_capacity - current_capacity)
end
end
......@@ -153,7 +151,7 @@ describe Gitlab::Mirror do
describe '#increment_capacity' do
it 'increments capacity' do
max_capacity = current_application_settings.mirror_max_capacity
max_capacity = Gitlab::CurrentSettings.mirror_max_capacity
expect { described_class.increment_capacity(1) }.to change { described_class.available_capacity }.from(max_capacity).to(max_capacity - 1)
end
......@@ -168,7 +166,7 @@ describe Gitlab::Mirror do
context 'with capacity above 0' do
it 'decrements capacity' do
max_capacity = current_application_settings.mirror_max_capacity
max_capacity = Gitlab::CurrentSettings.mirror_max_capacity
described_class.increment_capacity(id)
......
......@@ -121,9 +121,9 @@ describe Gitlab::UsageData do
subject { described_class.features_usage_data_ce }
it 'gathers feature usage data' do
expect(subject[:signup]).to eq(current_application_settings.allow_signup?)
expect(subject[:signup]).to eq(Gitlab::CurrentSettings.allow_signup?)
expect(subject[:ldap]).to eq(Gitlab.config.ldap.enabled)
expect(subject[:gravatar]).to eq(current_application_settings.gravatar_enabled?)
expect(subject[:gravatar]).to eq(Gitlab::CurrentSettings.gravatar_enabled?)
expect(subject[:omniauth]).to eq(Gitlab.config.omniauth.enabled)
expect(subject[:reply_by_email]).to eq(Gitlab::IncomingEmail.enabled?)
expect(subject[:container_registry]).to eq(Gitlab.config.registry.enabled)
......@@ -135,7 +135,7 @@ describe Gitlab::UsageData do
subject { described_class.features_usage_data_ee }
it 'gathers feature usage data of EE' do
expect(subject[:elasticsearch]).to eq(current_application_settings.elasticsearch_search?)
expect(subject[:elasticsearch]).to eq(Gitlab::CurrentSettings.elasticsearch_search?)
expect(subject[:geo]).to eq(Gitlab::Geo.enabled?)
end
end
......@@ -158,7 +158,7 @@ describe Gitlab::UsageData do
it "gathers license data" do
license = ::License.current
expect(subject[:uuid]).to eq(current_application_settings.uuid)
expect(subject[:uuid]).to eq(Gitlab::CurrentSettings.uuid)
expect(subject[:license_md5]).to eq(Digest::MD5.hexdigest(license.data))
expect(subject[:version]).to eq(Gitlab::VERSION)
expect(subject[:licensee]).to eq(license.licensee)
......
require 'spec_helper'
describe Key, :mailer do
include Gitlab::CurrentSettings
describe 'modules' do
subject { described_class }
it { is_expected.to include_module(Gitlab::CurrentSettings) }
end
describe "Associations" do
it { is_expected.to belong_to(:user) }
end
......
......@@ -17,8 +17,6 @@ describe Note do
it { is_expected.to include_module(Participable) }
it { is_expected.to include_module(Mentionable) }
it { is_expected.to include_module(Awardable) }
it { is_expected.to include_module(Gitlab::CurrentSettings) }
end
describe 'validation' do
......
require 'rails_helper'
describe ProjectMirrorData, type: :model do
include Gitlab::CurrentSettings
describe 'associations' do
it { is_expected.to belong_to(:project) }
end
......@@ -100,7 +98,7 @@ describe ProjectMirrorData, type: :model do
end
context 'when base delay is higher than mirror_max_delay' do
let(:max_timestamp) { timestamp + current_application_settings.mirror_max_delay.minutes }
let(:max_timestamp) { timestamp + Gitlab::CurrentSettings.mirror_max_delay.minutes }
before do
mirror_data.last_update_started_at = timestamp - 1.hour
......
......@@ -109,7 +109,6 @@ describe Project do
it { is_expected.to include_module(Gitlab::ConfigHelper) }
it { is_expected.to include_module(Gitlab::ShellAdapter) }
it { is_expected.to include_module(Gitlab::VisibilityLevel) }
it { is_expected.to include_module(Gitlab::CurrentSettings) }
it { is_expected.to include_module(Referable) }
it { is_expected.to include_module(Sortable) }
end
......
require 'spec_helper'
describe User do
include Gitlab::CurrentSettings
include ProjectForksHelper
describe 'modules' do
subject { described_class }
it { is_expected.to include_module(Gitlab::ConfigHelper) }
it { is_expected.to include_module(Gitlab::CurrentSettings) }
it { is_expected.to include_module(Referable) }
it { is_expected.to include_module(Sortable) }
it { is_expected.to include_module(TokenAuthenticatable) }
......@@ -588,7 +586,7 @@ describe User do
stub_config_setting(default_can_create_group: true)
expect { user.update_attributes(external: false) }.to change { user.can_create_group }.to(true)
.and change { user.projects_limit }.to(current_application_settings.default_projects_limit)
.and change { user.projects_limit }.to(Gitlab::CurrentSettings.default_projects_limit)
end
end
......@@ -854,7 +852,7 @@ describe User do
end
end
context 'when current_application_settings.user_default_external is true' do
context 'when Gitlab::CurrentSettings.user_default_external is true' do
before do
stub_application_setting(user_default_external: true)
end
......
......@@ -2,8 +2,6 @@
require 'spec_helper'
describe API::Projects do
include Gitlab::CurrentSettings
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
......
require 'spec_helper'
describe API::V3::Projects do
include Gitlab::CurrentSettings
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
......
......@@ -15,9 +15,7 @@ RSpec.configure do |config|
# Track the maximum number of failures
first_failure = Time.parse("2017-11-14 17:52:30")
last_failure = Time.parse("2017-11-14 18:54:37")
failure_count = Gitlab::CurrentSettings
.current_application_settings
.circuitbreaker_failure_count_threshold + 1
failure_count = Gitlab::CurrentSettings.circuitbreaker_failure_count_threshold + 1
cache_key = "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}broken:#{Gitlab::Environment.hostname}"
Gitlab::Git::Storage.redis.with do |redis|
......
# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
module StubENV
include Gitlab::CurrentSettings
def stub_env(key_or_hash, value = nil)
init_stub unless env_stubbed?
......
......@@ -9,7 +9,7 @@ shared_context 'unique ips sign in limit' do
before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
current_application_settings.update!(
Gitlab::CurrentSettings.update!(
unique_ips_limit_enabled: true,
unique_ips_limit_time_window: 10000
)
......@@ -34,7 +34,7 @@ end
shared_examples 'user login operation with unique ip limit' do
include_context 'unique ips sign in limit' do
before do
current_application_settings.update!(unique_ips_limit_per_user: 1)
Gitlab::CurrentSettings.update!(unique_ips_limit_per_user: 1)
end
it 'allows user authenticating from the same ip' do
......@@ -52,7 +52,7 @@ end
shared_examples 'user login request with unique ip limit' do |success_status = 200|
include_context 'unique ips sign in limit' do
before do
current_application_settings.update!(unique_ips_limit_per_user: 1)
Gitlab::CurrentSettings.update!(unique_ips_limit_per_user: 1)
end
it 'allows user authenticating from the same ip' do
......
require 'spec_helper'
describe ElasticIndexerWorker, elastic: true do
include Gitlab::CurrentSettings
subject { described_class.new }
before do
stub_application_setting(elasticsearch_indexing: true)
Elasticsearch::Model.client =
Gitlab::Elastic::Client.build(current_application_settings.elasticsearch_config)
Gitlab::Elastic::Client.build(Gitlab::CurrentSettings.elasticsearch_config)
Gitlab::Elastic::Helper.create_empty_index
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