Commit bfc359ca61bd7e7ffea714b4ad64a7d9927441c3
1 parent
ba937b2b
Exists in
master
and in
4 other branches
Fix project filter for MR on dashboard
Showing
4 changed files
with
22 additions
and
9 deletions
Show diff stats
app/helpers/dashboard_helper.rb
app/models/issue.rb
| @@ -24,7 +24,13 @@ class Issue < ActiveRecord::Base | @@ -24,7 +24,13 @@ class Issue < ActiveRecord::Base | ||
| 24 | 24 | ||
| 25 | acts_as_taggable_on :labels | 25 | acts_as_taggable_on :labels |
| 26 | 26 | ||
| 27 | - def self.open_for(user) | ||
| 28 | - opened.assigned(user) | 27 | + class << self |
| 28 | + def cared(user) | ||
| 29 | + where('assignee_id = :user', user: user.id) | ||
| 30 | + end | ||
| 31 | + | ||
| 32 | + def open_for(user) | ||
| 33 | + opened.assigned(user) | ||
| 34 | + end | ||
| 29 | end | 35 | end |
| 30 | end | 36 | end |
app/models/merge_request.rb
| @@ -43,12 +43,19 @@ class MergeRequest < ActiveRecord::Base | @@ -43,12 +43,19 @@ class MergeRequest < ActiveRecord::Base | ||
| 43 | validates :target_branch, presence: true | 43 | validates :target_branch, presence: true |
| 44 | validate :validate_branches | 44 | validate :validate_branches |
| 45 | 45 | ||
| 46 | - def self.find_all_by_branch(branch_name) | ||
| 47 | - where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) | ||
| 48 | - end | ||
| 49 | 46 | ||
| 50 | - def self.find_all_by_milestone(milestone) | ||
| 51 | - where("milestone_id = :milestone_id", milestone_id: milestone) | 47 | + class << self |
| 48 | + def cared(user) | ||
| 49 | + where('assignee_id = :user OR author_id = :user', user: user.id) | ||
| 50 | + end | ||
| 51 | + | ||
| 52 | + def find_all_by_branch(branch_name) | ||
| 53 | + where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) | ||
| 54 | + end | ||
| 55 | + | ||
| 56 | + def find_all_by_milestone(milestone) | ||
| 57 | + where("milestone_id = :milestone_id", milestone_id: milestone) | ||
| 58 | + end | ||
| 52 | end | 59 | end |
| 53 | 60 | ||
| 54 | def human_state | 61 | def human_state |
app/models/user.rb
| @@ -267,7 +267,7 @@ class User < ActiveRecord::Base | @@ -267,7 +267,7 @@ class User < ActiveRecord::Base | ||
| 267 | end | 267 | end |
| 268 | 268 | ||
| 269 | def cared_merge_requests | 269 | def cared_merge_requests |
| 270 | - MergeRequest.where("author_id = :id or assignee_id = :id", id: self.id) | 270 | + MergeRequest.cared(self) |
| 271 | end | 271 | end |
| 272 | 272 | ||
| 273 | # Remove user from all projects and | 273 | # Remove user from all projects and |