diff options
author | Luke Picciau <git@itscode.red> | 2019-05-31 13:31:47 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-05-31 13:31:47 +0300 |
commit | 5e8184cc6601bfc690f533b48993904dfe3833eb (patch) | |
tree | 2af8a374496c8841a8d067d6946b1fb9344c795f /spec/models/milestone_spec.rb | |
parent | fa32ae5d61e94823aef4d5c040b06b8ea65040a7 (diff) |
Change query to work on mysql as well. Also set entire date because setting only the year can trip 'start_date_should_be_less_than_due_date'
Diffstat (limited to 'spec/models/milestone_spec.rb')
-rw-r--r-- | spec/models/milestone_spec.rb | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index b82368318f2..752a7965704 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -31,12 +31,28 @@ describe Milestone do end describe 'start_date' do - it 'adds an error when start_date is greated then due_date' do + it 'adds an error when start_date is greater then due_date' do milestone = build(:milestone, start_date: Date.tomorrow, due_date: Date.yesterday) expect(milestone).not_to be_valid expect(milestone.errors[:due_date]).to include("must be greater than start date") end + + it 'adds an error when start_date is greater than 9999-12-31' do + milestone = build(:milestone, start_date: Date.new(10000, 1, 1)) + + expect(milestone).not_to be_valid + expect(milestone.errors[:start_date]).to include("date must not be after 9999-12-31") + end + end + + describe 'due_date' do + it 'adds an error when due_date is greater than 9999-12-31' do + milestone = build(:milestone, due_date: Date.new(10000, 1, 1)) + + expect(milestone).not_to be_valid + expect(milestone.errors[:due_date]).to include("date must not be after 9999-12-31") + end end end @@ -381,21 +397,6 @@ describe Milestone do expect(milestone_ids).to be_empty end end - - context 'when there is a milestone with a date after 294276 AD', :postgresql do - before do - past_milestone_project_1.update!(due_date: Date.new(294277, 1, 1)) - end - - it 'returns the next upcoming open milestone ID for each project and group' do - expect(milestone_ids).to contain_exactly( - current_milestone_project_1.id, - current_milestone_project_2.id, - current_milestone_group_1.id, - current_milestone_group_2.id - ) - end - end end describe '#to_reference' do |