diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/models/iteration_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/models/iteration_spec.rb')
-rw-r--r-- | spec/models/iteration_spec.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/models/iteration_spec.rb b/spec/models/iteration_spec.rb index ae14adf9106..ef638330208 100644 --- a/spec/models/iteration_spec.rb +++ b/spec/models/iteration_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Iteration do +RSpec.describe Iteration do let_it_be(:project) { create(:project) } let_it_be(:group) { create(:group) } @@ -45,6 +45,14 @@ describe Iteration do it { is_expected.to be_valid } end + context 'when updated iteration dates overlap with its own dates' do + it 'is valid' do + existing_iteration.start_date = 5.days.from_now + + expect(existing_iteration).to be_valid + end + end + context 'when dates overlap' do context 'same group' do context 'when start_date is in range' do @@ -138,6 +146,25 @@ describe Iteration do end end + context 'time scopes' do + let_it_be(:project) { create(:project, :empty_repo) } + let_it_be(:iteration_1) { create(:iteration, :skip_future_date_validation, project: project, start_date: 3.days.ago, due_date: 1.day.from_now) } + let_it_be(:iteration_2) { create(:iteration, :skip_future_date_validation, project: project, start_date: 10.days.ago, due_date: 4.days.ago) } + let_it_be(:iteration_3) { create(:iteration, project: project, start_date: 4.days.from_now, due_date: 1.week.from_now) } + + describe 'start_date_passed' do + it 'returns iterations where start_date is in the past but due_date is in the future' do + expect(described_class.start_date_passed).to contain_exactly(iteration_1) + end + end + + describe 'due_date_passed' do + it 'returns iterations where due date is in the past' do + expect(described_class.due_date_passed).to contain_exactly(iteration_2) + end + end + end + describe '.within_timeframe' do let_it_be(:now) { Time.current } let_it_be(:project) { create(:project, :empty_repo) } |