diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/support/shared_examples/requests/releases_shared_examples.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/support/shared_examples/requests/releases_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/requests/releases_shared_examples.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/releases_shared_examples.rb b/spec/support/shared_examples/requests/releases_shared_examples.rb new file mode 100644 index 00000000000..b835947e497 --- /dev/null +++ b/spec/support/shared_examples/requests/releases_shared_examples.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'correct release milestone order' do + let_it_be_with_reload(:milestone_1) { create(:milestone, project: project) } + let_it_be_with_reload(:milestone_2) { create(:milestone, project: project) } + + shared_examples 'correct sort order' do + it 'sorts milestonee_1 before milestone_2' do + freeze_time do + expect(actual_milestone_title_order).to eq([milestone_1.title, milestone_2.title]) + end + end + end + + context 'due_date' do + before do + milestone_1.update!(due_date: Time.zone.now, start_date: 1.day.ago, title: 'z') + milestone_2.update!(due_date: 1.day.from_now, start_date: 2.days.ago, title: 'a') + end + + context 'when both milestones have a due_date' do + it_behaves_like 'correct sort order' + end + + context 'when one milestone does not have a due_date' do + before do + milestone_2.update!(due_date: nil) + end + + it_behaves_like 'correct sort order' + end + end + + context 'start_date' do + before do + milestone_1.update!(due_date: 1.day.from_now, start_date: 1.day.ago, title: 'z' ) + milestone_2.update!(due_date: 1.day.from_now, start_date: milestone_2_start_date, title: 'a' ) + end + + context 'when both milestones have a start_date' do + let(:milestone_2_start_date) { Time.zone.now } + + it_behaves_like 'correct sort order' + end + + context 'when one milestone does not have a start_date' do + let(:milestone_2_start_date) { nil } + + it_behaves_like 'correct sort order' + end + end + + context 'title' do + before do + milestone_1.update!(due_date: 1.day.from_now, start_date: Time.zone.now, title: 'a' ) + milestone_2.update!(due_date: 1.day.from_now, start_date: Time.zone.now, title: 'z' ) + end + + it_behaves_like 'correct sort order' + end +end |