Fix tests for services

This commit is contained in:
Anton Ignatov 2019-07-26 14:16:44 +02:00
parent 84fe10df47
commit 618f0cc334
4 changed files with 8 additions and 5 deletions

View file

@ -49,7 +49,7 @@ class ZipExport < ApplicationRecord
end
def zip_file_name
return '' unless file.attached?
return '' unless zip_file.attached?
zip_file.blob&.filename&.to_s
end

View file

@ -84,7 +84,9 @@ class ProjectsOverviewService
).joins(
"LEFT OUTER JOIN (#{due_modules.to_sql}) due_modules "\
"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
unless @user.is_admin_of_team?(@team)

View file

@ -71,7 +71,8 @@ describe RepositoryZipExport, type: :background_job do
ZipExport.skip_callback(:create, :after, :self_destruct)
RepositoryZipExport.generate_zip(params, repository, user)
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_content = csv_file.get_input_stream.read
CSV.parse(csv_content, headers: true)

View file

@ -50,7 +50,7 @@ describe TemplatesService do
tmpl_res = tmpl_task.results.find_by_name(demo_res.name)
expect(tmpl_res.name).to eq(demo_res.name)
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)
.to eq(tmpl_res.asset.file_file_name)
elsif demo_res.table
@ -75,7 +75,7 @@ describe TemplatesService do
.to match_array(tmpl_step.assets.pluck(:file_file_name))
end
tmpl_step.assets.each do |asset|
expect(asset.file.exists?).to eq(true)
expect(asset.file.attached?).to eq(true)
end
if demo_step.tables.present?
expect(demo_step.tables.pluck(:contents))