diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-22 16:35:08 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:32:42 -0600 |
commit | b3ff48c9a1d61b22ab4040ebcdc64eeeb797ad44 (patch) | |
tree | e73552a1d8f27dd510e0bde264b6d24648fc2bfc /app | |
parent | 0a5b670a9392f7f8c02e83f1c2e3ed4d2d67cfde (diff) | |
download | gitlab-ce-b3ff48c9a1d61b22ab4040ebcdc64eeeb797ad44.tar.gz |
Move up delegate calls
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | app/models/commit_status.rb | 3 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 22 | ||||
-rw-r--r-- | app/models/member.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 7 |
7 files changed, 23 insertions, 27 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index d2a53315f1d..3a17d5c8dbe 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -22,6 +22,8 @@ module Ci serialize :options serialize :yaml_variables, Gitlab::Serializer::Ci::Variables + delegate :name, to: :project, prefix: true + validates :coverage, numericality: true, allow_blank: true validates :ref, presence: true @@ -233,8 +235,6 @@ module Ci gl_project_id end - delegate :name, to: :project, prefix: true - def repo_url auth = "gitlab-ci-token:#{ensure_token!}@" project.http_url_to_repo.sub(/^https?:\/\//) do |prefix| diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index d2312215f85..632178de887 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -14,6 +14,8 @@ module Ci has_many :builds, foreign_key: :commit_id has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id + delegate :id, to: :project, prefix: true + validates :sha, presence: { unless: :importing? } validates :ref, presence: { unless: :importing? } validates :status, presence: { unless: :importing? } @@ -153,8 +155,6 @@ module Ci builds.latest.with_artifacts_not_expired.includes(project: [:namespace]) end - delegate :id, to: :project, prefix: true - # For now the only user who participates is the user who triggered def participants(_current_user = nil) Array(user) diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index df835b99189..fc750a3e5e9 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -10,6 +10,7 @@ class CommitStatus < ActiveRecord::Base belongs_to :user delegate :commit, to: :pipeline + delegate :sha, :short_sha, to: :pipeline validates :pipeline, presence: true, unless: :importing? @@ -102,8 +103,6 @@ class CommitStatus < ActiveRecord::Base end end - delegate :sha, :short_sha, to: :pipeline - def before_sha pipeline.before_sha || Gitlab::Git::BLANK_SHA end diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 8b33e776e87..fcb335e48d1 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -46,6 +46,17 @@ module Issuable has_one :metrics + delegate :name, + :email, + to: :author, + prefix: true + + delegate :name, + :email, + to: :assignee, + allow_nil: true, + prefix: true + validates :author, presence: true validates :title, presence: true, length: { maximum: 255 } @@ -72,17 +83,6 @@ module Issuable scope :references_project, -> { references(:project) } scope :non_archived, -> { join_project.where(projects: { archived: false }) } - delegate :name, - :email, - to: :author, - prefix: true - - delegate :name, - :email, - to: :assignee, - allow_nil: true, - prefix: true - attr_mentionable :title, pipeline: :single_line attr_mentionable :description diff --git a/app/models/member.rb b/app/models/member.rb index 2ea4abacea4..f198fbe9056 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -10,6 +10,8 @@ class Member < ActiveRecord::Base belongs_to :user belongs_to :source, polymorphic: true + delegate :name, :username, :email, to: :user, prefix: true + validates :user, presence: true, unless: :invite? validates :source, presence: true validates :user_id, uniqueness: { scope: [:source_type, :source_id], @@ -73,8 +75,6 @@ class Member < ActiveRecord::Base after_destroy :post_destroy_hook, unless: :pending? after_commit :refresh_member_authorized_projects - delegate :name, :username, :email, to: :user, prefix: true - default_value_for :notification_level, NotificationSetting.levels[:global] class << self diff --git a/app/models/project.rb b/app/models/project.rb index a1b29d335b3..698e742de48 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -172,9 +172,11 @@ class Project < ActiveRecord::Base accepts_nested_attributes_for :project_feature delegate :name, to: :owner, allow_nil: true, prefix: true + delegate :count, to: :forks, prefix: true delegate :members, to: :team, prefix: true delegate :add_user, to: :team delegate :add_guest, :add_reporter, :add_developer, :add_master, to: :team + delegate :empty_repo?, to: :repository # Validations validates :creator, presence: true, on: :create @@ -838,8 +840,6 @@ class Project < ActiveRecord::Base false end - delegate :empty_repo?, to: :repository - def repo repository.raw end @@ -1027,8 +1027,6 @@ class Project < ActiveRecord::Base forked? && project == forked_from_project end - delegate :count, to: :forks, prefix: true - def origin_merge_requests merge_requests.where(source_project_id: self.id) end diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 2f55b853232..9891f5edf41 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -19,6 +19,9 @@ class ProjectWiki @user = user end + delegate :empty?, to: :pages + delegate :repository_storage_path, to: :project + def path @project.path + '.wiki' end @@ -60,8 +63,6 @@ class ProjectWiki !!repository.exists? end - delegate :empty?, to: :pages - # Returns an Array of Gitlab WikiPage instances or an # empty Array if this Wiki has no pages. def pages @@ -158,8 +159,6 @@ class ProjectWiki } end - delegate :repository_storage_path, to: :project - private def init_repo(path_with_namespace) |