Merge pull request #2796 from mlorb/ml-sci-4934

Add factories for new task flows models [SCI-4934]
This commit is contained in:
Urban Rotnik 2020-08-31 11:16:39 +02:00 committed by GitHub
commit d8378f4bc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 13 deletions

View file

@ -133,21 +133,18 @@ describe MyModulesController, type: :controller do
my_module: { status_id: status_id }
}
end
let(:my_module_status_flow) { create :my_module_status_flow, :in_team, team: team}
let(:status1) {create :my_module_status, my_module_status_flow: my_module_status_flow}
let(:status2) {create :my_module_status, my_module_status_flow: my_module_status_flow}
before(:all) do
MyModuleStatusFlow.ensure_default
end
context 'when states updated' do
let(:status_id) { status2.id }
before do
my_module.update(my_module_status: status1)
end
let(:status_id) { my_module.my_module_status.next_status.id }
it 'changes status' do
action
expect(my_module.reload.my_module_status.name).to be_eql(status2.name)
expect(my_module.reload.my_module_status.id).to be_eql(status_id)
expect(response).to have_http_status 200
end
end
@ -155,10 +152,6 @@ describe MyModulesController, type: :controller do
context 'when status not found' do
let(:status_id) { -1 }
before do
my_module.update(my_module_status: status1)
end
it 'renders 404' do
action

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :active_condition, class: 'MyModuleStatusConditions::Active' do
my_module_status
end
end

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :change_activity_consequence, class: 'MyModuleStatusConsequences::ChangeActivity' do
my_module_status
end
end

View file

@ -8,5 +8,10 @@ FactoryBot.define do
team { create :team }
visibility { :in_team }
end
trait :with_statuses do
after(:create) do |flow|
create_list :my_module_status, 3, my_module_status_flow: flow
end
end
end
end

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
FactoryBot.define do
factory :read_only_implication, class: 'MyModuleStatusImplications::ReadOnly' do
my_module_status
end
end

View file

@ -6,5 +6,20 @@ FactoryBot.define do
description { Faker::Lorem.sentence }
color { Faker::Color.hex_color }
my_module_status_flow
trait :with_consequence do
after(:create) do |status|
create :my_module_status_consequence, my_module_status: status
end
end
trait :with_conditions do
after(:create) do |status|
create :my_module_status_condition, my_module_status: status
end
end
trait :with_implications do
after(:create) do |status|
create :my_module_status_implication, my_module_status: status
end
end
end
end

View file

@ -14,5 +14,8 @@ FactoryBot.define do
trait :with_due_date do
due_date { Faker::Time.between(from: Date.today, to: Date.today + 10.days) }
end
trait :with_status do
my_module_status
end
end
end