Commit cfdc8b02 authored by Alexandru Croitor's avatar Alexandru Croitor

Rename started iteraton state name to current

Change iteration state name to be consistent with our iteration
naming for current iteration.
parent a16e12d9
...@@ -14412,8 +14412,9 @@ State of a GitLab iteration. ...@@ -14412,8 +14412,9 @@ State of a GitLab iteration.
| ----- | ----------- | | ----- | ----------- |
| <a id="iterationstateall"></a>`all` | | | <a id="iterationstateall"></a>`all` | |
| <a id="iterationstateclosed"></a>`closed` | | | <a id="iterationstateclosed"></a>`closed` | |
| <a id="iterationstatecurrent"></a>`current` | |
| <a id="iterationstateopened"></a>`opened` | | | <a id="iterationstateopened"></a>`opened` | |
| <a id="iterationstatestarted"></a>`started` | | | <a id="iterationstatestarted"></a>`started` **{warning-solid}** | **Deprecated** in 14.1. Use current instead. |
| <a id="iterationstateupcoming"></a>`upcoming` | | | <a id="iterationstateupcoming"></a>`upcoming` | |
### `IterationWildcardId` ### `IterationWildcardId`
......
...@@ -26,7 +26,7 @@ GET /groups/:id/iterations?search=version ...@@ -26,7 +26,7 @@ GET /groups/:id/iterations?search=version
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| ------------------- | ------- | -------- | ----------- | | ------------------- | ------- | -------- | ----------- |
| `state` | string | no | Return only `opened`, `upcoming`, `started`, `closed`, or `all` iterations. Defaults to `all`. | | `state` | string | no | 'Return `opened`, `upcoming`, `current (previously started)`, `closed`, or `all` iterations. Filtering by `started` state is deprecated starting with 14.1, please use `current` instead.' |
| `search` | string | no | Return only iterations with a title matching the provided string. | | `search` | string | no | Return only iterations with a title matching the provided string. |
| `include_ancestors` | boolean | no | Include iterations from parent group and its ancestors. Defaults to `true`. | | `include_ancestors` | boolean | no | Include iterations from parent group and its ancestors. Defaults to `true`. |
......
...@@ -28,7 +28,7 @@ GET /projects/:id/iterations?search=version ...@@ -28,7 +28,7 @@ GET /projects/:id/iterations?search=version
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
| ------------------- | ------- | -------- | ----------- | | ------------------- | ------- | -------- | ----------- |
| `state` | string | no | Return only `opened`, `upcoming`, `started`, `closed`, or `all` iterations. Defaults to `all`. | | `state` | string | no | 'Return `opened`, `upcoming`, `current (previously started)`, `closed`, or `all` iterations. Filtering by `started` state is deprecated starting with 14.1, please use `current` instead.' |
| `search` | string | no | Return only iterations with a title matching the provided string. | | `search` | string | no | Return only iterations with a title matching the provided string. |
| `include_ancestors` | boolean | no | Include iterations from parent group and its ancestors. Defaults to `true`. | | `include_ancestors` | boolean | no | Include iterations from parent group and its ancestors. Defaults to `true`. |
......
...@@ -67,6 +67,10 @@ class IterationsFinder ...@@ -67,6 +67,10 @@ class IterationsFinder
def by_state(items) def by_state(items)
return items unless params[:state].present? return items unless params[:state].present?
# `started` was deprecated in 14.1 in favor of `current`. Support for `started`
# will be removed in 14.6 https://gitlab.com/gitlab-org/gitlab/-/issues/334018
params[:state] = 'current' if params[:state] == 'started'
Iteration.filter_by_state(items, params[:state]) Iteration.filter_by_state(items, params[:state])
end end
......
...@@ -6,7 +6,11 @@ module Types ...@@ -6,7 +6,11 @@ module Types
description 'State of a GitLab iteration' description 'State of a GitLab iteration'
value 'upcoming' value 'upcoming'
value 'started' value 'started', deprecated: {
reason: "Use current instead",
milestone: '14.1'
}
value 'current'
value 'opened' value 'opened'
value 'closed' value 'closed'
value 'all' value 'all'
......
...@@ -6,7 +6,7 @@ module EE ...@@ -6,7 +6,7 @@ module EE
STATE_ENUM_MAP = { STATE_ENUM_MAP = {
upcoming: 1, upcoming: 1,
started: 2, current: 2,
closed: 3 closed: 3
}.with_indifferent_access.freeze }.with_indifferent_access.freeze
...@@ -55,8 +55,9 @@ module EE ...@@ -55,8 +55,9 @@ module EE
scope :due_date_order_asc, -> { order(:due_date) } scope :due_date_order_asc, -> { order(:due_date) }
scope :due_date_order_desc, -> { order(due_date: :desc) } scope :due_date_order_desc, -> { order(due_date: :desc) }
scope :upcoming, -> { with_state(:upcoming) } scope :upcoming, -> { with_state(:upcoming) }
scope :started, -> { with_state(:started) } scope :current, -> { with_state(:current) }
scope :closed, -> { with_state(:closed) } scope :closed, -> { with_state(:closed) }
scope :opened, -> { with_states(:current, :upcoming) }
scope :by_iteration_cadence_ids, ->(cadence_ids) { where(iterations_cadence_id: cadence_ids) } scope :by_iteration_cadence_ids, ->(cadence_ids) { where(iterations_cadence_id: cadence_ids) }
scope :with_start_date_after, ->(date) { where('start_date > :date', date: date) } scope :with_start_date_after, ->(date) { where('start_date > :date', date: date) }
...@@ -70,11 +71,11 @@ module EE ...@@ -70,11 +71,11 @@ module EE
state_machine :state_enum, initial: :upcoming do state_machine :state_enum, initial: :upcoming do
event :start do event :start do
transition upcoming: :started transition upcoming: :current
end end
event :close do event :close do
transition [:upcoming, :started] => :closed transition [:upcoming, :current] => :closed
end end
after_transition any => [:closed] do |iteration| after_transition any => [:closed] do |iteration|
...@@ -84,13 +85,25 @@ module EE ...@@ -84,13 +85,25 @@ module EE
end end
state :upcoming, value: Iteration::STATE_ENUM_MAP[:upcoming] state :upcoming, value: Iteration::STATE_ENUM_MAP[:upcoming]
state :started, value: Iteration::STATE_ENUM_MAP[:started] state :current, value: Iteration::STATE_ENUM_MAP[:current]
state :closed, value: Iteration::STATE_ENUM_MAP[:closed] state :closed, value: Iteration::STATE_ENUM_MAP[:closed]
end end
class << self class << self
alias_method :with_state, :with_state_enum alias_method :with_state, :with_state_enum
alias_method :with_states, :with_state_enums alias_method :with_states, :with_state_enums
def compute_state(start_date, due_date)
today = Date.today
if start_date > today
:upcoming
elsif due_date < today
:closed
else
:current
end
end
end end
end end
...@@ -121,9 +134,9 @@ module EE ...@@ -121,9 +134,9 @@ module EE
def filter_by_state(iterations, state) def filter_by_state(iterations, state)
case state case state
when 'closed' then iterations.closed when 'closed' then iterations.closed
when 'started' then iterations.started when 'current' then iterations.current
when 'upcoming' then iterations.upcoming when 'upcoming' then iterations.upcoming
when 'opened' then iterations.started.or(iterations.upcoming) when 'opened' then iterations.opened
when 'all' then iterations when 'all' then iterations
else raise ArgumentError, "Unknown state filter: #{state}" else raise ArgumentError, "Unknown state filter: #{state}"
end end
...@@ -219,19 +232,7 @@ module EE ...@@ -219,19 +232,7 @@ module EE
end end
def set_iteration_state def set_iteration_state
self.state = compute_state self.state = self.class.compute_state(start_date, due_date)
end
def compute_state
today = Date.today
if start_date > today
:upcoming
elsif due_date < today
:closed
else
:started
end
end end
# TODO: this method should be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/296099 # TODO: this method should be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/296099
......
...@@ -12,20 +12,20 @@ class IterationsUpdateStatusWorker ...@@ -12,20 +12,20 @@ class IterationsUpdateStatusWorker
feature_category :issue_tracking feature_category :issue_tracking
def perform def perform
set_started_iterations set_current_iterations
set_closed_iterations set_closed_iterations
end end
private private
def set_started_iterations def set_current_iterations
Iteration.upcoming.start_date_passed.each_batch(of: BATCH_SIZE) do |iterations| Iteration.upcoming.start_date_passed.each_batch(of: BATCH_SIZE) do |iterations|
iterations.update_all(state_enum: ::Iteration::STATE_ENUM_MAP[:started], updated_at: Time.current) iterations.update_all(state_enum: ::Iteration::STATE_ENUM_MAP[:current], updated_at: Time.current)
end end
end end
def set_closed_iterations def set_closed_iterations
Iteration.upcoming.or(Iteration.started).due_date_passed.each_batch(of: BATCH_SIZE) do |iterations| Iteration.opened.due_date_passed.each_batch(of: BATCH_SIZE) do |iterations|
closed_iteration_ids = iterations.pluck_primary_key closed_iteration_ids = iterations.pluck_primary_key
iterations.update_all(state_enum: ::Iteration::STATE_ENUM_MAP[:closed], updated_at: Time.current) iterations.update_all(state_enum: ::Iteration::STATE_ENUM_MAP[:closed], updated_at: Time.current)
......
...@@ -8,8 +8,8 @@ module API ...@@ -8,8 +8,8 @@ module API
helpers do helpers do
params :list_params do params :list_params do
optional :state, type: String, values: %w[opened upcoming started closed all], default: 'all', optional :state, type: String, values: %w[opened upcoming started current closed all], default: 'all',
desc: 'Return "opened", "upcoming", "started", "closed", or "all" milestones' desc: 'Return "opened", "upcoming", "current (previously started)", "closed", or "all" iterations. Filtering by `started` state is deprecated starting with 14.1, please use `current` instead.'
optional :search, type: String, desc: 'The search criteria for the title of the iteration' optional :search, type: String, desc: 'The search criteria for the title of the iteration'
optional :include_ancestors, type: Grape::API::Boolean, default: true, optional :include_ancestors, type: Grape::API::Boolean, default: true,
desc: 'Include iterations from parent and its ancestors' desc: 'Include iterations from parent and its ancestors'
......
...@@ -22,8 +22,8 @@ FactoryBot.define do ...@@ -22,8 +22,8 @@ FactoryBot.define do
state_enum { Iteration::STATE_ENUM_MAP[:upcoming] } state_enum { Iteration::STATE_ENUM_MAP[:upcoming] }
end end
trait :started do trait :current do
state_enum { Iteration::STATE_ENUM_MAP[:started] } state_enum { Iteration::STATE_ENUM_MAP[:current] }
end end
trait :closed do trait :closed do
...@@ -60,7 +60,7 @@ FactoryBot.define do ...@@ -60,7 +60,7 @@ FactoryBot.define do
end end
factory :upcoming_iteration, traits: [:upcoming] factory :upcoming_iteration, traits: [:upcoming]
factory :started_iteration, traits: [:started] factory :current_iteration, traits: [:current]
factory :closed_iteration, traits: [:closed] factory :closed_iteration, traits: [:closed]
end end
end end
...@@ -7,7 +7,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -7,7 +7,7 @@ RSpec.describe 'Iterations list', :js do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) } let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:started_iteration) { create(:iteration, :skip_future_date_validation, group: group, start_date: now - 1.day, due_date: now, title: 'Started iteration') } let_it_be(:current_iteration) { create(:iteration, :skip_future_date_validation, group: group, start_date: now - 1.day, due_date: now, title: 'Started iteration') }
let_it_be(:upcoming_iteration) { create(:iteration, group: group, start_date: now + 1.day, due_date: now + 2.days) } let_it_be(:upcoming_iteration) { create(:iteration, group: group, start_date: now + 1.day, due_date: now + 2.days) }
let_it_be(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, group: group, start_date: now - 3.days, due_date: now - 2.days) } let_it_be(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, group: group, start_date: now - 3.days, due_date: now - 2.days) }
let_it_be(:subgroup_iteration) { create(:iteration, :skip_future_date_validation, group: subgroup, start_date: now - 3.days, due_date: now + 4.days) } let_it_be(:subgroup_iteration) { create(:iteration, :skip_future_date_validation, group: subgroup, start_date: now - 3.days, due_date: now + 4.days) }
...@@ -25,7 +25,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -25,7 +25,7 @@ RSpec.describe 'Iterations list', :js do
it 'shows iterations on each tab' do it 'shows iterations on each tab' do
aggregate_failures do aggregate_failures do
expect(page).to have_link(started_iteration.title) expect(page).to have_link(current_iteration.title)
expect(page).to have_link(upcoming_iteration.title) expect(page).to have_link(upcoming_iteration.title)
expect(page).not_to have_link(closed_iteration.title) expect(page).not_to have_link(closed_iteration.title)
expect(page).not_to have_link(subgroup_iteration.title) expect(page).not_to have_link(subgroup_iteration.title)
...@@ -36,7 +36,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -36,7 +36,7 @@ RSpec.describe 'Iterations list', :js do
aggregate_failures do aggregate_failures do
expect(page).to have_link(closed_iteration.title) expect(page).to have_link(closed_iteration.title)
expect(page).not_to have_link(started_iteration.title) expect(page).not_to have_link(current_iteration.title)
expect(page).not_to have_link(upcoming_iteration.title) expect(page).not_to have_link(upcoming_iteration.title)
expect(page).not_to have_link(subgroup_iteration.title) expect(page).not_to have_link(subgroup_iteration.title)
expect(page).not_to have_link(subgroup_closed_iteration.title) expect(page).not_to have_link(subgroup_closed_iteration.title)
...@@ -45,7 +45,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -45,7 +45,7 @@ RSpec.describe 'Iterations list', :js do
click_link('All') click_link('All')
aggregate_failures do aggregate_failures do
expect(page).to have_link(started_iteration.title) expect(page).to have_link(current_iteration.title)
expect(page).to have_link(upcoming_iteration.title) expect(page).to have_link(upcoming_iteration.title)
expect(page).to have_link(closed_iteration.title) expect(page).to have_link(closed_iteration.title)
expect(page).not_to have_link(subgroup_iteration.title) expect(page).not_to have_link(subgroup_iteration.title)
...@@ -59,7 +59,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -59,7 +59,7 @@ RSpec.describe 'Iterations list', :js do
wait_for_requests wait_for_requests
expect(page).to have_current_path(group_iteration_path(group, started_iteration.id)) expect(page).to have_current_path(group_iteration_path(group, current_iteration.id))
end end
end end
end end
...@@ -71,7 +71,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -71,7 +71,7 @@ RSpec.describe 'Iterations list', :js do
it 'shows iterations on each tab including ancestor iterations' do it 'shows iterations on each tab including ancestor iterations' do
aggregate_failures do aggregate_failures do
expect(page).to have_link(started_iteration.title) expect(page).to have_link(current_iteration.title)
expect(page).to have_link(upcoming_iteration.title) expect(page).to have_link(upcoming_iteration.title)
expect(page).not_to have_link(closed_iteration.title) expect(page).not_to have_link(closed_iteration.title)
expect(page).to have_link(subgroup_iteration.title) expect(page).to have_link(subgroup_iteration.title)
...@@ -83,7 +83,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -83,7 +83,7 @@ RSpec.describe 'Iterations list', :js do
aggregate_failures do aggregate_failures do
expect(page).to have_link(closed_iteration.title) expect(page).to have_link(closed_iteration.title)
expect(page).to have_link(subgroup_closed_iteration.title) expect(page).to have_link(subgroup_closed_iteration.title)
expect(page).not_to have_link(started_iteration.title) expect(page).not_to have_link(current_iteration.title)
expect(page).not_to have_link(upcoming_iteration.title) expect(page).not_to have_link(upcoming_iteration.title)
expect(page).not_to have_link(subgroup_iteration.title) expect(page).not_to have_link(subgroup_iteration.title)
end end
...@@ -91,7 +91,7 @@ RSpec.describe 'Iterations list', :js do ...@@ -91,7 +91,7 @@ RSpec.describe 'Iterations list', :js do
click_link('All') click_link('All')
aggregate_failures do aggregate_failures do
expect(page).to have_link(started_iteration.title) expect(page).to have_link(current_iteration.title)
expect(page).to have_link(upcoming_iteration.title) expect(page).to have_link(upcoming_iteration.title)
expect(page).to have_link(closed_iteration.title) expect(page).to have_link(closed_iteration.title)
expect(page).to have_link(subgroup_iteration.title) expect(page).to have_link(subgroup_iteration.title)
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Iterations list', :js do RSpec.describe 'Iterations list', :js do
let(:now) { Time.now } let_it_be(:now) { Time.now }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :public, group: group) } let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let!(:started_iteration) { create(:iteration, :skip_future_date_validation, group: group, start_date: now - 1.day, due_date: now, title: 'Started iteration') } let_it_be(:current_iteration) { create(:iteration, :skip_future_date_validation, group: group, start_date: now - 1.day, due_date: now) }
let!(:upcoming_iteration) { create(:iteration, group: group, start_date: now + 1.day, due_date: now + 2.days) } let_it_be(:upcoming_iteration) { create(:iteration, group: group, start_date: now + 1.day, due_date: now + 2.days) }
let!(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, group: group, start_date: now - 3.days, due_date: now - 2.days) } let_it_be(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, group: group, start_date: now - 3.days, due_date: now - 2.days) }
context 'as guest' do context 'as guest' do
before do before do
...@@ -18,19 +18,19 @@ RSpec.describe 'Iterations list', :js do ...@@ -18,19 +18,19 @@ RSpec.describe 'Iterations list', :js do
end end
it 'shows iterations on each tab', :aggregate_failures do it 'shows iterations on each tab', :aggregate_failures do
expect(page).to have_link(started_iteration.title, href: project_iteration_path(project, started_iteration.id)) expect(page).to have_link(current_iteration.title, href: project_iteration_path(project, current_iteration.id))
expect(page).to have_link(upcoming_iteration.title, href: project_iteration_path(project, upcoming_iteration.id)) expect(page).to have_link(upcoming_iteration.title, href: project_iteration_path(project, upcoming_iteration.id))
expect(page).not_to have_link(closed_iteration.title) expect(page).not_to have_link(closed_iteration.title)
click_link('Closed') click_link('Closed')
expect(page).to have_link(closed_iteration.title, href: project_iteration_path(project, closed_iteration.id)) expect(page).to have_link(closed_iteration.title, href: project_iteration_path(project, closed_iteration.id))
expect(page).not_to have_link(started_iteration.title) expect(page).not_to have_link(current_iteration.title)
expect(page).not_to have_link(upcoming_iteration.title) expect(page).not_to have_link(upcoming_iteration.title)
click_link('All') click_link('All')
expect(page).to have_link(started_iteration.title, href: project_iteration_path(project, started_iteration.id)) expect(page).to have_link(current_iteration.title, href: project_iteration_path(project, current_iteration.id))
expect(page).to have_link(upcoming_iteration.title, href: project_iteration_path(project, upcoming_iteration.id)) expect(page).to have_link(upcoming_iteration.title, href: project_iteration_path(project, upcoming_iteration.id))
expect(page).to have_link(closed_iteration.title, href: project_iteration_path(project, closed_iteration.id)) expect(page).to have_link(closed_iteration.title, href: project_iteration_path(project, closed_iteration.id))
end end
......
...@@ -174,7 +174,7 @@ RSpec.describe IssuesFinder do ...@@ -174,7 +174,7 @@ RSpec.describe IssuesFinder do
end end
context 'when current iteration exists' do context 'when current iteration exists' do
let(:current_iteration) { create(:iteration, :started, group: group, start_date: Date.today, due_date: 1.day.from_now) } let(:current_iteration) { create(:iteration, :current, group: group, start_date: Date.yesterday, due_date: 1.day.from_now) }
it 'returns filtered issues' do it 'returns filtered issues' do
expect(issues).to contain_exactly(current_iteration_issue) expect(issues).to contain_exactly(current_iteration_issue)
......
...@@ -11,9 +11,9 @@ RSpec.describe IterationsFinder do ...@@ -11,9 +11,9 @@ RSpec.describe IterationsFinder do
let_it_be(:iteration_cadence2) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 2, title: 'two week iterations') } let_it_be(:iteration_cadence2) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 2, title: 'two week iterations') }
let_it_be(:iteration_cadence3) { create(:iterations_cadence, group: root, active: true, duration_in_weeks: 3, title: 'three week iterations') } let_it_be(:iteration_cadence3) { create(:iterations_cadence, group: root, active: true, duration_in_weeks: 3, title: 'three week iterations') }
let_it_be(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, start_date: 7.days.ago, due_date: 2.days.ago) } let_it_be(:closed_iteration) { create(:closed_iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, start_date: 7.days.ago, due_date: 2.days.ago) }
let_it_be(:started_group_iteration) { create(:started_iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, title: 'one test', start_date: 1.day.ago, due_date: Date.today) } let_it_be(:started_group_iteration) { create(:current_iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, title: 'one test', start_date: 1.day.ago, due_date: Date.today) }
let_it_be(:upcoming_group_iteration) { create(:iteration, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, start_date: 1.day.from_now, due_date: 3.days.from_now) } let_it_be(:upcoming_group_iteration) { create(:iteration, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, start_date: 1.day.from_now, due_date: 3.days.from_now) }
let_it_be(:root_group_iteration) { create(:started_iteration, iterations_cadence: iteration_cadence3, group: iteration_cadence3.group, start_date: 1.day.ago, due_date: 2.days.from_now) } let_it_be(:root_group_iteration) { create(:current_iteration, iterations_cadence: iteration_cadence3, group: iteration_cadence3.group, start_date: 1.day.ago, due_date: 2.days.from_now) }
let_it_be(:root_closed_iteration) { create(:closed_iteration, iterations_cadence: iteration_cadence3, group: iteration_cadence3.group, start_date: 1.week.ago, due_date: 2.days.ago) } let_it_be(:root_closed_iteration) { create(:closed_iteration, iterations_cadence: iteration_cadence3, group: iteration_cadence3.group, start_date: 1.week.ago, due_date: 2.days.ago) }
let(:parent) { project_1 } let(:parent) { project_1 }
...@@ -79,7 +79,7 @@ RSpec.describe IterationsFinder do ...@@ -79,7 +79,7 @@ RSpec.describe IterationsFinder do
end end
it 'filters by started state' do it 'filters by started state' do
params[:state] = 'started' params[:state] = 'current'
expect(subject).to contain_exactly(root_group_iteration, started_group_iteration) expect(subject).to contain_exactly(root_group_iteration, started_group_iteration)
end end
......
...@@ -14,7 +14,7 @@ RSpec.describe Resolvers::BoardListIssuesResolver do ...@@ -14,7 +14,7 @@ RSpec.describe Resolvers::BoardListIssuesResolver do
let_it_be(:epic) { create(:epic, group: group) } let_it_be(:epic) { create(:epic, group: group) }
let_it_be(:iteration) { create(:iteration, group: group, start_date: 1.week.ago, due_date: 2.days.ago) } let_it_be(:iteration) { create(:iteration, group: group, start_date: 1.week.ago, due_date: 2.days.ago) }
let_it_be(:current_iteration) { create(:iteration, :started, group: group, start_date: Date.today, due_date: 1.day.from_now) } let_it_be(:current_iteration) { create(:iteration, group: group, start_date: Date.yesterday, due_date: 1.day.from_now) }
let_it_be(:issue1) { create(:issue, project: project, labels: [label], weight: 3) } let_it_be(:issue1) { create(:issue, project: project, labels: [label], weight: 3) }
let_it_be(:issue2) { create(:issue, project: project, labels: [label], iteration: iteration) } let_it_be(:issue2) { create(:issue, project: project, labels: [label], iteration: iteration) }
......
...@@ -15,7 +15,7 @@ RSpec.describe Resolvers::IssuesResolver do ...@@ -15,7 +15,7 @@ RSpec.describe Resolvers::IssuesResolver do
let_it_be(:epic2) { create :epic, group: group } let_it_be(:epic2) { create :epic, group: group }
let_it_be(:iteration1) { create(:iteration, group: group, start_date: 2.weeks.ago, due_date: 1.week.ago) } let_it_be(:iteration1) { create(:iteration, group: group, start_date: 2.weeks.ago, due_date: 1.week.ago) }
let_it_be(:current_iteration) { create(:iteration, :started, group: group, start_date: Date.today, due_date: 1.day.from_now) } let_it_be(:current_iteration) { create(:iteration, group: group, start_date: Date.yesterday, due_date: 1.day.from_now) }
let_it_be(:issue1) { create :issue, project: project, epic: epic1, iteration: iteration1 } let_it_be(:issue1) { create :issue, project: project, epic: epic1, iteration: iteration1 }
let_it_be(:issue2) { create :issue, project: project, epic: epic2, weight: 1 } let_it_be(:issue2) { create :issue, project: project, epic: epic2, weight: 1 }
......
...@@ -93,7 +93,7 @@ RSpec.describe Iteration do ...@@ -93,7 +93,7 @@ RSpec.describe Iteration do
describe '.filter_by_state' do describe '.filter_by_state' do
let_it_be(:closed_iteration) { create(:iteration, :closed, :skip_future_date_validation, group: group, start_date: 8.days.ago, due_date: 2.days.ago) } let_it_be(:closed_iteration) { create(:iteration, :closed, :skip_future_date_validation, group: group, start_date: 8.days.ago, due_date: 2.days.ago) }
let_it_be(:started_iteration) { create(:iteration, :started, :skip_future_date_validation, group: group, start_date: 1.day.ago, due_date: 6.days.from_now) } let_it_be(:current_iteration) { create(:iteration, :current, :skip_future_date_validation, group: group, start_date: 1.day.ago, due_date: 6.days.from_now) }
let_it_be(:upcoming_iteration) { create(:iteration, :upcoming, group: group, start_date: 1.week.from_now, due_date: 2.weeks.from_now) } let_it_be(:upcoming_iteration) { create(:iteration, :upcoming, group: group, start_date: 1.week.from_now, due_date: 2.weeks.from_now) }
shared_examples_for 'filter_by_state' do shared_examples_for 'filter_by_state' do
...@@ -111,15 +111,15 @@ RSpec.describe Iteration do ...@@ -111,15 +111,15 @@ RSpec.describe Iteration do
context 'filtering by started iterations' do context 'filtering by started iterations' do
it_behaves_like 'filter_by_state' do it_behaves_like 'filter_by_state' do
let(:state) { 'started' } let(:state) { 'current' }
let(:expected_iterations) { [started_iteration] } let(:expected_iterations) { [current_iteration] }
end end
end end
context 'filtering by opened iterations' do context 'filtering by opened iterations' do
it_behaves_like 'filter_by_state' do it_behaves_like 'filter_by_state' do
let(:state) { 'opened' } let(:state) { 'opened' }
let(:expected_iterations) { [started_iteration, upcoming_iteration] } let(:expected_iterations) { [current_iteration, upcoming_iteration] }
end end
end end
...@@ -133,7 +133,7 @@ RSpec.describe Iteration do ...@@ -133,7 +133,7 @@ RSpec.describe Iteration do
context 'filtering by "all"' do context 'filtering by "all"' do
it_behaves_like 'filter_by_state' do it_behaves_like 'filter_by_state' do
let(:state) { 'all' } let(:state) { 'all' }
let(:expected_iterations) { [closed_iteration, started_iteration, upcoming_iteration] } let(:expected_iterations) { [closed_iteration, current_iteration, upcoming_iteration] }
end end
end end
...@@ -438,7 +438,7 @@ RSpec.describe Iteration do ...@@ -438,7 +438,7 @@ RSpec.describe Iteration do
let_it_be(:iterations_cadence1) { create(:iterations_cadence, group: group, start_date: 10.days.ago) } let_it_be(:iterations_cadence1) { create(:iterations_cadence, group: group, start_date: 10.days.ago) }
let_it_be(:iterations_cadence2) { create(:iterations_cadence, group: group, start_date: 10.days.ago) } let_it_be(:iterations_cadence2) { create(:iterations_cadence, group: group, start_date: 10.days.ago) }
let_it_be(:closed_iteration) { create(:iteration, :closed, :skip_future_date_validation, iterations_cadence: iterations_cadence1, group: group, start_date: 8.days.ago, due_date: 2.days.ago) } let_it_be(:closed_iteration) { create(:iteration, :closed, :skip_future_date_validation, iterations_cadence: iterations_cadence1, group: group, start_date: 8.days.ago, due_date: 2.days.ago) }
let_it_be(:started_iteration) { create(:iteration, :started, :skip_future_date_validation, iterations_cadence: iterations_cadence2, group: group, start_date: 1.day.ago, due_date: 6.days.from_now) } let_it_be(:current_iteration) { create(:iteration, :current, :skip_future_date_validation, iterations_cadence: iterations_cadence2, group: group, start_date: 1.day.ago, due_date: 6.days.from_now) }
let_it_be(:upcoming_iteration) { create(:iteration, :upcoming, iterations_cadence: iterations_cadence2, group: group, start_date: 1.week.from_now, due_date: 2.weeks.from_now) } let_it_be(:upcoming_iteration) { create(:iteration, :upcoming, iterations_cadence: iterations_cadence2, group: group, start_date: 1.week.from_now, due_date: 2.weeks.from_now) }
it 'returns iterations by cadence' do it 'returns iterations by cadence' do
...@@ -450,7 +450,7 @@ RSpec.describe Iteration do ...@@ -450,7 +450,7 @@ RSpec.describe Iteration do
it 'returns iterations by multiple cadences' do it 'returns iterations by multiple cadences' do
iterations = described_class.by_iteration_cadence_ids([iterations_cadence1, iterations_cadence2]) iterations = described_class.by_iteration_cadence_ids([iterations_cadence1, iterations_cadence2])
expect(iterations).to match_array([closed_iteration, started_iteration, upcoming_iteration]) expect(iterations).to match_array([closed_iteration, current_iteration, upcoming_iteration])
end end
end end
...@@ -479,7 +479,7 @@ RSpec.describe Iteration do ...@@ -479,7 +479,7 @@ RSpec.describe Iteration do
it 'sets state to started' do it 'sets state to started' do
iteration.save! iteration.save!
expect(iteration.state).to eq('started') expect(iteration.state).to eq('current')
end end
end end
...@@ -489,7 +489,7 @@ RSpec.describe Iteration do ...@@ -489,7 +489,7 @@ RSpec.describe Iteration do
it 'sets state to started' do it 'sets state to started' do
iteration.save! iteration.save!
expect(iteration.state).to eq('started') expect(iteration.state).to eq('current')
end end
end end
...@@ -539,7 +539,7 @@ RSpec.describe Iteration do ...@@ -539,7 +539,7 @@ RSpec.describe Iteration do
iteration.due_date += 2.weeks iteration.due_date += 2.weeks
iteration.save! iteration.save!
expect(iteration.state).to eq('started') expect(iteration.state).to eq('current')
end end
end end
end end
......
...@@ -11,9 +11,9 @@ RSpec.describe 'getting iterations' do ...@@ -11,9 +11,9 @@ RSpec.describe 'getting iterations' do
let_it_be(:iteration_cadence1) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 1, title: 'one week iterations') } let_it_be(:iteration_cadence1) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 1, title: 'one week iterations') }
let_it_be(:iteration_cadence2) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 2, title: 'two week iterations') } let_it_be(:iteration_cadence2) { create(:iterations_cadence, group: group, active: true, duration_in_weeks: 2, title: 'two week iterations') }
let_it_be(:started_group_iteration) { create(:started_iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, title: 'one test', start_date: now - 1.day, due_date: now) } let_it_be(:current_group_iteration) { create(:iteration, :skip_future_date_validation, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, title: 'one test', start_date: 1.day.ago, due_date: 1.week.from_now) }
let_it_be(:upcoming_group_iteration) { create(:iteration, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, start_date: 1.day.from_now, due_date: 2.days.from_now) } let_it_be(:upcoming_group_iteration) { create(:iteration, iterations_cadence: iteration_cadence2, group: iteration_cadence2.group, start_date: 1.day.from_now, due_date: 2.days.from_now) }
let_it_be(:closed_group_iteration) { create(:closed_iteration, :skip_project_validation, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, start_date: 3.days.from_now, due_date: 4.days.from_now) } let_it_be(:closed_group_iteration) { create(:iteration, :skip_project_validation, iterations_cadence: iteration_cadence1, group: iteration_cadence1.group, start_date: 3.weeks.ago, due_date: 1.week.ago) }
before do before do
group.add_maintainer(user) group.add_maintainer(user)
...@@ -50,7 +50,33 @@ RSpec.describe 'getting iterations' do ...@@ -50,7 +50,33 @@ RSpec.describe 'getting iterations' do
it 'returns iterations' do it 'returns iterations' do
post_graphql(iteration_cadence_query(group, [iteration_cadence1.to_global_id, iteration_cadence2.to_global_id]), current_user: user) post_graphql(iteration_cadence_query(group, [iteration_cadence1.to_global_id, iteration_cadence2.to_global_id]), current_user: user)
expect_iterations_response(started_group_iteration, closed_group_iteration, upcoming_group_iteration) expect_iterations_response(current_group_iteration, closed_group_iteration, upcoming_group_iteration)
end
end
end
describe 'query for iterations by state' do
context 'with DEPRECATED `started` state' do
it 'returns `current` iteration' do
post_graphql(iterations_query(group, "state: started"), current_user: user)
expect_iterations_response(current_group_iteration)
end
end
context 'with `current` state' do
it 'returns `current` iteration' do
post_graphql(iterations_query(group, "state: current"), current_user: user)
expect_iterations_response(current_group_iteration)
end
end
context 'with `closed` state' do
it 'returns `closed` iteration' do
post_graphql(iterations_query(group, "state: closed"), current_user: user)
expect_iterations_response(closed_group_iteration)
end end
end end
end end
......
...@@ -7,8 +7,8 @@ RSpec.describe API::Iterations do ...@@ -7,8 +7,8 @@ RSpec.describe API::Iterations do
let_it_be(:parent_group) { create(:group, :private) } let_it_be(:parent_group) { create(:group, :private) }
let_it_be(:group) { create(:group, :private, parent: parent_group) } let_it_be(:group) { create(:group, :private, parent: parent_group) }
let_it_be(:iteration) { create(:iteration, group: group, title: 'search_title') } let_it_be(:current_iteration) { create(:iteration, group: group, title: 'search_title', start_date: 5.days.ago, due_date: 1.week.from_now) }
let_it_be(:closed_iteration) { create(:iteration, :closed, group: group, start_date: 2.weeks.ago, due_date: 1.week.ago) } let_it_be(:closed_iteration) { create(:iteration, group: group, start_date: 2.weeks.ago, due_date: 1.week.ago) }
let_it_be(:ancestor_iteration) { create(:iteration, group: parent_group) } let_it_be(:ancestor_iteration) { create(:iteration, group: parent_group) }
before_all do before_all do
...@@ -30,15 +30,34 @@ RSpec.describe API::Iterations do ...@@ -30,15 +30,34 @@ RSpec.describe API::Iterations do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
expect(json_response.map { |i| i['id'] }).to contain_exactly(iteration.id, closed_iteration.id, ancestor_iteration.id) expect(json_response.map { |i| i['id'] }).to contain_exactly(current_iteration.id, closed_iteration.id, ancestor_iteration.id)
end end
it 'returns iterations filtered by state' do context 'filter by iteration state' do
get api(api_path, user), params: { state: 'closed' } it 'returns `closed` state iterations' do
get api(api_path, user), params: { state: 'closed' }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(closed_iteration.id) expect(json_response.first['id']).to eq(closed_iteration.id)
end
# to be removed when `started` state DEPRECATION is removed, planned for milestone 14.6
it 'returns `current` state iterations' do
get api(api_path, user), params: { state: 'started' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(current_iteration.id)
end
it 'returns `current` state iterations' do
get api(api_path, user), params: { state: 'current' }
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(current_iteration.id)
end
end end
it 'returns iterations filtered by title' do it 'returns iterations filtered by title' do
...@@ -46,7 +65,7 @@ RSpec.describe API::Iterations do ...@@ -46,7 +65,7 @@ RSpec.describe API::Iterations do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq(iteration.id) expect(json_response.first['id']).to eq(current_iteration.id)
end end
it 'returns 400 when param is invalid' do it 'returns 400 when param is invalid' do
...@@ -67,7 +86,7 @@ RSpec.describe API::Iterations do ...@@ -67,7 +86,7 @@ RSpec.describe API::Iterations do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
expect(json_response.map { |i| i['id'] }).to contain_exactly(iteration.id, closed_iteration.id) expect(json_response.map { |i| i['id'] }).to contain_exactly(current_iteration.id, closed_iteration.id)
end end
end end
...@@ -82,7 +101,7 @@ RSpec.describe API::Iterations do ...@@ -82,7 +101,7 @@ RSpec.describe API::Iterations do
get api(api_path, user), params: { include_ancestors: false } get api(api_path, user), params: { include_ancestors: false }
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |i| i['id'] }).to contain_exactly(iteration.id, closed_iteration.id) expect(json_response.map { |i| i['id'] }).to contain_exactly(current_iteration.id, closed_iteration.id)
end end
end end
end end
...@@ -9,7 +9,7 @@ RSpec.describe Iterations::Cadences::DestroyService do ...@@ -9,7 +9,7 @@ RSpec.describe Iterations::Cadences::DestroyService do
let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:project) { create(:project, :repository, group: group) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:iteration_cadence, refind: true) { create(:iterations_cadence, group: group, start_date: Date.today, duration_in_weeks: 1, iterations_in_advance: 2) } let_it_be(:iteration_cadence, refind: true) { create(:iterations_cadence, group: group, start_date: Date.today, duration_in_weeks: 1, iterations_in_advance: 2) }
let_it_be(:iteration) { create(:started_iteration, group: group, start_date: 2.days.ago, due_date: 5.days.from_now) } let_it_be(:iteration) { create(:current_iteration, group: group, start_date: 2.days.ago, due_date: 5.days.from_now) }
let_it_be(:iteration_list, refind: true) { create(:iteration_list, iteration: iteration) } let_it_be(:iteration_list, refind: true) { create(:iteration_list, iteration: iteration) }
let_it_be(:iteration_event, refind: true) { create(:resource_iteration_event, iteration: iteration) } let_it_be(:iteration_event, refind: true) { create(:resource_iteration_event, iteration: iteration) }
let_it_be(:board) { create(:board, iteration: iteration, group: group) } let_it_be(:board) { create(:board, iteration: iteration, group: group) }
......
...@@ -17,7 +17,7 @@ RSpec.describe Iterations::DeleteService do ...@@ -17,7 +17,7 @@ RSpec.describe Iterations::DeleteService do
let_it_be(:past_issue, refind: true) { create(:issue, namespace: group, iteration: past_iteration) } let_it_be(:past_issue, refind: true) { create(:issue, namespace: group, iteration: past_iteration) }
let_it_be(:past_merge_request, refind: true) { create(:merge_request, source_project: project, iteration: past_iteration) } let_it_be(:past_merge_request, refind: true) { create(:merge_request, source_project: project, iteration: past_iteration) }
let_it_be(:current_iteration, refind: true) { create(:started_iteration, iterations_cadence: iteration_cadence1, group: group, start_date: start_date + 14.days, due_date: start_date + 27.days) } let_it_be(:current_iteration, refind: true) { create(:current_iteration, iterations_cadence: iteration_cadence1, group: group, start_date: start_date + 14.days, due_date: start_date + 27.days) }
let_it_be(:future_iteration, refind: true) { create(:upcoming_iteration, iterations_cadence: iteration_cadence1, group: group, start_date: start_date + 28.days, due_date: start_date + 41.days) } let_it_be(:future_iteration, refind: true) { create(:upcoming_iteration, iterations_cadence: iteration_cadence1, group: group, start_date: start_date + 28.days, due_date: start_date + 41.days) }
...@@ -26,7 +26,7 @@ RSpec.describe Iterations::DeleteService do ...@@ -26,7 +26,7 @@ RSpec.describe Iterations::DeleteService do
let_it_be(:last_future_issue, refind: true) { create(:issue, namespace: group, iteration: last_future_iteration) } let_it_be(:last_future_issue, refind: true) { create(:issue, namespace: group, iteration: last_future_iteration) }
let_it_be(:last_future_merge_request, refind: true) { create(:merge_request, source_branch: 'another-feature', source_project: project, iteration: last_future_iteration) } let_it_be(:last_future_merge_request, refind: true) { create(:merge_request, source_branch: 'another-feature', source_project: project, iteration: last_future_iteration) }
let_it_be(:other_cadence_iteration, refind: true) { create(:started_iteration, iterations_cadence: iteration_cadence2, group: group, start_date: start_date + 14.days, due_date: start_date + 27.days) } let_it_be(:other_cadence_iteration, refind: true) { create(:current_iteration, iterations_cadence: iteration_cadence2, group: group, start_date: start_date + 14.days, due_date: start_date + 27.days) }
let_it_be(:other_cadence_board, refind: true) { create(:board, iteration: other_cadence_iteration, group: group) } let_it_be(:other_cadence_board, refind: true) { create(:board, iteration: other_cadence_iteration, group: group) }
let_it_be(:other_cadence_issue, refind: true) { create(:issue, namespace: group, iteration: other_cadence_iteration) } let_it_be(:other_cadence_issue, refind: true) { create(:issue, namespace: group, iteration: other_cadence_iteration) }
let_it_be(:other_cadence_merge_request, refind: true) { create(:merge_request, source_branch: 'another-feature2', source_project: project, iteration: other_cadence_iteration) } let_it_be(:other_cadence_merge_request, refind: true) { create(:merge_request, source_branch: 'another-feature2', source_project: project, iteration: other_cadence_iteration) }
......
...@@ -7,13 +7,13 @@ RSpec.describe Iterations::RollOverIssuesService do ...@@ -7,13 +7,13 @@ RSpec.describe Iterations::RollOverIssuesService do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:closed_iteration1) { create(:closed_iteration, group: group) } let_it_be(:closed_iteration1) { create(:closed_iteration, group: group) }
let_it_be(:closed_iteration2) { create(:closed_iteration, group: group) } let_it_be(:closed_iteration2) { create(:closed_iteration, group: group) }
let_it_be(:started_iteration) { create(:started_iteration, group: group) } let_it_be(:current_iteration) { create(:current_iteration, group: group) }
let_it_be(:upcoming_iteration) { create(:upcoming_iteration, group: group) } let_it_be(:upcoming_iteration) { create(:upcoming_iteration, group: group) }
let_it_be(:open_issues) { [create(:issue, :opened, iteration: closed_iteration1)] } let_it_be(:open_issues) { [create(:issue, :opened, iteration: closed_iteration1)] }
let_it_be(:closed_issues) { [create(:issue, :closed, iteration: closed_iteration1)] } let_it_be(:closed_issues) { [create(:issue, :closed, iteration: closed_iteration1)] }
let(:from_iteration) { closed_iteration1 } let(:from_iteration) { closed_iteration1 }
let(:to_iteration) { started_iteration } let(:to_iteration) { current_iteration }
subject { described_class.new(user, from_iteration, to_iteration).execute } subject { described_class.new(user, from_iteration, to_iteration).execute }
...@@ -80,12 +80,12 @@ RSpec.describe Iterations::RollOverIssuesService do ...@@ -80,12 +80,12 @@ RSpec.describe Iterations::RollOverIssuesService do
it { is_expected.not_to be_error } it { is_expected.not_to be_error }
it 'rolls-over issues to next iteration' do it 'rolls-over issues to next iteration' do
expect(started_iteration.issues).to be_empty expect(current_iteration.issues).to be_empty
expect(closed_iteration1.issues).to match_array(open_issues + closed_issues) expect(closed_iteration1.issues).to match_array(open_issues + closed_issues)
expect { subject }.to change(ResourceIterationEvent, :count).by(2) expect { subject }.to change(ResourceIterationEvent, :count).by(2)
expect(started_iteration.reload.issues).to match_array(open_issues) expect(current_iteration.reload.issues).to match_array(open_issues)
expect(closed_iteration1.reload.issues).to match_array(closed_issues) expect(closed_iteration1.reload.issues).to match_array(closed_issues)
end end
end end
......
...@@ -7,10 +7,10 @@ RSpec.describe Iterations::RollOverIssuesWorker do ...@@ -7,10 +7,10 @@ RSpec.describe Iterations::RollOverIssuesWorker do
let_it_be(:group2) { create(:group) } let_it_be(:group2) { create(:group) }
let_it_be(:cadence1, reload: true) { create(:iterations_cadence, group: group1, roll_over: true, automatic: true) } let_it_be(:cadence1, reload: true) { create(:iterations_cadence, group: group1, roll_over: true, automatic: true) }
let_it_be(:cadence2) { create(:iterations_cadence, group: group2, roll_over: true, automatic: true) } let_it_be(:cadence2) { create(:iterations_cadence, group: group2, roll_over: true, automatic: true) }
let_it_be(:closed_iteration1) { create(:closed_iteration, iterations_cadence: cadence1, group: group1, start_date: 2.weeks.ago, due_date: 1.week.ago) } let_it_be(:closed_iteration1) { create(:iteration, iterations_cadence: cadence1, group: group1, start_date: 2.weeks.ago, due_date: 1.week.ago) }
let_it_be(:closed_iteration2) { create(:closed_iteration, iterations_cadence: cadence2, group: group2, start_date: 2.weeks.ago, due_date: 1.week.ago) } let_it_be(:closed_iteration2) { create(:iteration, iterations_cadence: cadence2, group: group2, start_date: 2.weeks.ago, due_date: 1.week.ago) }
let_it_be(:started_iteration1) { create(:started_iteration, iterations_cadence: cadence1, group: group1, start_date: 2.days.ago, due_date: 5.days.from_now) } let_it_be(:current_iteration1) { create(:iteration, iterations_cadence: cadence1, group: group1, start_date: 2.days.ago, due_date: 5.days.from_now) }
let_it_be(:started_iteration2) { create(:upcoming_iteration, iterations_cadence: cadence2, group: group2, start_date: 2.days.ago, due_date: 5.days.from_now) } let_it_be(:current_iteration2) { create(:iteration, iterations_cadence: cadence2, group: group2, start_date: 2.days.ago, due_date: 5.days.from_now) }
let(:mock_success_service) { double('mock service', execute: ::ServiceResponse.success) } let(:mock_success_service) { double('mock service', execute: ::ServiceResponse.success) }
let(:mock_failure_service) { double('mock service', execute: ::ServiceResponse.error(message: 'some error')) } let(:mock_failure_service) { double('mock service', execute: ::ServiceResponse.error(message: 'some error')) }
......
...@@ -4,15 +4,15 @@ require 'spec_helper' ...@@ -4,15 +4,15 @@ require 'spec_helper'
RSpec.describe IterationsUpdateStatusWorker do RSpec.describe IterationsUpdateStatusWorker do
let_it_be(:closed_iteration1, reload: true) { create(:iteration, :skip_future_date_validation, start_date: 20.days.ago, due_date: 11.days.ago) } let_it_be(:closed_iteration1, reload: true) { create(:iteration, :skip_future_date_validation, start_date: 20.days.ago, due_date: 11.days.ago) }
let_it_be(:started_iteration1, reload: true) { create(:iteration, :skip_future_date_validation, start_date: 10.days.ago, due_date: 3.days.ago) } let_it_be(:current_iteration1, reload: true) { create(:iteration, :skip_future_date_validation, start_date: 10.days.ago, due_date: 3.days.ago) }
let_it_be(:started_iteration2) { create(:iteration, :skip_future_date_validation, start_date: 2.days.ago, due_date: 5.days.from_now) } let_it_be(:current_iteration2) { create(:iteration, :skip_future_date_validation, start_date: 2.days.ago, due_date: 5.days.from_now) }
let_it_be(:upcoming_iteration) { create(:iteration, start_date: 11.days.from_now, due_date: 13.days.from_now) } let_it_be(:upcoming_iteration) { create(:iteration, start_date: 11.days.from_now, due_date: 13.days.from_now) }
subject(:worker) { described_class.new } subject(:worker) { described_class.new }
describe '#perform' do describe '#perform' do
before do before do
started_iteration1.update_column(:state_enum, 2) current_iteration1.update_column(:state_enum, 2)
closed_iteration1.update_column(:state_enum, 1) closed_iteration1.update_column(:state_enum, 1)
end end
...@@ -22,18 +22,18 @@ RSpec.describe IterationsUpdateStatusWorker do ...@@ -22,18 +22,18 @@ RSpec.describe IterationsUpdateStatusWorker do
worker.perform worker.perform
end end
context 'when iterations with passed due dates are in `upcoming`, `started` or `closes` states' do context 'when iterations with passed due dates are in `upcoming`, `current` or `closes` states' do
it 'updates the status of iterations that require it', :aggregate_failures do it 'updates the status of iterations that require it', :aggregate_failures do
expect(closed_iteration1.state).to eq('upcoming') expect(closed_iteration1.state).to eq('upcoming')
expect(started_iteration1.state).to eq('started') expect(current_iteration1.state).to eq('current')
expect(started_iteration2.state).to eq('started') expect(current_iteration2.state).to eq('current')
expect(upcoming_iteration.state).to eq('upcoming') expect(upcoming_iteration.state).to eq('upcoming')
worker.perform worker.perform
expect(closed_iteration1.reload.state).to eq('closed') expect(closed_iteration1.reload.state).to eq('closed')
expect(started_iteration1.reload.state).to eq('closed') expect(current_iteration1.reload.state).to eq('closed')
expect(started_iteration2.reload.state).to eq('started') expect(current_iteration2.reload.state).to eq('current')
expect(upcoming_iteration.reload.state).to eq('upcoming') expect(upcoming_iteration.reload.state).to eq('upcoming')
end end
......
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