summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/milestone.rb2
-rw-r--r--spec/models/milestone_spec.rb4
2 files changed, 4 insertions, 2 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 6b01e48d7fc..fe9a281f366 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -71,7 +71,7 @@ class Milestone < ActiveRecord::Base
rel = unscoped.of_projects(projects).active.where('due_date > ?', Time.now)
if Gitlab::Database.postgresql?
- rel.order(:project_id, :due_date).pluck('DISTINCT ON (project_id) id')
+ rel.order(:project_id, :due_date).select('DISTINCT ON (project_id) id')
else
rel.
group(:project_id).
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index 210c5f7eb4f..1e18c788b50 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -221,7 +221,9 @@ describe Milestone, models: true do
let!(:past_milestone_project_3) { create(:milestone, project: project_3, due_date: Time.now - 1.day) }
- let(:milestone_ids) { Milestone.upcoming_ids_by_projects(projects) }
+ # The call to `#try` is because this returns a relation with a Postgres DB,
+ # and an array of IDs with a MySQL DB.
+ let(:milestone_ids) { Milestone.upcoming_ids_by_projects(projects).map { |id| id.try(:id) || id } }
it 'returns the next upcoming open milestone ID for each project' do
expect(milestone_ids).to contain_exactly(current_milestone_project_1.id, current_milestone_project_2.id)