Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPL-1032 RVI - added state processed 4 and bed verification #3993

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/models/transfer_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class TransferRequest < ApplicationRecord # rubocop:todo Metrics/ClassLength
state :processed_1
state :processed_2
state :processed_3
state :processed_4
state :failed, enter: :on_failed
state :passed
state :qc_complete
Expand All @@ -81,18 +82,22 @@ class TransferRequest < ApplicationRecord # rubocop:todo Metrics/ClassLength
transitions to: :processed_3, from: [:processed_2]
end

event :process_4 do
transitions to: :processed_4, from: [:processed_3]
end

event :pass do
# Jumping straight to passed moves through an implied started state.
transitions to: :passed, from: :pending, after: :on_started
transitions to: :passed, from: %i[started failed processed_2 processed_3]
transitions to: :passed, from: %i[started failed processed_2 processed_3 processed_4]
end

event :fail do
transitions to: :failed, from: %i[pending started processed_1 processed_2 processed_3 passed]
transitions to: :failed, from: %i[pending started processed_1 processed_2 processed_3 processed_4 passed]
end

event :cancel do
transitions to: :cancelled, from: %i[started processed_1 processed_2 processed_3 passed qc_complete]
transitions to: :cancelled, from: %i[started processed_1 processed_2 processed_3 processed_4 passed qc_complete]
end

event :cancel_before_started do
Expand Down
7 changes: 1 addition & 6 deletions features/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@
options.add_argument('--headless')
options.add_argument('--window-size=1600,3200')
options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
the_driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)

# the following is needed to avoid a test failure where the driver would
# forget / ignore its configured download location on every other run
the_driver.browser.download_path = DownloadHelpers::PATH.to_s
the_driver
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Capybara.register_driver :chrome do |app|
Expand Down
24 changes: 24 additions & 0 deletions spec/models/state_changer/initial_stock_tube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,30 @@
expect(request.reload.state).to eq('started')
end
end

context 'when transitioning to "processed_4" with "started" requests' do
let(:target_state) { 'processed_4' }
let(:request_state) { 'started' }

it 'updates the tube to "processed_4" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('processed_4')
expect(request.reload.state).to eq('started')
end
end
end

context 'when the tube is: "processed_4"' do
let(:transfer_request_state) { 'processed_4' }

context 'when transitioning to "passed" with "started" requests' do
let(:target_state) { 'passed' }
let(:request_state) { 'started' }

it 'updates the tube to "passed" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('passed')
expect(request.reload.state).to eq('started')
end
end
end

context 'when the tube is: "passed"' do
Expand Down
24 changes: 24 additions & 0 deletions spec/models/state_changer/mx_tube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ def create_requests_and_transfers
expect(request.reload.state).to eq('passed')
end
end

context 'when transitioning to "processed_4" with "started" requests' do
let(:target_state) { 'processed_4' }
let(:request_state) { 'started' }

it 'updates the tube to "processed_4" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('processed_4')
expect(request.reload.state).to eq('started')
end
end
end

context 'when the tube is: "processed_4"' do
let(:transfer_request_state) { 'processed_4' }

context 'when transitioning to "passed" with "passed" requests' do
let(:target_state) { 'passed' }
let(:request_state) { 'started' }

it 'updates the tube to "passed" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('passed')
expect(request.reload.state).to eq('passed')
end
end
end

context 'when the tube is: "passed"' do
Expand Down
24 changes: 24 additions & 0 deletions spec/models/state_changer/stock_tube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,30 @@
expect(request.reload.state).to eq('started')
end
end

context 'when transitioning to "processed_4" with "started" requests' do
let(:target_state) { 'processed_4' }
let(:request_state) { 'started' }

it 'updates the tube to "processed_4" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('processed_4')
expect(request.reload.state).to eq('started')
end
end
end

context 'when the tube is: "processed_4"' do
let(:transfer_request_state) { 'processed_4' }

context 'when transitioning to "passed" with "started" requests' do
let(:target_state) { 'passed' }
let(:request_state) { 'started' }

it 'updates the tube to "passed" with "started" requests', :aggregate_failures do
expect(transfer_request.reload.state).to eq('passed')
expect(request.reload.state).to eq('started')
end
end
end

context 'when the tube is: "passed"' do
Expand Down
8 changes: 7 additions & 1 deletion spec/models/transfer_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@
started: :passed,
failed: :passed,
processed_2: :passed,
processed_3: :passed
processed_3: :passed,
processed_4: :passed
},
process_1: {
pending: :processed_1
Expand All @@ -280,6 +281,9 @@
process_3: {
processed_2: :processed_3
},
process_4: {
processed_3: :processed_4
},
qc: {
passed: :qc_complete
},
Expand All @@ -289,13 +293,15 @@
processed_1: :failed,
processed_2: :failed,
processed_3: :failed,
processed_4: :failed,
passed: :failed
},
cancel: {
started: :cancelled,
processed_1: :cancelled,
processed_2: :cancelled,
processed_3: :cancelled,
processed_4: :cancelled,
passed: :cancelled,
qc_complete: :cancelled
},
Expand Down
13 changes: 5 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@

options.add_argument('--headless')
options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
the_driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)

# copied the following over from features/support/capybara.rb because I expect it is also relevant here
the_driver.browser.download_path = DownloadHelpers::PATH.to_s if the_driver.browser.respond_to?(:download_path=)
the_driver
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Capybara.register_driver :selenium_chrome do |app|
driver = Capybara::Selenium::Driver.new(app, browser: :chrome)
driver.browser.download_path = DownloadHelpers::PATH.to_s
driver
options = Selenium::WebDriver::Chrome::Options.new

options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Capybara.javascript_driver = ENV.fetch('JS_DRIVER', 'headless_chrome').to_sym
Expand Down
Loading