diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/models/iteration.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/models/iteration.rb')
-rw-r--r-- | app/models/iteration.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/iteration.rb b/app/models/iteration.rb index 3495f099064..d223c80fca0 100644 --- a/app/models/iteration.rb +++ b/app/models/iteration.rb @@ -29,6 +29,7 @@ class Iteration < ApplicationRecord scope :upcoming, -> { with_state(:upcoming) } scope :started, -> { with_state(:started) } + scope :closed, -> { with_state(:closed) } scope :within_timeframe, -> (start_date, end_date) do where('start_date is not NULL or due_date is not NULL') @@ -36,8 +37,8 @@ class Iteration < ApplicationRecord .where('due_date is NULL or due_date >= ?', start_date) end - scope :start_date_passed, -> { where('start_date <= ?', Date.current).where('due_date > ?', Date.current) } - scope :due_date_passed, -> { where('due_date <= ?', Date.current) } + scope :start_date_passed, -> { where('start_date <= ?', Date.current).where('due_date >= ?', Date.current) } + scope :due_date_passed, -> { where('due_date < ?', Date.current) } state_machine :state_enum, initial: :upcoming do event :start do @@ -63,9 +64,10 @@ class Iteration < ApplicationRecord case state when 'closed' then iterations.closed when 'started' then iterations.started + when 'upcoming' then iterations.upcoming when 'opened' then iterations.started.or(iterations.upcoming) when 'all' then iterations - else iterations.upcoming + else raise ArgumentError, "Unknown state filter: #{state}" end end |