diff options
author | James Lopez <james@jameslopez.es> | 2016-06-01 18:03:51 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-01 18:03:51 +0200 |
commit | 7c8359b7441c2631ceec3bd3783a9761646a9f99 (patch) | |
tree | f684e27f73b13e2322cc80e91a1b0f6ac7d1b4a4 /app/models/merge_request.rb | |
parent | 6782cd3cf6bd298c0c26538db35704bf13fcabb3 (diff) | |
download | gitlab-ce-7c8359b7441c2631ceec3bd3783a9761646a9f99.tar.gz |
started refactoring some stuff based on MR feedback
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 916329e04d6..c771968627c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -34,6 +34,7 @@ class MergeRequest < ActiveRecord::Base include Referable include Sortable include Taskable + include Importable belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project" belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project" @@ -48,8 +49,6 @@ class MergeRequest < ActiveRecord::Base delegate :commits, :diffs, :real_size, to: :merge_request_diff, prefix: nil - attr_accessor :importing - # When this attribute is true some MR validation is ignored # It allows us to close or modify broken merge requests attr_accessor :allow_broken @@ -123,12 +122,12 @@ class MergeRequest < ActiveRecord::Base end end - validates :source_project, presence: true, unless: [:allow_broken, :importing] + validates :source_project, presence: true, unless: [:allow_broken, :importing?] validates :source_branch, presence: true validates :target_project, presence: true validates :target_branch, presence: true validates :merge_user, presence: true, if: :merge_when_build_succeeds? - validate :validate_branches, unless: [:allow_broken, :importing] + validate :validate_branches, unless: [:allow_broken, :importing?] validate :validate_fork scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } |