mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-15 03:13:20 +08:00
Merge pull request #2796 from mlorb/ml-sci-4934
Add factories for new task flows models [SCI-4934]
This commit is contained in:
commit
d8378f4bc4
7 changed files with 50 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
|
7
spec/factories/my_module_status_conditions.rb
Normal file
7
spec/factories/my_module_status_conditions.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :active_condition, class: 'MyModuleStatusConditions::Active' do
|
||||
my_module_status
|
||||
end
|
||||
end
|
7
spec/factories/my_module_status_consequences.rb
Normal file
7
spec/factories/my_module_status_consequences.rb
Normal 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
|
|
@ -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
|
||||
|
|
7
spec/factories/my_module_status_implications.rb
Normal file
7
spec/factories/my_module_status_implications.rb
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue