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

Y24-456 - Tube rack banking driver file #4675

Open
wants to merge 3 commits into
base: y24-088-tuberacks-epic
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions app/models/tube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def self.delegate_to_purpose(*methods)

# TODO: change column name to account for purpose, not plate_purpose!
belongs_to :purpose, class_name: 'Tube::Purpose', foreign_key: :plate_purpose_id
has_one :racked_tube, dependent: :destroy
has_one :tube_rack, through: :racked_tube
has_many :racked_tubes, dependent: :destroy
has_many :tube_racks, through: :racked_tube

scope :in_column_major_order, lambda { joins(:racked_tube).order('racked_tubes.coordinate ASC') }
delegate :coordinate, to: :racked_tube
Expand Down
4 changes: 4 additions & 0 deletions app/resources/api/v2/tube_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def sibling_tubes
# @!attribute [r] transfer_requests_as_target
# @return [Array<Api::V2::TransferRequestResource>] An array of transfer requests into this tube.
has_many :transfer_requests_as_target, readonly: true

# @!attribute [r] racked_tube
# @return [Api::V2::RackedTubeResource] An array of racked tubes associated with this tube.
has_many :racked_tubes, readonly: true, foreign_key_on: :related
end
end
end
8 changes: 4 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1452,15 +1452,15 @@
create_table "specific_tube_rack_creation_children", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "specific_tube_rack_creation_id", null: false
t.integer "tube_rack_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "specific_tube_rack_creation_purposes", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.integer "specific_tube_rack_creation_id", null: false
t.integer "tube_rack_purpose_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "stamp_qcables", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t|
Expand Down
4 changes: 4 additions & 0 deletions spec/requests/api/v2/tubes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
expect(json.dig('data', 'relationships', 'transfer_requests_as_target')).to be_present
end

it 'returns a reference to the racked_tube relationship' do
expect(json.dig('data', 'relationships', 'racked_tubes')).to be_present
end

it 'does not include attributes for related resources' do
expect(json['included']).not_to be_present
end
Expand Down
1 change: 1 addition & 0 deletions spec/resources/api/v2/tube_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
it { is_expected.to have_a_readonly_has_many(:aliquots).with_class_name('Aliquot') }
it { is_expected.to have_a_readonly_has_one(:receptacle).with_class_name('Receptacle') }
it { is_expected.to have_a_readonly_has_many(:transfer_requests_as_target).with_class_name('TransferRequest') }
it { is_expected.to have_a_readonly_has_many(:racked_tubes).with_class_name('RackedTube') }

# Behaviours
it_behaves_like 'a labware resource'
Expand Down
Loading