Skip to content

Commit

Permalink
Merge pull request #33 from sanger/devel
Browse files Browse the repository at this point in the history
LAB-18 - remove recording of duplicate Labwhere
  • Loading branch information
stevieing authored Mar 9, 2017
2 parents 288a4fd + 2bbe1d4 commit c5bffcf
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/models/labware_collection/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def original_location_names
end

def labwares=(labwares)
@labwares = labwares.split("\n")
@labwares = labwares.split("\n").uniq
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_location.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<article id="<%= dom_id(location) %>" class="drilldown" data-behavior="list" data-info="true" data-type="location" data-id="<%= location.id %>">
<article id="<%= dom_id(location.morph) %>" class="drilldown" data-behavior="list" data-info="true" data-type="location" data-id="<%= location.id %>">
<div>
<%= drilldown_link %>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/views/ordered_locations/_ordered_location.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render partial: "application/location", object: ordered_location %>
2 changes: 1 addition & 1 deletion app/views/searches/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div data-behavior="<%= heading %>-list">
<h4><%= heading.to_s.titleize %></h4>
<% records.each do |record| %>
<%= render record.morph %>
<%= render record %>
<% end %>
</div>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions app/views/unordered_locations/_unordered_location.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render partial: "application/location", object: unordered_location %>
3 changes: 2 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
# config.action_view.raise_on_missing_translations = true

# Print My Barcode api base
config.x.pmb_api_base = 'http://pmb.dev/api/v1'
# config.x.pmb_api_base = 'http://pmb.dev/api/v1'
config.x.pmb_api_base = 'http://dev.psd.sanger.ac.uk:7462/v1'
end
18 changes: 1 addition & 17 deletions lib/label_printing/label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ def initialize(locations)

def to_h
{
header: header,
body: body,
footer: footer
}
end

def header
{
'header_text_1' => 'header by LabWhere',
'header_text_2' => 'header'
body: body
}
end

Expand All @@ -33,11 +24,4 @@ def body
end
end

def footer
{
'footer_text_1' => 'footer by LabWhere',
'footer_text_2' => 'footer'
}
end

end
17 changes: 0 additions & 17 deletions spec/models/label_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
require 'rails_helper'

RSpec.shared_examples 'a label' do
describe '#header' do
it 'has a header label' do
expect(subject.header).to have_key 'header_text_1'
expect(subject.header).to have_key 'header_text_2'
expect(subject.header['header_text_1']).to eql 'header by LabWhere'
expect(subject.header['header_text_2']).to eql 'header'
end
end

describe '#footer' do
it 'has a footer label' do
expect(subject.footer).to have_key 'footer_text_1'
expect(subject.footer).to have_key 'footer_text_2'
expect(subject.footer['footer_text_1']).to eql 'footer by LabWhere'
expect(subject.footer['footer_text_2']).to eql 'footer'
end
end

describe '#body' do
it 'creates the body from the location(s)' do
Expand Down
24 changes: 20 additions & 4 deletions spec/models/labware_collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,34 @@
let!(:location) { create(:location_with_parent) }
let(:labware_collection) { LabwareCollection.open(location: location, user: user, labwares: labwares.join_barcodes)}

it "should create the correct number of labwares" do
it "creates the correct number of labwares" do
expect(labware_collection.count).to eq(labwares.count)
end

it "should add each of the labwares to the location" do
it "adds each of the labwares to the location" do
labware_collection.push
expect(location.labwares.count).to eq(labware_collection.count)
end

it "should provide a list of the original locations for the labware" do
it "provides a list of the original locations for the labware" do
labware_collection.push
expect(labware_collection.original_location_names).to eq(previous_location_1.name + ", " + previous_location_2.name)
end

it "should create an audit record for each labware" do
it "creates an audit record for each labware" do
labware_collection.push
location.labwares.each do |labware|
expect(labware.audits.count).to eq(1)
end
end

it 'removes duplicates from labwares which have been passed' do
labware_collection = LabwareCollection.open(location: location, user: user, labwares: new_labwares.join_barcodes << "\n" << new_labwares.join_barcodes)
expect(labware_collection.count).to eq(new_labwares.count)
labware_collection.push
expect(location.labwares.count).to eq(new_labwares.count)
end

end

describe 'adding to an ordered location with a starting position' do
Expand Down Expand Up @@ -75,6 +82,15 @@
expect(location.labwares).to be_empty
end

it 'removes duplicates from labwares which have been passed' do
labware_collection = LabwareCollection.open(location: location, user: user, labwares: new_labwares.join_barcodes << "\n" << new_labwares.join_barcodes, start_position: 5)
expect(labware_collection.count).to eq(new_labwares.count)
labware_collection.push
((labware_collection.start_position)..(labware_collection.start_position + labware_collection.count - 1)).each do |i|
expect(location.coordinates.find_by_position(position: i)).to be_filled
end
end

end

end
5 changes: 5 additions & 0 deletions spec/models/locations/ordered_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,10 @@


end

it '#child_count returns correct number of children' do
location = create(:ordered_location_with_labwares)
expect(location.child_count).to eq(location.labwares.count)
end

end

0 comments on commit c5bffcf

Please sign in to comment.