mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 02:14:29 +08:00
Fix failing tests with local file storage [SCI-2944]
This commit is contained in:
parent
19f1585352
commit
79c7bbbfb0
1 changed files with 28 additions and 35 deletions
|
@ -15,6 +15,7 @@ describe TemplatesService do
|
||||||
seed_demo_data(main_team.created_by, main_team)
|
seed_demo_data(main_team.created_by, main_team)
|
||||||
dj_worker = Delayed::Worker.new
|
dj_worker = Delayed::Worker.new
|
||||||
Delayed::Job.all.each { |job| dj_worker.run(job) }
|
Delayed::Job.all.each { |job| dj_worker.run(job) }
|
||||||
|
Delayed::Job.all.each { |job| dj_worker.run(job) }
|
||||||
demo_exp = main_team.projects.first.experiments.first
|
demo_exp = main_team.projects.first.experiments.first
|
||||||
exp_exporter = ModelExporters::ExperimentExporter.new(demo_exp.id)
|
exp_exporter = ModelExporters::ExperimentExporter.new(demo_exp.id)
|
||||||
exp_dir = exp_exporter.export_template_to_dir
|
exp_dir = exp_exporter.export_template_to_dir
|
||||||
|
@ -28,69 +29,61 @@ describe TemplatesService do
|
||||||
)
|
)
|
||||||
ts = TemplatesService.new(tmplts_dir)
|
ts = TemplatesService.new(tmplts_dir)
|
||||||
ts.update_project(templates_project)
|
ts.update_project(templates_project)
|
||||||
|
Delayed::Job.all.each { |job| dj_worker.run(job) }
|
||||||
tmpl_exp = templates_project.experiments.first
|
tmpl_exp = templates_project.experiments.first
|
||||||
|
|
||||||
expect(tmpl_exp.name).to eq demo_exp.name
|
expect(tmpl_exp.name).to eq(demo_exp.name)
|
||||||
expect(tmpl_exp.uuid).to_not eq(nil)
|
expect(tmpl_exp.uuid).to_not eq(nil)
|
||||||
expect(tmpl_exp.my_modules.pluck(:name))
|
expect(tmpl_exp.my_modules.pluck(:name))
|
||||||
.to eq(demo_exp.my_modules.pluck(:name))
|
.to match_array(demo_exp.my_modules.pluck(:name))
|
||||||
tmpl_tasks = tmpl_exp.active_my_modules
|
tmpl_tasks = tmpl_exp.my_modules.order(:id)
|
||||||
demo_tasks = demo_exp.active_my_modules
|
demo_tasks = demo_exp.my_modules.order(:id)
|
||||||
i = 0
|
demo_tasks.each do |demo_task|
|
||||||
tmpl_tasks.each do
|
tmpl_task = tmpl_tasks.find_by_name(demo_task.name)
|
||||||
tmpl_task = tmpl_tasks[i]
|
expect(tmpl_task.name).to eq(demo_task.name)
|
||||||
demo_task = demo_tasks[i]
|
|
||||||
expect(tmpl_task.name).to eq demo_task.name
|
|
||||||
expect(tmpl_task.task_comments.size)
|
expect(tmpl_task.task_comments.size)
|
||||||
.to eq demo_task.task_comments.size
|
.to eq(demo_task.task_comments.size)
|
||||||
j = 0
|
demo_task.results.each do |demo_res|
|
||||||
tmpl_task.results.each do
|
tmpl_res = tmpl_task.results.find_by_name(demo_res.name)
|
||||||
tmpl_res = tmpl_task.results[j]
|
expect(tmpl_res.name).to eq(demo_res.name)
|
||||||
demo_res = demo_task.results[j]
|
|
||||||
expect(tmpl_res.name).to eq demo_res.name
|
|
||||||
if demo_res.asset
|
if demo_res.asset
|
||||||
expect(tmpl_res.asset.file.exists?).to eq true
|
expect(tmpl_res.asset.file.exists?).to eq(true)
|
||||||
expect(demo_res.asset.file_file_name)
|
expect(demo_res.asset.file_file_name)
|
||||||
.to eq tmpl_res.asset.file_file_name
|
.to eq(tmpl_res.asset.file_file_name)
|
||||||
elsif demo_res.table
|
elsif demo_res.table
|
||||||
expect(demo_res.table.contents).to eq tmpl_res.table.contents
|
expect(demo_res.table.contents).to eq(tmpl_res.table.contents)
|
||||||
elsif demo_res.result_text
|
elsif demo_res.result_text
|
||||||
expect(demo_res.result_text.text).to eq tmpl_res.result_text.text
|
expect(demo_res.result_text.text).to eq(tmpl_res.result_text.text)
|
||||||
end
|
end
|
||||||
expect(demo_res.result_comments.size)
|
expect(demo_res.result_comments.size)
|
||||||
.to eq tmpl_res.result_comments.size
|
.to eq(tmpl_res.result_comments.size)
|
||||||
j += 1
|
|
||||||
end
|
end
|
||||||
unless demo_task.protocol.present? &&
|
unless demo_task.protocol.present? &&
|
||||||
demo_task.protocol.steps.size.positive?
|
demo_task.protocol.steps.size.positive?
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
j = 0
|
demo_task.protocol.steps.each do |demo_step|
|
||||||
demo_task.protocol.steps.each do
|
tmpl_step = tmpl_task.protocol.steps.find_by_name(demo_step.name)
|
||||||
demo_step = demo_task.protocol.steps[j]
|
expect(demo_step.name).to eq(tmpl_step.name)
|
||||||
tmpl_step = tmpl_task.protocol.steps[j]
|
expect(demo_step.description).to eq(tmpl_step.description)
|
||||||
if demo_step.assets.present?
|
if demo_step.assets.present?
|
||||||
expect(demo_step.assets.pluck(:file_file_name))
|
expect(demo_step.assets.pluck(:file_file_name))
|
||||||
.to eq tmpl_step.assets.pluck(:file_file_name)
|
.to match_array(tmpl_step.assets.pluck(:file_file_name))
|
||||||
end
|
end
|
||||||
tmpl_step.assets.each do |asset|
|
tmpl_step.assets.order(:id).each do |asset|
|
||||||
expect(asset.file.exists?).to eq true
|
expect(asset.file.exists?).to eq(true)
|
||||||
end
|
end
|
||||||
if demo_step.tables.present?
|
if demo_step.tables.present?
|
||||||
expect(demo_step.tables.pluck(:contents))
|
expect(demo_step.tables.pluck(:contents))
|
||||||
.to eq tmpl_step.tables.pluck(:contents)
|
.to match_array(tmpl_step.tables.pluck(:contents))
|
||||||
end
|
end
|
||||||
if demo_step.checklists.present?
|
if demo_step.checklists.present?
|
||||||
expect(demo_step.checklists.pluck(:name))
|
expect(demo_step.checklists.pluck(:name))
|
||||||
.to eq tmpl_step.checklists.pluck(:name)
|
.to match_array(tmpl_step.checklists.pluck(:name))
|
||||||
end
|
end
|
||||||
expect(demo_step.name).to eq tmpl_step.name
|
|
||||||
expect(demo_step.description).to eq tmpl_step.description
|
|
||||||
expect(demo_step.step_comments.size)
|
expect(demo_step.step_comments.size)
|
||||||
.to eq tmpl_step.step_comments.size
|
.to eq(tmpl_step.step_comments.size)
|
||||||
j += 1
|
|
||||||
end
|
end
|
||||||
i += 1
|
|
||||||
end
|
end
|
||||||
Asset.all.each(&:paperclip_delete)
|
Asset.all.each(&:paperclip_delete)
|
||||||
FileUtils.remove_dir(tmplts_dir)
|
FileUtils.remove_dir(tmplts_dir)
|
||||||
|
|
Loading…
Add table
Reference in a new issue