Commit 52bff7f7 authored by Jarka Košanová's avatar Jarka Košanová

Change Iteration namespace to Iterations

- use iterations_cadences as table name
- rename FK column to iterations_cadence_id
parent 6b2a862f
......@@ -34,7 +34,7 @@ class Group < Namespace
has_many :milestones
has_many :iterations
has_many :iteration_cadences, class_name: 'Iteration::Cadence'
has_many :iterations_cadences, class_name: 'Iterations::Cadence'
has_many :services
has_many :shared_group_links, foreign_key: :shared_with_group_id, class_name: 'GroupGroupLink'
has_many :shared_with_group_links, foreign_key: :shared_group_id, class_name: 'GroupGroupLink'
......
......@@ -16,7 +16,7 @@ class Iteration < ApplicationRecord
belongs_to :project
belongs_to :group
belongs_to :iteration_cadence, class_name: 'Iteration::Cadence', foreign_key: :iteration_cadence_id, inverse_of: :iterations
belongs_to :iterations_cadence, class_name: 'Iterations::Cadence', foreign_key: :iterations_cadence_id, inverse_of: :iterations
has_internal_id :iid, scope: :project
has_internal_id :iid, scope: :group
......@@ -29,7 +29,7 @@ class Iteration < ApplicationRecord
validate :no_project, unless: :skip_project_validation
validate :validate_group
before_create :set_iteration_cadence
before_create :set_iterations_cadence
scope :upcoming, -> { with_state(:upcoming) }
scope :started, -> { with_state(:started) }
......@@ -141,25 +141,25 @@ class Iteration < ApplicationRecord
end
# TODO: this method should be removed as part of https://gitlab.com/gitlab-org/gitlab/-/issues/296099
def set_iteration_cadence
return if iteration_cadence
def set_iterations_cadence
return if iterations_cadence
# For now we support only group iterations
# issue to clarify project iterations: https://gitlab.com/gitlab-org/gitlab/-/issues/299864
return unless group
self.iteration_cadence = group.iteration_cadences.first || create_default_cadence
self.iterations_cadence = group.iterations_cadences.first || create_default_cadence
end
def create_default_cadence
cadence_title = "#{group.name} Iterations"
Iteration::Cadence.create!(group: group, title: cadence_title, start_date: start_date)
Iterations::Cadence.create!(group: group, title: cadence_title, start_date: start_date)
end
# TODO: remove this as part of https://gitlab.com/gitlab-org/gitlab/-/issues/296100
def validate_group
return unless iteration_cadence
return if iteration_cadence.group_id == group_id
return unless iterations_cadence
return if iterations_cadence.group_id == group_id
errors.add(:group, s_('is not valid. The iteration group has to match the iteration cadence group.'))
end
......
# frozen_string_literal: true
class Iteration::Cadence < ApplicationRecord
self.table_name = 'iteration_cadences'
class Iterations::Cadence < ApplicationRecord
self.table_name = 'iterations_cadences'
belongs_to :group
has_many :iterations, foreign_key: :iteration_cadence_id, inverse_of: :iteration_cadence
has_many :iterations, foreign_key: :iterations_cadence_id, inverse_of: :iterations_cadence
validates :title, presence: true
validates :start_date, presence: true
......
---
title: Add iteration_cadences table and respective model
title: Add iterations_cadences table and respective model
merge_request: 50707
author:
type: other
# frozen_string_literal: true
class CreateIterationCadence < ActiveRecord::Migration[6.0]
class CreateIterationsCadence < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
......@@ -8,7 +8,7 @@ class CreateIterationCadence < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
create_table_with_constraints :iteration_cadences do |t|
create_table_with_constraints :iterations_cadences do |t|
t.references :group, null: false, foreign_key: { to_table: :namespaces, on_delete: :cascade }
t.timestamps_with_timezone null: false
t.date :start_date, null: false
......@@ -24,6 +24,6 @@ class CreateIterationCadence < ActiveRecord::Migration[6.0]
end
def down
drop_table :iteration_cadences if table_exists?(:iteration_cadences)
drop_table :iterations_cadences if table_exists?(:iterations_cadences)
end
end
# frozen_string_literal: true
class AddIterationCadenceToSprints < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_sprints_iteration_cadence_id'
def up
add_column :sprints, :iteration_cadence_id, :integer unless column_exists?(:sprints, :iteration_cadence_id)
add_concurrent_index :sprints, :iteration_cadence_id, name: INDEX_NAME
add_concurrent_foreign_key :sprints, :iteration_cadences, column: :iteration_cadence_id, on_delete: :cascade
end
def down
remove_column :sprints, :iteration_cadence_id if column_exists?(:sprints, :iteration_cadence_id)
end
end
# frozen_string_literal: true
class AddIterationsCadenceToSprints < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_sprints_iterations_cadence_id'
def up
add_column :sprints, :iterations_cadence_id, :integer unless column_exists?(:sprints, :iterations_cadence_id)
add_concurrent_index :sprints, :iterations_cadence_id, name: INDEX_NAME
add_concurrent_foreign_key :sprints, :iterations_cadences, column: :iterations_cadence_id, on_delete: :cascade
end
def down
remove_column :sprints, :iterations_cadence_id if column_exists?(:sprints, :iterations_cadence_id)
end
end
......@@ -13544,7 +13544,7 @@ CREATE TABLE issues_self_managed_prometheus_alert_events (
updated_at timestamp with time zone NOT NULL
);
CREATE TABLE iteration_cadences (
CREATE TABLE iterations_cadences (
id bigint NOT NULL,
group_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
......@@ -13556,17 +13556,17 @@ CREATE TABLE iteration_cadences (
active boolean DEFAULT true NOT NULL,
automatic boolean DEFAULT true NOT NULL,
title text NOT NULL,
CONSTRAINT check_6b6fe7cdea CHECK ((char_length(title) <= 255))
CONSTRAINT check_fedff82d3b CHECK ((char_length(title) <= 255))
);
CREATE SEQUENCE iteration_cadences_id_seq
CREATE SEQUENCE iterations_cadences_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE iteration_cadences_id_seq OWNED BY iteration_cadences.id;
ALTER SEQUENCE iterations_cadences_id_seq OWNED BY iterations_cadences.id;
CREATE TABLE jira_connect_installations (
id bigint NOT NULL,
......@@ -17380,7 +17380,7 @@ CREATE TABLE sprints (
description text,
description_html text,
state_enum smallint DEFAULT 1 NOT NULL,
iteration_cadence_id integer,
iterations_cadence_id integer,
CONSTRAINT sprints_must_belong_to_project_or_group CHECK ((((project_id <> NULL::bigint) AND (group_id IS NULL)) OR ((group_id <> NULL::bigint) AND (project_id IS NULL)))),
CONSTRAINT sprints_title CHECK ((char_length(title) <= 255))
);
......@@ -19092,7 +19092,7 @@ ALTER TABLE ONLY issue_user_mentions ALTER COLUMN id SET DEFAULT nextval('issue_
ALTER TABLE ONLY issues ALTER COLUMN id SET DEFAULT nextval('issues_id_seq'::regclass);
ALTER TABLE ONLY iteration_cadences ALTER COLUMN id SET DEFAULT nextval('iteration_cadences_id_seq'::regclass);
ALTER TABLE ONLY iterations_cadences ALTER COLUMN id SET DEFAULT nextval('iterations_cadences_id_seq'::regclass);
ALTER TABLE ONLY jira_connect_installations ALTER COLUMN id SET DEFAULT nextval('jira_connect_installations_id_seq'::regclass);
......@@ -20388,15 +20388,15 @@ ALTER TABLE ONLY issues_prometheus_alert_events
ALTER TABLE ONLY issues_self_managed_prometheus_alert_events
ADD CONSTRAINT issues_self_managed_prometheus_alert_events_pkey PRIMARY KEY (issue_id, self_managed_prometheus_alert_event_id);
ALTER TABLE ONLY iteration_cadences
ADD CONSTRAINT iteration_cadences_pkey PRIMARY KEY (id);
ALTER TABLE ONLY sprints
ADD CONSTRAINT iteration_start_and_due_daterange_group_id_constraint EXCLUDE USING gist (group_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((group_id IS NOT NULL));
ALTER TABLE ONLY sprints
ADD CONSTRAINT iteration_start_and_due_daterange_project_id_constraint EXCLUDE USING gist (project_id WITH =, daterange(start_date, due_date, '[]'::text) WITH &&) WHERE ((project_id IS NOT NULL));
ALTER TABLE ONLY iterations_cadences
ADD CONSTRAINT iterations_cadences_pkey PRIMARY KEY (id);
ALTER TABLE ONLY jira_connect_installations
ADD CONSTRAINT jira_connect_installations_pkey PRIMARY KEY (id);
......@@ -22470,7 +22470,7 @@ CREATE INDEX index_issues_on_updated_at ON issues USING btree (updated_at);
CREATE INDEX index_issues_on_updated_by_id ON issues USING btree (updated_by_id) WHERE (updated_by_id IS NOT NULL);
CREATE INDEX index_iteration_cadences_on_group_id ON iteration_cadences USING btree (group_id);
CREATE INDEX index_iterations_cadences_on_group_id ON iterations_cadences USING btree (group_id);
CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON jira_connect_installations USING btree (client_key);
......@@ -23460,7 +23460,7 @@ CREATE UNIQUE INDEX index_sop_configs_on_project_id ON security_orchestration_po
CREATE UNIQUE INDEX index_sop_configs_on_security_policy_management_project_id ON security_orchestration_policy_configurations USING btree (security_policy_management_project_id);
CREATE INDEX index_sprints_iteration_cadence_id ON sprints USING btree (iteration_cadence_id);
CREATE INDEX index_sprints_iterations_cadence_id ON sprints USING btree (iterations_cadence_id);
CREATE INDEX index_sprints_on_description_trigram ON sprints USING gin (description gin_trgm_ops);
......@@ -24299,6 +24299,9 @@ ALTER TABLE ONLY namespaces
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_3654b61b03 FOREIGN KEY (author_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE ONLY sprints
ADD CONSTRAINT fk_365d1db505 FOREIGN KEY (iterations_cadence_id) REFERENCES iterations_cadences(id) ON DELETE CASCADE;
ALTER TABLE ONLY push_event_payloads
ADD CONSTRAINT fk_36c74129da FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE;
......@@ -24728,9 +24731,6 @@ ALTER TABLE ONLY project_group_links
ALTER TABLE ONLY epics
ADD CONSTRAINT fk_dccd3f98fc FOREIGN KEY (assignee_id) REFERENCES users(id) ON DELETE SET NULL;
ALTER TABLE ONLY sprints
ADD CONSTRAINT fk_de14ba038f FOREIGN KEY (iteration_cadence_id) REFERENCES iteration_cadences(id) ON DELETE CASCADE;
ALTER TABLE ONLY analytics_devops_adoption_segment_selections
ADD CONSTRAINT fk_ded7fe0344 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
......@@ -25124,9 +25124,6 @@ ALTER TABLE ONLY packages_debian_group_component_files
ALTER TABLE ONLY boards_epic_board_labels
ADD CONSTRAINT fk_rails_2bedeb8799 FOREIGN KEY (label_id) REFERENCES labels(id) ON DELETE CASCADE;
ALTER TABLE ONLY iteration_cadences
ADD CONSTRAINT fk_rails_2cbf3ce526 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY onboarding_progresses
ADD CONSTRAINT fk_rails_2ccfd420cc FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE;
......@@ -26180,6 +26177,9 @@ ALTER TABLE ONLY alert_management_alert_user_mentions
ALTER TABLE ONLY snippet_statistics
ADD CONSTRAINT fk_rails_ebc283ccf1 FOREIGN KEY (snippet_id) REFERENCES snippets(id) ON DELETE CASCADE;
ALTER TABLE ONLY iterations_cadences
ADD CONSTRAINT fk_rails_ece400c55a FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY dast_profiles
ADD CONSTRAINT fk_rails_ed1e66fbbf FOREIGN KEY (dast_site_profile_id) REFERENCES dast_site_profiles(id) ON DELETE CASCADE;
......@@ -319,8 +319,8 @@ RSpec.describe Banzai::Filter::IterationReferenceFilter do
project_reference = another_project.to_reference_base(project)
input_text = "See #{project_reference}#{reference}"
# we have to update iteration_cadence group first in order to avoid invalid record
iteration.iteration_cadence.update_column(:group_id, another_group.id)
# we have to update iterations_cadence group first in order to avoid invalid record
iteration.iterations_cadence.update_column(:group_id, another_group.id)
iteration.update_column(:group_id, another_group.id)
doc = reference_filter(input_text)
......@@ -330,8 +330,8 @@ RSpec.describe Banzai::Filter::IterationReferenceFilter do
end
it 'supports parent group references' do
# we have to update iteration_cadence group first in order to avoid invallid record
iteration.iteration_cadence.update_column(:group_id, parent_group.id)
# we have to update iterations_cadence group first in order to avoid invallid record
iteration.iterations_cadence.update_column(:group_id, parent_group.id)
iteration.update_column(:group_id, parent_group.id)
doc = reference_filter("See #{reference}")
......
......@@ -9,7 +9,7 @@ module Gitlab
end
class IterationCadence < ApplicationRecord
self.table_name = 'iteration_cadences'
self.table_name = 'iterations_cadences'
include BulkInsertSafe
end
......@@ -19,13 +19,13 @@ module Gitlab
end
def perform(*group_ids)
create_iteration_cadences(group_ids)
assign_iteration_cadences(group_ids)
create_iterations_cadences(group_ids)
assign_iterations_cadences(group_ids)
end
private
def create_iteration_cadences(group_ids)
def create_iterations_cadences(group_ids)
groups_with_cadence = IterationCadence.select(:group_id)
new_cadences = Group.where(id: group_ids).where.not(id: groups_with_cadence).map do |group|
last_iteration = Iteration.where(group_id: group.id).order(:start_date)&.last
......@@ -47,9 +47,9 @@ module Gitlab
IterationCadence.bulk_insert!(new_cadences.compact)
end
def assign_iteration_cadences(group_ids)
def assign_iterations_cadences(group_ids)
IterationCadence.where(group_id: group_ids).each do |cadence|
Iteration.where(iteration_cadence_id: nil).where(group_id: cadence.group_id).update_all(iteration_cadence_id: cadence.id)
Iteration.where(iterations_cadence_id: nil).where(group_id: cadence.group_id).update_all(iterations_cadence_id: cadence.id)
end
end
end
......
......@@ -5,7 +5,7 @@ FactoryBot.define do
n.days.from_now
end
factory :iteration_cadence, class: 'Iteration::Cadence' do
factory :iterations_cadence, class: 'Iterations::Cadence' do
title
group
start_date { generate(:cadence_sequential_date) }
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe Gitlab::BackgroundMigration::SetDefaultIterationCadences, schema: 20201231133921 do
let(:namespaces) { table(:namespaces) }
let(:iterations) { table(:sprints) }
let(:iteration_cadences) { table(:iteration_cadences) }
let(:iterations_cadences) { table(:iterations_cadences) }
describe '#perform' do
context 'when no iteration cadences exists' do
......@@ -21,26 +21,26 @@ RSpec.describe Gitlab::BackgroundMigration::SetDefaultIterationCadences, schema:
described_class.new.perform(group_1.id, group_2.id, group_3.id, namespaces.last.id + 1)
end
it 'creates iteration_cadence records for the requested groups' do
expect(iteration_cadences.count).to eq(2)
it 'creates iterations_cadence records for the requested groups' do
expect(iterations_cadences.count).to eq(2)
end
it 'assigns the iteration cadences to the iterations correctly' do
iteration_cadence = iteration_cadences.find_by(group_id: group_1.id)
iteration_records = iterations.where(iteration_cadence_id: iteration_cadence.id)
iterations_cadence = iterations_cadences.find_by(group_id: group_1.id)
iteration_records = iterations.where(iterations_cadence_id: iterations_cadence.id)
expect(iteration_cadence.start_date).to eq(iteration_1.start_date)
expect(iteration_cadence.last_run_date).to eq(iteration_1.start_date)
expect(iteration_cadence.title).to eq('group 1 Iterations')
expect(iterations_cadence.start_date).to eq(iteration_1.start_date)
expect(iterations_cadence.last_run_date).to eq(iteration_1.start_date)
expect(iterations_cadence.title).to eq('group 1 Iterations')
expect(iteration_records.size).to eq(1)
expect(iteration_records.first.id).to eq(iteration_1.id)
iteration_cadence = iteration_cadences.find_by(group_id: group_3.id)
iteration_records = iterations.where(iteration_cadence_id: iteration_cadence.id)
iterations_cadence = iterations_cadences.find_by(group_id: group_3.id)
iteration_records = iterations.where(iterations_cadence_id: iterations_cadence.id)
expect(iteration_cadence.start_date).to eq(iteration_3.start_date)
expect(iteration_cadence.last_run_date).to eq(iteration_3.start_date)
expect(iteration_cadence.title).to eq('group 3 Iterations')
expect(iterations_cadence.start_date).to eq(iteration_3.start_date)
expect(iterations_cadence.last_run_date).to eq(iteration_3.start_date)
expect(iterations_cadence.title).to eq('group 3 Iterations')
expect(iteration_records.size).to eq(2)
expect(iteration_records.first.id).to eq(iteration_2.id)
expect(iteration_records.second.id).to eq(iteration_3.id)
......@@ -50,25 +50,25 @@ RSpec.describe Gitlab::BackgroundMigration::SetDefaultIterationCadences, schema:
context 'when an iteration cadence exists for a group' do
let!(:group) { namespaces.create!(name: 'group', path: 'group') }
let!(:iteration_cadence_1) { iteration_cadences.create!(group_id: group.id, start_date: 5.days.ago, title: 'Cadence 1') }
let!(:iteration_cadence_2) { iteration_cadences.create!(group_id: group.id, start_date: 2.days.ago, title: 'Cadence 2') }
let!(:iterations_cadence_1) { iterations_cadences.create!(group_id: group.id, start_date: 5.days.ago, title: 'Cadence 1') }
let!(:iterations_cadence_2) { iterations_cadences.create!(group_id: group.id, start_date: 2.days.ago, title: 'Cadence 2') }
let!(:iteration_1) { iterations.create!(group_id: group.id, iid: 1, title: 'Iteration 1', start_date: 10.days.ago, due_date: 8.days.ago) }
let!(:iteration_2) { iterations.create!(group_id: group.id, iteration_cadence_id: iteration_cadence_1.id, iid: 2, title: 'Iteration 2', start_date: 5.days.ago, due_date: 3.days.ago) }
let!(:iteration_3) { iterations.create!(group_id: group.id, iteration_cadence_id: iteration_cadence_2.id, iid: 3, title: 'Iteration 3', start_date: 2.days.ago, due_date: 1.day.ago) }
let!(:iteration_2) { iterations.create!(group_id: group.id, iterations_cadence_id: iterations_cadence_1.id, iid: 2, title: 'Iteration 2', start_date: 5.days.ago, due_date: 3.days.ago) }
let!(:iteration_3) { iterations.create!(group_id: group.id, iterations_cadence_id: iterations_cadence_2.id, iid: 3, title: 'Iteration 3', start_date: 2.days.ago, due_date: 1.day.ago) }
subject { described_class.new.perform(group.id) }
it 'does not create a new iteration_cadence' do
expect { subject }.not_to change { iteration_cadences.count }
it 'does not create a new iterations_cadence' do
expect { subject }.not_to change { iterations_cadences.count }
end
it 'assigns iteration cadences to iterations if needed' do
subject
expect(iteration_1.reload.iteration_cadence_id).to eq(iteration_cadence_1.id)
expect(iteration_2.reload.iteration_cadence_id).to eq(iteration_cadence_1.id)
expect(iteration_3.reload.iteration_cadence_id).to eq(iteration_cadence_2.id)
expect(iteration_1.reload.iterations_cadence_id).to eq(iterations_cadence_1.id)
expect(iteration_2.reload.iterations_cadence_id).to eq(iterations_cadence_1.id)
expect(iteration_3.reload.iterations_cadence_id).to eq(iterations_cadence_2.id)
end
end
end
......
......@@ -10,7 +10,7 @@ RSpec.describe Iteration do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:iteration_cadence).inverse_of(:iterations) }
it { is_expected.to belong_to(:iterations_cadence).inverse_of(:iterations) }
end
describe "#iid" do
......@@ -40,43 +40,43 @@ RSpec.describe Iteration do
end
describe 'setting iteration cadence' do
let_it_be(:iteration_cadence) { create(:iteration_cadence, group: group, start_date: 10.days.ago) }
let(:iteration) { create(:iteration, group: group, iteration_cadence: set_cadence, start_date: 2.days.from_now) }
let_it_be(:iterations_cadence) { create(:iterations_cadence, group: group, start_date: 10.days.ago) }
let(:iteration) { create(:iteration, group: group, iterations_cadence: set_cadence, start_date: 2.days.from_now) }
context 'when iteration_cadence is set correctly' do
let(:set_cadence) { iteration_cadence}
context 'when iterations_cadence is set correctly' do
let(:set_cadence) { iterations_cadence}
it 'does not change the iteration_cadence' do
expect(iteration.iteration_cadence).to eq(iteration_cadence)
it 'does not change the iterations_cadence' do
expect(iteration.iterations_cadence).to eq(iterations_cadence)
end
end
context 'when iteration_cadence exists for the group' do
context 'when iterations_cadence exists for the group' do
let(:set_cadence) { nil }
it 'sets the iteration_cadence to the existing record' do
expect(iteration.iteration_cadence).to eq(iteration_cadence)
it 'sets the iterations_cadence to the existing record' do
expect(iteration.iterations_cadence).to eq(iterations_cadence)
end
end
context 'when iteration_cadence does not exists for the group' do
context 'when iterations_cadence does not exists for the group' do
let_it_be(:group) { create(:group, name: 'Test group')}
let(:iteration) { build(:iteration, group: group, iteration_cadence: set_cadence) }
let(:iteration) { build(:iteration, group: group, iterations_cadence: set_cadence) }
it 'creates a default iteration_cadence and uses it for the iteration' do
expect { iteration.save! }.to change { Iteration::Cadence.count }.by(1)
it 'creates a default iterations_cadence and uses it for the iteration' do
expect { iteration.save! }.to change { Iterations::Cadence.count }.by(1)
end
it 'sets the newly created iteration_cadence to the reecord' do
it 'sets the newly created iterations_cadence to the reecord' do
iteration.save!
expect(iteration.iteration_cadence).to eq(Iteration::Cadence.last)
expect(iteration.iterations_cadence).to eq(Iterations::Cadence.last)
end
it 'creates the iteration_cadence with the correct attributes' do
it 'creates the iterations_cadence with the correct attributes' do
iteration.save!
cadence = Iteration::Cadence.last
cadence = Iterations::Cadence.last
expect(cadence.reload.start_date).to eq(iteration.start_date)
expect(cadence.title).to eq('Test group Iterations')
......@@ -84,10 +84,10 @@ RSpec.describe Iteration do
end
context 'when iteration is a project iteration' do
it 'does not set the iteration_cadence' do
iteration = create(:iteration, iteration_cadence: nil, project: project, skip_project_validation: true)
it 'does not set the iterations_cadence' do
iteration = create(:iteration, iterations_cadence: nil, project: project, skip_project_validation: true)
expect(iteration.reload.iteration_cadence).to be_nil
expect(iteration.reload.iterations_cadence).to be_nil
end
end
end
......@@ -368,11 +368,11 @@ RSpec.describe Iteration do
end
describe '#validate_group' do
let_it_be(:iteration_cadence) { create(:iteration_cadence, group: group) }
let_it_be(:iterations_cadence) { create(:iterations_cadence, group: group) }
context 'when the iteration and iteration cadence groups are same' do
it 'is valid' do
iteration = build(:iteration, group: group, iteration_cadence: iteration_cadence)
iteration = build(:iteration, group: group, iterations_cadence: iterations_cadence)
expect(iteration).to be_valid
end
......@@ -381,7 +381,7 @@ RSpec.describe Iteration do
context 'when the iteration and iteration cadence groups are different' do
it 'is invalid' do
other_group = create(:group)
iteration = build(:iteration, group: other_group, iteration_cadence: iteration_cadence)
iteration = build(:iteration, group: other_group, iterations_cadence: iterations_cadence)
expect(iteration).not_to be_valid
end
......@@ -389,7 +389,7 @@ RSpec.describe Iteration do
context 'when the iteration belongs to a project and the iteration cadence is set' do
it 'is invalid' do
iteration = build(:iteration, project: project, iteration_cadence: iteration_cadence, skip_project_validation: true)
iteration = build(:iteration, project: project, iterations_cadence: iterations_cadence, skip_project_validation: true)
expect(iteration).to be_invalid
end
......
......@@ -2,16 +2,16 @@
require 'spec_helper'
RSpec.describe Iteration::Cadence do
RSpec.describe Iterations::Cadence do
describe 'associations' do
subject { build(:iteration_cadence) }
subject { build(:iterations_cadence) }
it { is_expected.to belong_to(:group) }
it { is_expected.to have_many(:iterations).inverse_of(:iteration_cadence) }
it { is_expected.to have_many(:iterations).inverse_of(:iterations_cadence) }
end
describe 'validations' do
subject { build(:iteration_cadence) }
subject { build(:iterations_cadence) }
it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_presence_of(:start_date) }
......
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