Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
updates for new upload folder location
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Aug 8, 2017
1 parent c922c71 commit d4bf776
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ coverage/*
## PROJECT::GENERAL
rdoc
public/uploads
uploads
doc
pkg
/.bundle
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)

# Default value for linked_dirs is []
set :linked_dirs, %w{log config/certs config/settings tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :linked_dirs, %w{log config/certs config/settings tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads uploads}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
Expand Down
6 changes: 3 additions & 3 deletions spec/features/item_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
# Visit edit page: delete a file.
# Make corresponding changes in the exp hash.
i = 1
file_url = Hydrus::ObjectFile.find(i).url
object_file = Hydrus::ObjectFile.find(i)
should_visit_edit_page(@hi)
css_del = "delete_file_#{i}"
click_link(css_del)
Expand All @@ -686,8 +686,8 @@
check_file_info.call(exp)

# Restore the deleted file.
restore_upload_file(file_url)
expect(File.exists?('public' + file_url)).to eq(true)
restore_upload_file(object_file)
expect(File.exists?(object_file.current_path)).to eq(true)
end
end
end
8 changes: 4 additions & 4 deletions spec/features/models/object_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
files = Hydrus::ObjectFile.where(pid: pid)
expect(files.size).to eq(4)
f = files[0]
exp_url = '/uploads/oo/000/oo/0001/oo000oo0001/content/pinocchio.htm'
exp_url = '/file/druid:oo000oo0001/pinocchio.htm'
exp_path = File.join(Rails.root,'uploads','oo/000/oo/0001/oo000oo0001/content/pinocchio.htm')
expect(f.url).to eq(exp_url)
expect(f.current_path).to eq("#{Rails.root}/public#{exp_url}")
expect(f.current_path).to eq(exp_path)
expect(files[1].filename).to eq(%q{pinocchio characters tc in file name.pdf})
expect(files[1].size).to be > 0
end
Expand All @@ -23,7 +24,6 @@
files = @hi.files
expect(files.size).to eq(4)
file = files.first

file_url = file.url
full_file_path = file.current_path
expect(File.exists?(full_file_path)).to be_truthy
Expand All @@ -35,7 +35,7 @@
expect(File.exists?(full_file_path)).to be_falsey

# restore original file and stream from fixtures
restore_upload_file(file_url)
restore_upload_file(file)
expect(File.exists?(full_file_path)).to be_truthy
end
end
12 changes: 5 additions & 7 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,11 @@ def create_new_item(opts = {})
Hydrus::Item.find(druid)
end

# Takes the file_url of an Item's uploaded file.
# Takes an objet_file object.
# Helper method to restore a file to the uploads directory
# after it was deleted in a integration test.
def restore_upload_file(file_url)
parts = file_url.split /\//
parts[0] = 'public'
dst = File.join(*parts)
src = File.join('spec/fixtures/files', parts[-3], parts[-1])
FileUtils.cp(src, dst)
def restore_upload_file(object_file)
src = File.join('spec/fixtures/files', DruidTools::Druid.new(object_file.pid).id, object_file.filename)
dst = object_file.current_path
FileUtils.cp(src, dst)
end

0 comments on commit d4bf776

Please sign in to comment.