summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2017-06-09 12:54:20 -0300
committerFelipe Artur <felipefac@gmail.com>2017-06-16 12:02:20 -0300
commit2e3f0b08fbc0387d3f7985bf61c16e8ec9821750 (patch)
tree32e5d96bbfb20ec79f5dbf5a9448ab40f0ff4a04 /app
parent673bc07c0f6cb936fbc2037440634133ad32afaf (diff)
downloadgitlab-ce-2e3f0b08fbc0387d3f7985bf61c16e8ec9821750.tar.gz
Remove old specs and add new ones
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/milestone_actions.rb2
-rw-r--r--app/models/concerns/milestoneish.rb8
2 files changed, 7 insertions, 3 deletions
diff --git a/app/controllers/concerns/milestone_actions.rb b/app/controllers/concerns/milestone_actions.rb
index 4bda26fdfd1..1ff785ac2ca 100644
--- a/app/controllers/concerns/milestone_actions.rb
+++ b/app/controllers/concerns/milestone_actions.rb
@@ -6,7 +6,7 @@ module MilestoneActions
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_merge_requests_tab", {
- merge_requests: @milestone.merge_requests.sort('priority'),
+ merge_requests: @milestone.sorted_merge_requests,
show_project_name: true
})
end
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb
index a3247210314..0f4d4d841ba 100644
--- a/app/models/concerns/milestoneish.rb
+++ b/app/models/concerns/milestoneish.rb
@@ -62,12 +62,16 @@ module Milestoneish
due_date && due_date.past?
end
+ def sorted_merge_requests
+ merge_requests.sort('label_priority')
+ end
+
private
def count_issues_by_state(user)
memoize_per_user(user, :count_issues_by_state) do
# Need to group and count using ruby array to not break
- # label ordering
+ # label ordering. Also it saves a SQL query.
issues_visible_to_user(user).to_a.group_by(&:state)
end
end
@@ -81,6 +85,6 @@ module Milestoneish
# override in a class that includes this module to get a faster query
# from IssuesFinder
def issues_finder_params
- { sort: 'priority' }
+ { sort: 'label_priority' }
end
end