Plate Printer
-
{this.renderOptions(this.props.platePrinter.optionsData)}
diff --git a/app/models/activities/tasks.rb b/app/models/activities/tasks.rb
index 795f8fcb..835f9605 100644
--- a/app/models/activities/tasks.rb
+++ b/app/models/activities/tasks.rb
@@ -4,6 +4,7 @@ module Tasks
def create_step(params)
step = params[:step_type].class_for_task_type.create!({
activity: self,
+ printer_config: params[:printer_config],
step_type: params[:step_type],
asset_group: params[:asset_group],
user: params[:user]})
diff --git a/app/models/steps/task.rb b/app/models/steps/task.rb
index 147b2a72..faf5819f 100644
--- a/app/models/steps/task.rb
+++ b/app/models/steps/task.rb
@@ -24,7 +24,7 @@ def process
assets_for_printing = assets_for_printing.to_a.concat(updates.assets_for_printing)
end
if assets_for_printing.length > 0
- AssetGroup.new(assets: assets_for_printing).print(user.printer_config, user.username)
+ AssetGroup.new(assets: assets_for_printing).print(printer_config, user.username)
end
end
diff --git a/spec/controllers/steps_controller_spec.rb b/spec/controllers/steps_controller_spec.rb
index 91e72e1d..5c180174 100644
--- a/spec/controllers/steps_controller_spec.rb
+++ b/spec/controllers/steps_controller_spec.rb
@@ -20,6 +20,24 @@
}
}.to change{Step.all.count}
end
+
+ context 'when receiving a specific printer config' do
+ let(:tube_printer) { create :printer, name: 'tubes'}
+ let(:plate_printer) { create :printer, name: 'plates'}
+ it 'stores the printer_config provided as parameter' do
+ post :create, params: {
+ activity_id: activity.id, step: {
+ asset_group_id: asset_group.id, step_type_id: step_type.id,
+ tube_printer_id: tube_printer.id, plate_printer_id: plate_printer.id
+ }
+ }
+ expect(Step.last.printer_config).to eq({
+ "Tube" => tube_printer.name,
+ "Plate" => plate_printer.name,
+ "TubeRack" => plate_printer.name
+ })
+ end
+ end
end
context '#update' do
let(:step) {
diff --git a/spec/models/step_spec.rb b/spec/models/step_spec.rb
index 14a8ee9e..f2fae640 100644
--- a/spec/models/step_spec.rb
+++ b/spec/models/step_spec.rb
@@ -73,6 +73,17 @@ def create_assets(num, type)
num.times.map { create_asset(type) }
end
+ describe '#create' do
+ context 'when creating a step with a specific printer config' do
+ let(:printer_data_config) { {"Tube"=>"1234", "Plate"=>"6789"} }
+ it 'stores the printer config in the database' do
+ s = create(:step, printer_config: printer_data_config)
+ s2 = Step.find_by(id: s.id)
+ expect(s2.printer_config).to eq(printer_data_config)
+ end
+ end
+ end
+
describe '#run' do
setup do
@step_type = FactoryBot.create :step_type
diff --git a/spec/models/steps/task_spec.rb b/spec/models/steps/task_spec.rb
index 186df75d..f0747a1e 100644
--- a/spec/models/steps/task_spec.rb
+++ b/spec/models/steps/task_spec.rb
@@ -3,13 +3,20 @@
describe Steps::Task do
let(:user) { create :user, username: 'test'}
+ let(:printer_config) {
+ {
+ "Plate" => "plates",
+ "Tube" => "tubes",
+ "TubeRack" => "plates"
+ }
+ }
def build_instance
asset_group = build :asset_group
- build :step, asset_group: asset_group
+ build :step, asset_group: asset_group, printer_config: printer_config
end
def create_instance(step_type, activity, group)
- create(:step, step_type: step_type, activity: activity, asset_group: group, user: user)
+ create(:step, step_type: step_type, activity: activity, asset_group: group, user: user, printer_config: printer_config)
end
#it_behaves_like 'background task'
diff --git a/test/javascript/components/activity.test.js b/test/javascript/components/activity.test.js
index e06af7a0..633d4ad4 100644
--- a/test/javascript/components/activity.test.js
+++ b/test/javascript/components/activity.test.js
@@ -9,27 +9,30 @@ import Activity from 'activity';
describe('Activity', () => {
it('renders Activity component', () => {
- const wrapper = shallow(
);
- expect(wrapper.find('div')).toHaveLength(1);
+ const wrapper = shallow(
)
+ expect(wrapper.find('div')).toHaveLength(1)
})
it('renders only one AssetGroupEditor component', () => {
- const wrapper = mount(
);
- expect(wrapper.find('AssetGroupEditor')).toHaveLength(1);
+ const wrapper = mount(
)
+ expect(wrapper.find('AssetGroupEditor')).toHaveLength(1)
})
- // describe('State Test failure 1', () => {
- // const stateFailure1 = require('../../data/react/state_failure.json')
+ describe('when changing the printers', () => {
+ const wrapper = mount(
)
- // it('shallows passes test failure 1', () => {
- // const wrapper = shallow(
)
- // expect(wrapper.find('div')).toHaveLength(1)
- // })
+ it('changes the selected tube printer in the react state', () => {
+ expect(wrapper.instance().state.selectedTubePrinter).toEqual(8)
+ wrapper.find({name: "tube_printer_select"}).first().simulate('change', {target: { value: 1}})
+ expect(wrapper.instance().state.selectedTubePrinter).toEqual(1)
+ })
- // it('mounts test failure 1', () => {
- // const wrapper = mount(
);
- // expect(wrapper.find('AssetGroupEditor')).toHaveLength(1);
- // })
- // })
+ it('changes the selected plate printer in the react state', () => {
+ expect(wrapper.instance().state.selectedPlatePrinter).toEqual(14)
+ wrapper.find({name: "plate_printer_select"}).first().simulate('change', {target: { value: 2}})
+ expect(wrapper.instance().state.selectedPlatePrinter).toEqual(2)
+ })
+
+ })
})
diff --git a/test/javascript/test_helpers/factories.js b/test/javascript/test_helpers/factories.js
index f96aff41..5816389f 100644
--- a/test/javascript/test_helpers/factories.js
+++ b/test/javascript/test_helpers/factories.js
@@ -13,14 +13,16 @@ const buildEmptyActivityState = () => {
},
"tubePrinter":{
"optionsData":[
- ["printer 1",1]
+ ["printer 1",1],
+ ["printer 2",8]
],
"defaultValue":8
},"platePrinter":{
"optionsData":[
- ["printer 2",2]
+ ["printer 3",2],
+ ["printer 14",14]
],
- "defaultValue":2
+ "defaultValue":14
},
"shownComponents":{},
"activityRunning":false,