2019-02-02 01:06:36 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
describe TemplatesService do
|
|
|
|
let!(:main_team) { create :team }
|
|
|
|
let!(:admin_user) { create :user }
|
|
|
|
|
|
|
|
describe '#update_project' do
|
|
|
|
context 'update templates project' do
|
|
|
|
it 'experiment is added to templates project' do
|
|
|
|
create(:user_team, user: admin_user, team: main_team)
|
|
|
|
dj_worker = Delayed::Worker.new
|
2019-02-13 22:17:33 +08:00
|
|
|
templates_project =
|
|
|
|
create :project, name: 'Templates', template: true, team: main_team
|
2019-02-02 01:06:36 +08:00
|
|
|
create(
|
|
|
|
:user_project, :owner, project: templates_project, user: admin_user
|
|
|
|
)
|
2020-12-22 04:35:09 +08:00
|
|
|
ts = TemplatesService.new
|
2019-02-13 22:17:33 +08:00
|
|
|
ts.update_team(main_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
|