-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from sanger/develop
Merge develop into master
- Loading branch information
Showing
3 changed files
with
67 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
require 'lighthouse' | ||
require 'wrangler' | ||
|
||
class ProcessPlatesControllerTest < ActiveSupport::TestCase | ||
context 'while testing public functions' do | ||
should 'sanitize barcodes' do | ||
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 456'), %w[123 456]) | ||
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 456'), %w[123 456]) | ||
assert_equal(ProcessPlatesController.new.sanitize_barcodes('123 123 456'), %w[123 456]) | ||
assert_equal(ProcessPlatesController.new.sanitize_barcodes("123\n456"), %w[123 456]) | ||
end | ||
|
||
should 'verify all responses are HTTP CREATED (201)' do | ||
assert_equal(ProcessPlatesController.new.all_created?([]), false) | ||
assert_equal(ProcessPlatesController.new.all_created?([{ code: '201' }, { code: '201' }]), true) | ||
assert_equal(ProcessPlatesController.new.all_created?([{ code: 201 }, { code: 201 }]), false) | ||
assert_equal(ProcessPlatesController.new.all_created?([{ code: '201' }, { code: '200' }]), false) | ||
end | ||
|
||
should 'call external services 1' do | ||
Lighthouse.expects(:call_api).with(%w[123 456]).returns([]) | ||
Wrangler.expects(:call_api).with(%w[123 456]) | ||
ProcessPlatesController.new.call_external_services(%w[123 456]) | ||
end | ||
|
||
should 'call external services 2' do | ||
Lighthouse.expects(:call_api).with(%w[123 456]).returns([{ code: 400 }]) | ||
Wrangler.expects(:call_api).with(%w[123 456]) | ||
ProcessPlatesController.new.call_external_services(%w[123 456]) | ||
end | ||
|
||
should 'call only lighthouse service' do | ||
Lighthouse.expects(:call_api).returns([{ code: '201' }]) | ||
ProcessPlatesController.new.call_external_services(%w[123 456]) | ||
end | ||
end | ||
end |