mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +08:00
Fix tests for services
This commit is contained in:
parent
84fe10df47
commit
618f0cc334
4 changed files with 8 additions and 5 deletions
|
@ -49,7 +49,7 @@ class ZipExport < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def zip_file_name
|
def zip_file_name
|
||||||
return '' unless file.attached?
|
return '' unless zip_file.attached?
|
||||||
|
|
||||||
zip_file.blob&.filename&.to_s
|
zip_file.blob&.filename&.to_s
|
||||||
end
|
end
|
||||||
|
|
|
@ -84,7 +84,9 @@ class ProjectsOverviewService
|
||||||
).joins(
|
).joins(
|
||||||
"LEFT OUTER JOIN (#{due_modules.to_sql}) due_modules "\
|
"LEFT OUTER JOIN (#{due_modules.to_sql}) due_modules "\
|
||||||
"ON due_modules.experiment_id = experiments.id"
|
"ON due_modules.experiment_id = experiments.id"
|
||||||
).left_outer_joins(:user_projects, :project_comments)
|
).joins(
|
||||||
|
'LEFT OUTER JOIN user_projects ON user_projects.project_id = projects.id'
|
||||||
|
).left_outer_joins(:project_comments)
|
||||||
|
|
||||||
# Only admins see all projects of the team
|
# Only admins see all projects of the team
|
||||||
unless @user.is_admin_of_team?(@team)
|
unless @user.is_admin_of_team?(@team)
|
||||||
|
|
|
@ -71,7 +71,8 @@ describe RepositoryZipExport, type: :background_job do
|
||||||
ZipExport.skip_callback(:create, :after, :self_destruct)
|
ZipExport.skip_callback(:create, :after, :self_destruct)
|
||||||
RepositoryZipExport.generate_zip(params, repository, user)
|
RepositoryZipExport.generate_zip(params, repository, user)
|
||||||
csv_zip_file = ZipExport.first.zip_file
|
csv_zip_file = ZipExport.first.zip_file
|
||||||
parsed_csv_content = Zip::File.open(csv_zip_file.path) do |zip_file|
|
file_path = ActiveStorage::Blob.service.public_send(:path_for, csv_zip_file.key)
|
||||||
|
parsed_csv_content = Zip::File.open(file_path) do |zip_file|
|
||||||
csv_file = zip_file.glob('*.csv').first
|
csv_file = zip_file.glob('*.csv').first
|
||||||
csv_content = csv_file.get_input_stream.read
|
csv_content = csv_file.get_input_stream.read
|
||||||
CSV.parse(csv_content, headers: true)
|
CSV.parse(csv_content, headers: true)
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe TemplatesService do
|
||||||
tmpl_res = tmpl_task.results.find_by_name(demo_res.name)
|
tmpl_res = tmpl_task.results.find_by_name(demo_res.name)
|
||||||
expect(tmpl_res.name).to eq(demo_res.name)
|
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.attached?).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
|
||||||
|
@ -75,7 +75,7 @@ describe TemplatesService do
|
||||||
.to match_array(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.each do |asset|
|
||||||
expect(asset.file.exists?).to eq(true)
|
expect(asset.file.attached?).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))
|
||||||
|
|
Loading…
Reference in a new issue