diff options
-rw-r--r-- | app/models/commit.rb | 6 | ||||
-rw-r--r-- | lib/file_size_validator.rb | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index d1f07ccd55c..f5d1e242e75 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -12,11 +12,11 @@ class Commit attr_accessor :project - DIFF_SAFE_LINES = Gitlab::Git::DiffCollection::DEFAULT_LIMITS[:max_lines] + DIFF_SAFE_LINES ||= Gitlab::Git::DiffCollection::DEFAULT_LIMITS[:max_lines] # Commits above this size will not be rendered in HTML - DIFF_HARD_LIMIT_FILES = 1000 unless defined?(DIFF_HARD_LIMIT_FILES) - DIFF_HARD_LIMIT_LINES = 50000 unless defined?(DIFF_HARD_LIMIT_LINES) + DIFF_HARD_LIMIT_FILES ||= 1000 + DIFF_HARD_LIMIT_LINES ||= 50000 class << self def decorate(commits, project) diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 2eae55e534b..7b136c2bbe5 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -1,9 +1,9 @@ class FileSizeValidator < ActiveModel::EachValidator - MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze - CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze + MESSAGES ||= { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze + CHECKS ||= { is: :==, minimum: :>=, maximum: :<= }.freeze - DEFAULT_TOKENIZER = lambda { |value| value.split(//) } - RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long] + DEFAULT_TOKENIZER ||= -> (value) { value.split(//) }.freeze + RESERVED_OPTIONS ||= [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long].freeze def initialize(options) if range = (options.delete(:in) || options.delete(:within)) |