diff --git a/.pryrc b/.pryrc new file mode 100644 index 000000000..ca997213f --- /dev/null +++ b/.pryrc @@ -0,0 +1,7 @@ +# frozen_string_literal: true +if defined?(PryByebug) + Pry.commands.alias_command 's', 'step' + Pry.commands.alias_command 'n', 'next' + Pry.commands.alias_command 'f', 'finish' + Pry.commands.alias_command 'c', 'continue' +end diff --git a/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.spec.js b/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.spec.js index 037afeb9c..954bfc22e 100644 --- a/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.spec.js +++ b/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.spec.js @@ -833,8 +833,8 @@ describe('CustomTaggedPlate', () => { purpose_uuid: 'purpose-uuid', parent_uuid: 'parent-plate-uuid', tag_layout: { - tag_group: 'tag-1-group-uuid', - tag2_group: 'tag-2-group-uuid', + tag_group_uuid: 'tag-1-group-uuid', + tag2_group_uuid: 'tag-2-group-uuid', direction: 'column', walking_by: 'manual by plate', initial_tag: 1, diff --git a/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.vue b/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.vue index 07220aff2..e4f92be76 100644 --- a/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.vue +++ b/app/frontend/javascript/custom-tagged-plate/components/CustomTaggedPlate.vue @@ -619,8 +619,8 @@ export default { purpose_uuid: this.purposeUuid, parent_uuid: this.parentUuid, tag_layout: { - tag_group: this.tag1GroupUuid, - tag2_group: this.tag2GroupUuid, + tag_group_uuid: this.tag1GroupUuid, + tag2_group_uuid: this.tag2GroupUuid, direction: this.direction, walking_by: this.walkingBy, initial_tag: initialTag, diff --git a/app/models/labware_creators/custom_tagged_plate.rb b/app/models/labware_creators/custom_tagged_plate.rb index 8892620e5..31a85dd98 100644 --- a/app/models/labware_creators/custom_tagged_plate.rb +++ b/app/models/labware_creators/custom_tagged_plate.rb @@ -18,10 +18,10 @@ class CustomTaggedPlate < Base { tag_plate: %i[asset_uuid template_uuid state], tag_layout: [ - :user, - :plate, - :tag_group, - :tag2_group, + :user_uuid, + :plate_uuid, + :tag_group_uuid, + :tag2_group_uuid, :direction, :walking_by, :initial_tag, @@ -107,7 +107,9 @@ def tag_layout_attributes def create_labware! create_plate! do |plate_uuid| - api.tag_layout.create!(tag_layout_attributes.merge(plate: plate_uuid, user: user_uuid)) + Sequencescape::Api::V2::TagLayout.create!( + tag_layout_attributes.merge(plate_uuid: plate_uuid, user_uuid: user_uuid) + ) end end end diff --git a/app/sequencescape/sequencescape/api/v2/tag_layout.rb b/app/sequencescape/sequencescape/api/v2/tag_layout.rb new file mode 100644 index 000000000..2e5f92fda --- /dev/null +++ b/app/sequencescape/sequencescape/api/v2/tag_layout.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +# tag layout resource +class Sequencescape::Api::V2::TagLayout < Sequencescape::Api::V2::Base +end diff --git a/spec/models/labware_creators/custom_tagged_plate_spec.rb b/spec/models/labware_creators/custom_tagged_plate_spec.rb index 4c605f864..522fd4bd3 100644 --- a/spec/models/labware_creators/custom_tagged_plate_spec.rb +++ b/spec/models/labware_creators/custom_tagged_plate_spec.rb @@ -114,30 +114,48 @@ let(:expected_transfers) { WellHelpers.stamp_hash(96) } - def expect_transfer_creation + def expect_state_change_creation expect_api_v2_posts( - 'Transfer', + 'StateChange', + [ + { + reason: 'Used in Library creation', + target_uuid: tag_plate_uuid, + target_state: 'exhausted', + user_uuid: user_uuid + } + ] + ) + end + + def expect_tag_layout_creation + expect_api_v2_posts( + 'TagLayout', [ { user_uuid: user_uuid, - source_uuid: plate_uuid, - destination_uuid: child_plate_uuid, - transfer_template_uuid: transfer_template_uuid, - transfers: expected_transfers + plate_uuid: child_plate_uuid, + tag_group_uuid: 'tag-group-uuid', + tag2_group_uuid: 'tag2-group-uuid', + direction: 'column', + walking_by: 'manual by plate', + initial_tag: '1', + tags_per_well: 1 } ] ) end - def expect_state_change_creation + def expect_transfer_creation expect_api_v2_posts( - 'StateChange', + 'Transfer', [ { - reason: 'Used in Library creation', - target_uuid: tag_plate_uuid, - target_state: 'exhausted', - user_uuid: user_uuid + user_uuid: user_uuid, + source_uuid: plate_uuid, + destination_uuid: child_plate_uuid, + transfer_template_uuid: transfer_template_uuid, + transfers: expected_transfers } ] ) @@ -157,9 +175,9 @@ def expect_state_change_creation state: tag_plate_state }, tag_layout: { - user: 'user-uuid', - tag_group: 'tag-group-uuid', - tag2_group: 'tag2-group-uuid', + user_uuid: 'user-uuid', + tag_group_uuid: 'tag-group-uuid', + tag2_group_uuid: 'tag2-group-uuid', direction: 'column', walking_by: 'manual by plate', initial_tag: '1', @@ -176,37 +194,20 @@ def expect_state_change_creation it_behaves_like 'it has a custom page', 'custom_tagged_plate' context 'on save' do - let!(:custom_tag_layout_creation_request) do - stub_api_post( - 'tag_layouts', - payload: { - tag_layout: { - user: 'user-uuid', - plate: child_plate_uuid, - tag_group: 'tag-group-uuid', - tag2_group: 'tag2-group-uuid', - direction: 'column', - walking_by: 'manual by plate', - initial_tag: '1', - tags_per_well: 1 - } - } - ) - end - context 'with an available tag plate' do let(:tag_plate_state) { 'available' } it 'creates a tag plate' do - expect_transfer_creation expect_state_change_creation + expect_tag_layout_creation + expect_transfer_creation expect(subject.save).to be true expect(plate_creation_request).to have_been_made.once - expect(custom_tag_layout_creation_request).to have_been_made.once end it 'has the correct child (and uuid)' do + stub_api_v2_post('TagLayout') stub_api_v2_post('Transfer') stub_api_v2_post('StateChange') @@ -218,12 +219,12 @@ def expect_state_change_creation context 'when a user has exhausted the plate in another tab' do it 'creates a tag plate' do - expect_transfer_creation expect_state_change_creation + expect_tag_layout_creation + expect_transfer_creation expect(subject.save).to be true expect(plate_creation_request).to have_been_made.once - expect(custom_tag_layout_creation_request).to have_been_made.once end end end @@ -232,17 +233,18 @@ def expect_state_change_creation let(:tag_plate_state) { 'exhausted' } it 'creates a tagged plate' do + # This one will be VERY different + expect_tag_layout_creation + expect_transfer_creation expect(Sequencescape::Api::V2::StateChange).not_to receive(:create!) expect(subject.save).to be true expect(plate_creation_request).to have_been_made.once - - # This one will be VERY different - expect(custom_tag_layout_creation_request).to have_been_made.once end it 'has the correct child (and uuid)' do + stub_api_v2_post('TagLayout') stub_api_v2_post('Transfer') expect(subject.save).to be true @@ -258,15 +260,16 @@ def expect_state_change_creation let(:parents) { [plate_uuid] } it 'creates a tag plate' do + expect_tag_layout_creation expect_transfer_creation expect(Sequencescape::Api::V2::StateChange).not_to receive(:create!) expect(subject.save).to be true expect(plate_creation_request).to have_been_made.once - expect(custom_tag_layout_creation_request).to have_been_made.once end it 'has the correct child (and uuid)' do + stub_api_v2_post('TagLayout') stub_api_v2_post('Transfer') expect(subject.save).to be true