Skip to content

Commit

Permalink
Rails 4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jun 26, 2013
1 parent 1bf5a98 commit c2dab1c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 34 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
language: ruby
rvm:
- "1.9.3"
- "2.0.0"
- 1.9.3
- 2.0.0

gemfile:
- gemfiles/gemfile.rails3
- gemfiles/gemfile.rails4

notifications:
irc: "irc.freenode.org#projecthydra"
Expand Down
9 changes: 0 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,3 @@ source "http://rubygems.org"

# Specify gem dependencies in hydra-head.gemspec
gemspec


# group :test do
# gem 'cucumber-rails', '>=1.2.0', :require=>false
# gem 'rcov', :platform => :mri_18
# gem 'simplecov', :platform => :mri_19
# gem 'simplecov-rcov', :platform => :mri_19
# end

11 changes: 11 additions & 0 deletions gemfiles/gemfile.rails3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "http://rubygems.org"

gemspec :path=>"../"

gem 'activemodel', '~> 3.2.13'

group :development, :test do
gem 'rcov', :platform => :mri_18
gem 'simplecov', :platform => :mri_19
gem 'simplecov-rcov', :platform => :mri_19
end
12 changes: 12 additions & 0 deletions gemfiles/gemfile.rails4
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source "http://rubygems.org"

gemspec :path=>"../"

gem 'rails', '4.0.0'
gem 'sass-rails', '4.0.0'


group :development, :test do
gem 'simplecov', :platform => :mri_19
gem 'simplecov-rcov', :platform => :mri_19
end
2 changes: 1 addition & 1 deletion hydra-access-controls/hydra-access-controls.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "active-fedora", '~> 6.1'
gem.add_dependency 'cancan'
gem.add_dependency 'deprecation'
gem.add_dependency 'blacklight'
gem.add_dependency 'blacklight', '~> 4.0'

gem.add_development_dependency("rake")
gem.add_development_dependency 'rspec'
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 @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = '>= 1.9.3'


gem.add_dependency "rails", '~>3.2.3'
gem.add_dependency "rails", '>= 3.2.3', '< 5'
gem.add_dependency "blacklight", '~> 4.0'
gem.add_dependency "active-fedora"
gem.add_dependency 'block_helpers'
Expand Down
2 changes: 1 addition & 1 deletion hydra-core/lib/hydra-core.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'hydra'

module HydraHead
require 'hydra-head/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
require 'hydra-head/engine' if defined?(Rails)
require 'hydra-head/routes'
# If you put this in your application's routes.rb, it will add the Hydra Head routes to the app.
# The hydra:head generator puts this in routes.rb for you by default.
Expand Down
4 changes: 2 additions & 2 deletions hydra-core/lib/hydra/controller/download_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def send_content(asset)

if request.head?
content_head
elsif request.headers["Range"]
elsif request.headers['HTTP_RANGE']
send_range
else
send_file_headers! content_options
Expand Down Expand Up @@ -93,7 +93,7 @@ def content_head

# render an HTTP Range response
def send_range
_, range = request.headers["Range"].split('bytes=')
_, range = request.headers['HTTP_RANGE'].split('bytes=')
from, to = range.split('-').map(&:to_i)
to = datastream.dsSize - 1 unless to
length = to - from + 1
Expand Down
8 changes: 4 additions & 4 deletions hydra-core/spec/controllers/downloads_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@
controller.stub(:log_download)
end
it "head request" do
request.env["Range"] = 'bytes=0-15'
request.env["HTTP_RANGE"] = 'bytes=0-15'
head :show, id: 'changeme:test', datastream_id: 'webm'
response.headers['Content-Length'].should == 16
response.headers['Accept-Ranges'].should == 'bytes'
response.headers['Content-Type'].should == 'video/webm'
end
it "should send the whole thing" do
request.env["Range"] = 'bytes=0-15'
request.env["HTTP_RANGE"] = 'bytes=0-15'
get :show, id: 'changeme:test', datastream_id: 'webm'
response.body.should == 'one1two2threfour'
response.headers["Content-Range"].should == 'bytes 0-15/16'
Expand All @@ -113,14 +113,14 @@
response.body.should == 'one1two2threfour'
end
it "should get a range not starting at the beginning" do
request.env["Range"] = 'bytes=3-15'
request.env["HTTP_RANGE"] = 'bytes=3-15'
get :show, id: 'changeme:test', datastream_id: 'webm'
response.body.should == '1two2threfour'
response.headers["Content-Range"].should == 'bytes 3-15/16'
response.headers["Content-Length"].should == '13'
end
it "should get a range not ending at the end" do
request.env["Range"] = 'bytes=4-11'
request.env["HTTP_RANGE"] = 'bytes=4-11'
get :show, id: 'changeme:test', datastream_id: 'webm'
response.body.should == 'two2thre'
response.headers["Content-Range"].should == 'bytes 4-11/16'
Expand Down
12 changes: 0 additions & 12 deletions hydra-core/spec/support/Gemfile

This file was deleted.

6 changes: 4 additions & 2 deletions hydra-core/tasks/rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ task :generate do
unless File.exists?('spec/internal/Rakefile')
puts "Generating rails app"
`rails new spec/internal`
puts "Copying gemfile"
`cp spec/support/Gemfile spec/internal`
puts "Updating gemfile"
`echo " gem 'hydra-access-controls', :path=>'../../../hydra-access-controls'" >> spec/internal/Gemfile`
`echo " gem 'hydra-core', :path=>'../../', :require=>'hydra-core'" >> spec/internal/Gemfile`
`echo " gem 'factory_girl_rails'" >> spec/internal/Gemfile`
puts "Copying generator"
`cp -r spec/support/lib/generators spec/internal/lib`
within_test_app do
Expand Down

0 comments on commit c2dab1c

Please sign in to comment.