Commit 673196e0 authored by Felipe Artur's avatar Felipe Artur

Fix ordering for Mysql

parent 996240a4
......@@ -37,8 +37,8 @@ module Issuable
scope :closed, -> { with_state(:closed) }
scope :left_joins_milestones, -> { joins("LEFT OUTER JOIN milestones ON #{table_name}.milestone_id = milestones.id") }
scope :order_milestone_due_desc, -> { outer_join_milestone.reorder('milestones.due_date IS NULL ASC, milestones.due_date DESC, milestones.id DESC') }
scope :order_milestone_due_asc, -> { outer_join_milestone.reorder('milestones.due_date IS NULL ASC, milestones.due_date ASC, milestones.id ASC') }
scope :order_milestone_due_desc, -> { left_joins_milestones.reorder('CASE WHEN milestones.due_date IS NULL then 0 ELSE 1 END DESC, CASE WHEN milestones.id IS NULL then 0 ELSE 1 END DESC, milestones.due_date DESC') }
scope :order_milestone_due_asc, -> { left_joins_milestones.reorder('CASE WHEN milestones.due_date IS NULL then 1 ELSE 0 END ASC, CASE WHEN milestones.id IS NULL then 1 ELSE 0 END ASC, milestones.due_date ASC') }
scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) }
scope :join_project, -> { joins(:project) }
......
......@@ -15,14 +15,14 @@ feature 'Issue filtering by Milestone', feature: true do
end
context 'filters by upcoming milestone', js: true do
it 'should not show issues with no expiry' do
it 'should show issues with no expiry' do
create(:issue, project: project)
create(:issue, project: project, milestone: milestone)
visit_issues(project)
filter_by_milestone(Milestone::Upcoming.title)
expect(page).to have_css('.issue', count: 0)
expect(page).to have_css('.issue', count: 2)
end
it 'should show issues in future' do
......@@ -36,7 +36,7 @@ feature 'Issue filtering by Milestone', feature: true do
expect(page).to have_css('.issue', count: 1)
end
it 'should not show issues in past' do
it 'should show issues in past' do
milestone = create(:milestone, project: project, due_date: Date.yesterday)
create(:issue, project: project)
create(:issue, project: project, milestone: milestone)
......@@ -44,7 +44,7 @@ feature 'Issue filtering by Milestone', feature: true do
visit_issues(project)
filter_by_milestone(Milestone::Upcoming.title)
expect(page).to have_css('.issue', count: 0)
expect(page).to have_css('.issue', count: 2)
end
end
......
......@@ -21,14 +21,14 @@ feature 'Merge Request filtering by Milestone', feature: true do
end
context 'filters by upcoming milestone', js: true do
it 'should not show issues with no expiry' do
it 'should show issues with no expiry' do
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
visit_merge_requests(project)
filter_by_milestone(Milestone::Upcoming.title)
expect(page).to have_css('.merge-request', count: 0)
expect(page).to have_css('.merge-request', count: 2)
end
it 'should show issues in future' do
......@@ -42,7 +42,7 @@ feature 'Merge Request filtering by Milestone', feature: true do
expect(page).to have_css('.merge-request', count: 1)
end
it 'should not show issues in past' do
it 'should show issues in past' do
milestone = create(:milestone, project: project, due_date: Date.yesterday)
create(:merge_request, :with_diffs, source_project: project)
create(:merge_request, :simple, source_project: project, milestone: milestone)
......@@ -50,7 +50,7 @@ feature 'Merge Request filtering by Milestone', feature: true do
visit_merge_requests(project)
filter_by_milestone(Milestone::Upcoming.title)
expect(page).to have_css('.merge-request', count: 0)
expect(page).to have_css('.merge-request', count: 2)
end
end
......
require 'spec_helper'
describe Issue, "Issuable" do
let!(:issue) { create(:issue) }
let(:issue) { create(:issue) }
let(:user) { create(:user) }
describe "Associations" do
......@@ -119,6 +119,8 @@ describe Issue, "Issuable" do
#Issues/MRs with milestones ordered by date
#Issues/MRs with milestones without dates
#Issues/MRs without milestones
let!(:issue) { create(:issue) }
let(:project) { issue.project }
let!(:early_milestone) { create(:milestone, project: project, due_date: 10.days.from_now) }
let!(:late_milestone) { create(:milestone, project: project, due_date: 30.days.from_now) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment