Skip to content

Commit

Permalink
Loosen dependency on rails, to support Rails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Aug 8, 2016
1 parent 94eb9d2 commit 5944ba5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ else
end
end
# END ENGINE_CART BLOCK

if !ENV['RAILS_VERSION'] || ENV['RAILS_VERSION'] =~ /^5.0/
gem 'rails-controller-testing'
end
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require 'rake/testtask'
require 'bundler'
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
Bundler::GemHelper.install_tasks

APP_ROOT= File.dirname(__FILE__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ def file_name
# render an HTTP HEAD response
def content_head
response.headers['Content-Length'] = file.size
response.headers['Content-Type'] = file.mime_type
head :ok
head :ok, content_type: file.mime_type
end

# render an HTTP Range response
Expand Down
2 changes: 1 addition & 1 deletion hydra-core/hydra-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = '>= 1.9.3'

gem.add_dependency "rails", '~> 4.0'
gem.add_dependency "railties", '>= 4.0.0', '< 6'
gem.add_dependency 'hydra-access-controls', version

gem.add_development_dependency 'sqlite3', '~> 1.3'
Expand Down
27 changes: 16 additions & 11 deletions hydra-core/spec/controllers/downloads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ContentHolder < ActiveFedora::Base
allow(ContentHolder).to receive(:default_file_path).and_return('buzz')
get :show, id: obj
expect(response).to be_successful
expect(response.headers['Content-Type']).to eq "image/png"
expect(response.headers['Content-Type']).to start_with "image/png"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"buzz.png\""
expect(response.body).to eq 'fizz'
end
Expand All @@ -83,7 +83,7 @@ class ContentHolder < ActiveFedora::Base
expect(DownloadsController.default_file_path).to eq "content"
get :show, id: obj
expect(response).to be_successful
expect(response.headers['Content-Type']).to eq "image/png"
expect(response.headers['Content-Type']).to start_with "image/png"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"world.png\""
expect(response.body).to eq 'foobarfoobarfoobar'
end
Expand All @@ -99,7 +99,7 @@ class ContentHolder < ActiveFedora::Base
it "should return it" do
get :show, id: obj, file: "descMetadata"
expect(response).to be_successful
expect(response.headers['Content-Type']).to eq "text/plain"
expect(response.headers['Content-Type']).to start_with "text/plain"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"metadata.xml\""
expect(response.body).to eq "It's a stream"
end
Expand All @@ -108,14 +108,14 @@ class ContentHolder < ActiveFedora::Base
it "should support setting disposition to inline" do
get :show, id: obj, :disposition => "inline"
expect(response).to be_successful
expect(response.headers['Content-Type']).to eq "image/png"
expect(response.headers['Content-Type']).to start_with "image/png"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"world.png\""
expect(response.body).to eq 'foobarfoobarfoobar'
end
it "should allow you to specify filename for download" do
get :show, id: obj, "filename" => "my%20dog.png"
expect(response).to be_successful
expect(response.headers['Content-Type']).to eq "image/png"
expect(response.headers['Content-Type']).to start_with "image/png"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"my%20dog.png\""
expect(response.body).to eq 'foobarfoobarfoobar'
end
Expand All @@ -128,37 +128,42 @@ class ContentHolder < ActiveFedora::Base
parent.save!
expect(controller).to receive(:authorize!).with(:download, instance_of(ActiveFedora::File)).and_return(true)
end

it "head request" do
request.env["HTTP_RANGE"] = 'bytes=0-15'
head :show, id: parent, file: 'webm'
expect(response.headers['Content-Length']).to eq 16
expect(response.headers['Accept-Ranges']).to eq 'bytes'
expect(response.headers['Content-Type']).to eq 'video/webm'
expect(response.headers['Content-Type']).to start_with 'video/webm'
end
it "should send the whole thing" do

it "sends the whole thing" do
request.env["HTTP_RANGE"] = 'bytes=0-15'
get :show, id: '1234', file: 'webm'
expect(response.body).to eq 'one1two2threfour'
expect(response.headers["Content-Range"]).to eq 'bytes 0-15/16'
expect(response.headers["Content-Length"]).to eq '16'
expect(response.headers['Accept-Ranges']).to eq 'bytes'
expect(response.headers['Content-Type']).to eq "video/webm"
expect(response.headers['Content-Type']).to start_with "video/webm"
expect(response.headers["Content-Disposition"]).to eq "inline; filename=\"MyVideo.webm\""
expect(response.status).to eq 206
end
it "should send the whole thing when the range is open ended" do

it "sends the whole thing when the range is open ended" do
request.env["HTTP_RANGE"] = 'bytes=0-'
get :show, id: '1234', file: 'webm'
expect(response.body).to eq 'one1two2threfour'
end
it "should get a range not starting at the beginning" do

it "gets a range not starting at the beginning" do
request.env["HTTP_RANGE"] = 'bytes=3-15'
get :show, id: '1234', file: 'webm'
expect(response.body).to eq '1two2threfour'
expect(response.headers["Content-Range"]).to eq 'bytes 3-15/16'
expect(response.headers["Content-Length"]).to eq '13'
end
it "should get a range not ending at the end" do

it "gets a range not ending at the end" do
request.env["HTTP_RANGE"] = 'bytes=4-11'
get :show, id: '1234', file: 'webm'
expect(response.body).to eq 'two2thre'
Expand Down
6 changes: 0 additions & 6 deletions hydra-core/spec/test_app_templates/Gemfile.extra

This file was deleted.

8 changes: 4 additions & 4 deletions hydra-head.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 1.9.3'

s.add_dependency('rails', '>= 3.2.6')
s.add_dependency('hydra-access-controls', version)
s.add_dependency('hydra-core', version)
s.add_dependency 'rails', '>= 3.2.6'
s.add_dependency 'hydra-access-controls', version
s.add_dependency 'hydra-core', version

s.add_development_dependency 'solr_wrapper', '~> 0.5'
s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
s.add_development_dependency 'engine_cart', '~> 0.10'
s.add_development_dependency "yard"
s.add_development_dependency 'yard'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'factory_girl_rails'
end
1 change: 1 addition & 0 deletions spec/test_app_templates/Gemfile.extra
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gem 'byebug' unless ENV['CI']

0 comments on commit 5944ba5

Please sign in to comment.