Commit 52e0df5c23b94cc8f2929a97bc2211fd51bc1de4
1 parent
e2d94e07
Exists in
master
and in
4 other branches
class.self methods moved to scopes
Showing
2 changed files
with
4 additions
and
19 deletions
Show diff stats
app/models/merge_request.rb
| ... | ... | @@ -81,24 +81,9 @@ class MergeRequest < ActiveRecord::Base |
| 81 | 81 | validate :validate_branches |
| 82 | 82 | |
| 83 | 83 | scope :merged, -> { with_state(:merged) } |
| 84 | - | |
| 85 | - class << self | |
| 86 | - def find_all_by_branch(branch_name) | |
| 87 | - where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) | |
| 88 | - end | |
| 89 | - | |
| 90 | - def cared(user) | |
| 91 | - where('assignee_id = :user OR author_id = :user', user: user.id) | |
| 92 | - end | |
| 93 | - | |
| 94 | - def find_all_by_branch(branch_name) | |
| 95 | - where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) | |
| 96 | - end | |
| 97 | - | |
| 98 | - def find_all_by_milestone(milestone) | |
| 99 | - where("milestone_id = :milestone_id", milestone_id: milestone) | |
| 100 | - end | |
| 101 | - end | |
| 84 | + scope :by_branch, ->(branch_name) { where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) } | |
| 85 | + scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) } | |
| 86 | + scope :by_milestone, ->(milestone) { where("milestone_id = :milestone_id", milestone_id: milestone) } | |
| 102 | 87 | |
| 103 | 88 | # DEPRECATED: Please use human_merge_status_name instead |
| 104 | 89 | def human_merge_status | ... | ... |
app/models/project.rb
| ... | ... | @@ -424,7 +424,7 @@ class Project < ActiveRecord::Base |
| 424 | 424 | c_ids = self.repository.commits_between(oldrev, newrev).map(&:id) |
| 425 | 425 | |
| 426 | 426 | # Update code for merge requests |
| 427 | - mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all | |
| 427 | + mrs = self.merge_requests.opened.by_branch(branch_name).all | |
| 428 | 428 | mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked } |
| 429 | 429 | |
| 430 | 430 | # Close merge requests | ... | ... |