diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /app/models/namespace.rb | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r-- | app/models/namespace.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index f7592532c5b..6e173e2549b 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -24,8 +24,8 @@ class Namespace < ApplicationRecord has_many :projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :project_statistics - has_many :runner_namespaces, inverse_of: :namespace, class_name: 'Ci::RunnerNamespace' - has_many :runners, through: :runner_namespaces, source: :runner, class_name: 'Ci::Runner' + has_many :runner_namespaces, inverse_of: :namespace, class_name: "Ci::RunnerNamespace" + has_many :runners, through: :runner_namespaces, source: :runner, class_name: "Ci::Runner" # This should _not_ be `inverse_of: :namespace`, because that would also set # `user.namespace` when this user creates a group with themselves as `owner`. @@ -38,20 +38,20 @@ class Namespace < ApplicationRecord validates :owner, presence: true, unless: ->(n) { n.type == "Group" } validates :name, presence: true, - length: { maximum: 255 }, + length: {maximum: 255}, namespace_name: true - validates :description, length: { maximum: 255 } + validates :description, length: {maximum: 255} validates :path, presence: true, - length: { maximum: 255 }, + length: {maximum: 255}, namespace_path: true validate :nesting_level_allowed delegate :name, to: :owner, allow_nil: true, prefix: true - after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') } + after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?("share_with_group_lock") } before_create :sync_share_with_group_lock_with_parent before_update :sync_share_with_group_lock_with_parent, if: :parent_changed? @@ -63,23 +63,23 @@ class Namespace < ApplicationRecord before_destroy(prepend: true) { prepare_for_destroy } after_destroy :rm_dir - scope :for_user, -> { where('type IS NULL') } + scope :for_user, -> { where("type IS NULL") } scope :with_statistics, -> do - joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id') - .group('namespaces.id') + joins("LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id") + .group("namespaces.id") .select( - 'namespaces.*', - 'COALESCE(SUM(ps.storage_size), 0) AS storage_size', - 'COALESCE(SUM(ps.repository_size), 0) AS repository_size', - 'COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size', - 'COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size' + "namespaces.*", + "COALESCE(SUM(ps.storage_size), 0) AS storage_size", + "COALESCE(SUM(ps.repository_size), 0) AS repository_size", + "COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size", + "COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size" ) end class << self def by_path(path) - find_by('lower(path) = :value', value: path.downcase) + find_by("lower(path) = :value", value: path.downcase) end # Case insensitive search for namespace by path or name @@ -145,18 +145,18 @@ class Namespace < ApplicationRecord end def kind - type == 'Group' ? 'group' : 'user' + type == "Group" ? "group" : "user" end def find_fork_of(project) return nil unless project.fork_network if Gitlab::SafeRequestStore.active? - forks_in_namespace = Gitlab::SafeRequestStore.fetch("namespaces:#{id}:forked_projects") do + forks_in_namespace = Gitlab::SafeRequestStore.fetch("namespaces:#{id}:forked_projects") { Hash.new do |found_forks, project| found_forks[project] = project.fork_network.find_forks_in(projects).first end - end + } forks_in_namespace[project] else @@ -259,7 +259,7 @@ class Namespace < ApplicationRecord path_was else previous_parent = Group.find_by(id: parent_id_was) - previous_parent.full_path + '/' + path_was + previous_parent.full_path + "/" + path_was end end @@ -276,7 +276,7 @@ class Namespace < ApplicationRecord def refresh_access_of_projects_invited_groups Group .joins(project_group_links: :project) - .where(projects: { namespace_id: id }) + .where(projects: {namespace_id: id}) .find_each(&:refresh_members_authorized_projects) end |