diff --git a/.gitignore b/.gitignore index 691ec7a3c..17f8eb99b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ coverage/* ## PROJECT::GENERAL rdoc public/uploads +uploads doc pkg /.bundle diff --git a/config/deploy.rb b/config/deploy.rb index 3435995f0..7f83af8e1 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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" } diff --git a/spec/features/item_edit_spec.rb b/spec/features/item_edit_spec.rb index 585fab7b0..da38b62c7 100644 --- a/spec/features/item_edit_spec.rb +++ b/spec/features/item_edit_spec.rb @@ -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) @@ -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 diff --git a/spec/features/models/object_file_spec.rb b/spec/features/models/object_file_spec.rb index 30143ae0d..4162f093c 100644 --- a/spec/features/models/object_file_spec.rb +++ b/spec/features/models/object_file_spec.rb @@ -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 @@ -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 @@ -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 diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index c57a60c78..0541b5317 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -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