Commit 9298d37b authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '6021-extract-ee-services' into 'master'

Resolve "Extract EE specific files/lines for some service objects"

Closes #6021

See merge request gitlab-org/gitlab-ee!5796
parents caf07c9b a05f0a46
module ApplicationSettings module ApplicationSettings
class UpdateService < ApplicationSettings::BaseService class UpdateService < ApplicationSettings::BaseService
def execute prepend EE::ApplicationSettings::UpdateService
# Repository size limit comes as MB from the view
limit = @params.delete(:repository_size_limit) attr_reader :params, :application_setting
@application_setting.repository_size_limit = Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
def execute
update_terms(@params.delete(:terms)) update_terms(@params.delete(:terms))
if params.key?(:performance_bar_allowed_group_path) if params.key?(:performance_bar_allowed_group_path)
......
...@@ -4,7 +4,7 @@ module Applications ...@@ -4,7 +4,7 @@ module Applications
def initialize(current_user, params) def initialize(current_user, params)
@current_user = current_user @current_user = current_user
@params = params @params = params.except(:ip_address)
end end
def execute(request = nil) def execute(request = nil)
......
module Commits module Commits
class CreateService < ::BaseService class CreateService < ::BaseService
prepend EE::Commits::CreateService
ValidationError = Class.new(StandardError) ValidationError = Class.new(StandardError)
ChangeError = Class.new(StandardError) ChangeError = Class.new(StandardError)
...@@ -37,7 +39,6 @@ module Commits ...@@ -37,7 +39,6 @@ module Commits
def validate! def validate!
validate_permissions! validate_permissions!
validate_repository_size!
validate_on_branch! validate_on_branch!
validate_branch_existance! validate_branch_existance!
...@@ -52,12 +53,6 @@ module Commits ...@@ -52,12 +53,6 @@ module Commits
end end
end end
def validate_repository_size!
if project.above_size_limit?
raise_error(Gitlab::RepositorySizeError.new(project).commit_error)
end
end
def validate_on_branch! def validate_on_branch!
if !@start_project.empty_repo? && !@start_project.repository.branch_exists?(@start_branch) if !@start_project.empty_repo? && !@start_project.repository.branch_exists?(@start_branch)
raise_error('You can only create or edit files when you are on a branch') raise_error('You can only create or edit files when you are on a branch')
......
module EE
module ApplicationSettings
module UpdateService
extend ::Gitlab::Utils::Override
extend ActiveSupport::Concern
override :execute
def execute
# Repository size limit comes as MB from the view
limit = params.delete(:repository_size_limit)
application_setting.repository_size_limit = ::Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
super
end
end
end
end
module EE
module Commits
module CreateService
extend ::Gitlab::Utils::Override
private
override :validate!
def validate!
super
validate_repository_size!
end
def validate_repository_size!
if project.above_size_limit?
raise_error(Gitlab::RepositorySizeError.new(project).commit_error)
end
end
end
end
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