2019-02-02 01:06:36 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
describe TemplatesService do
|
2022-06-07 00:21:57 +08:00
|
|
|
let!(:user) { create :user }
|
|
|
|
let!(:team) { create :team, created_by: user }
|
2019-02-02 01:06:36 +08:00
|
|
|
|
|
|
|
describe '#update_project' do
|
|
|
|
context 'update templates project' do
|
|
|
|
it 'experiment is added to templates project' do
|
|
|
|
dj_worker = Delayed::Worker.new
|
2022-06-07 00:21:57 +08:00
|
|
|
templates_project = create :project, name: 'Templates', template: true, team: team, created_by: user
|
|
|
|
|
2020-12-22 04:35:09 +08:00
|
|
|
ts = TemplatesService.new
|
2022-06-07 00:21:57 +08:00
|
|
|
ts.update_team(team)
|
2019-02-04 20:50:38 +08:00
|
|
|
Delayed::Job.all.each { |job| dj_worker.run(job) }
|
2020-12-22 04:35:09 +08:00
|
|
|
tmpl_exp = templates_project.experiments.find_by(name: 'Polymerase chain reaction')
|
2019-02-02 01:06:36 +08:00
|
|
|
|
|
|
|
expect(tmpl_exp.uuid).to_not eq(nil)
|
|
|
|
expect(tmpl_exp.my_modules.pluck(:name))
|
2020-12-22 04:35:09 +08:00
|
|
|
.to match_array(['Data analysis - ddCq', 'Data quality control', 'Experiment design', 'qPCR',
|
|
|
|
'Reverse transcription', 'RNA isolation', 'RNA quality & quantity - BIOANALYSER',
|
|
|
|
'Sampling biological material'])
|
2019-02-07 18:23:40 +08:00
|
|
|
tmpl_tasks = tmpl_exp.my_modules
|
2020-12-22 04:35:09 +08:00
|
|
|
tmpl_tasks.each do |tmpl_task|
|
|
|
|
tmpl_task.protocol.steps.each do |tmpl_step|
|
2019-02-07 18:23:40 +08:00
|
|
|
tmpl_step.assets.each do |asset|
|
2019-07-26 20:16:44 +08:00
|
|
|
expect(asset.file.attached?).to eq(true)
|
2019-02-02 01:06:36 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|