Commit 8a758c27 by Prem Sichanugrist

Make the test pass on JRuby

parent 84d2d087
...@@ -3,3 +3,5 @@ source "http://rubygems.org" ...@@ -3,3 +3,5 @@ source "http://rubygems.org"
gemspec gemspec
gem "jruby-openssl", :platform => :jruby gem "jruby-openssl", :platform => :jruby
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
gem "sqlite3", :platform => :ruby
...@@ -19,6 +19,10 @@ GEM ...@@ -19,6 +19,10 @@ GEM
activesupport (= 3.2.2) activesupport (= 3.2.2)
arel (~> 3.0.2) arel (~> 3.0.2)
tzinfo (~> 0.3.29) tzinfo (~> 0.3.29)
activerecord-jdbc-adapter (1.2.2)
activerecord-jdbcsqlite3-adapter (1.2.2)
activerecord-jdbc-adapter (~> 1.2.2)
jdbc-sqlite3 (~> 3.7.2)
activesupport (3.2.2) activesupport (3.2.2)
i18n (~> 0.6) i18n (~> 0.6)
multi_json (~> 1.0) multi_json (~> 1.0)
...@@ -26,104 +30,116 @@ GEM ...@@ -26,104 +30,116 @@ GEM
bundler bundler
rake rake
arel (3.0.2) arel (3.0.2)
aruba (0.4.6) aruba (0.4.11)
bcat (>= 0.6.1) childprocess (>= 0.2.3)
childprocess (>= 0.2.0) cucumber (>= 1.1.1)
cucumber (>= 1.0.2) ffi (>= 1.0.11)
rdiscount (>= 1.6.8) rspec (>= 2.7.0)
rspec (>= 2.6.0) aws-sdk (1.3.8)
aws-sdk (1.3.4)
httparty (~> 0.7) httparty (~> 0.7)
json (~> 1.4) json (~> 1.4)
nokogiri (>= 1.4.4) nokogiri (<= 1.5.0)
uuidtools (~> 2.1) uuidtools (~> 2.1)
bcat (0.6.2) bouncy-castle-java (1.5.0146.1)
rack (~> 1.0)
builder (3.0.0) builder (3.0.0)
capybara (1.1.1) capybara (1.1.2)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0) selenium-webdriver (~> 2.0)
xpath (~> 0.1.4) xpath (~> 0.1.4)
childprocess (0.2.2) childprocess (0.3.1)
ffi (~> 1.0.6) ffi (~> 1.0.6)
cocaine (0.2.0) cocaine (0.2.1)
cucumber (1.1.4) cucumber (1.1.9)
builder (>= 2.1.2) builder (>= 2.1.2)
diff-lcs (>= 1.1.2) diff-lcs (>= 1.1.2)
gherkin (~> 2.7.1) gherkin (~> 2.9.0)
json (>= 1.4.6) json (>= 1.4.6)
term-ansicolor (>= 1.0.6) term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3) diff-lcs (1.1.3)
excon (0.6.6) excon (0.6.6)
fakeweb (1.3.0) fakeweb (1.3.0)
ffi (1.0.9) ffi (1.0.11)
fog (0.11.0) ffi (1.0.11-java)
fog (0.9.0)
builder builder
excon (~> 0.6.5) excon (~> 0.6.1)
formatador (~> 0.2.0) formatador (>= 0.1.3)
json
mime-types mime-types
multi_json (~> 1.0.3) net-scp (>= 1.0.4)
net-scp (~> 1.0.4) net-ssh (>= 2.1.4)
net-ssh (~> 2.1.4) nokogiri (>= 1.4.4)
nokogiri (~> 1.5.0)
ruby-hmac ruby-hmac
formatador (0.2.1) formatador (0.2.1)
gherkin (2.7.1) gherkin (2.9.1)
json (>= 1.4.6)
gherkin (2.9.1-java)
json (>= 1.4.6) json (>= 1.4.6)
httparty (0.8.1) httparty (0.8.1)
multi_json multi_json
multi_xml multi_xml
i18n (0.6.0) i18n (0.6.0)
jdbc-sqlite3 (3.7.2)
jruby-openssl (0.7.6.1)
bouncy-castle-java (>= 1.5.0146.1)
json (1.6.5) json (1.6.5)
json_pure (1.6.1) json (1.6.5-java)
metaclass (0.0.1) metaclass (0.0.1)
mime-types (1.16) mime-types (1.18)
mocha (0.10.0) mocha (0.10.5)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.0.4) multi_json (1.1.0)
multi_xml (0.4.1) multi_xml (0.4.2)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
net-ssh (2.1.4) net-ssh (2.3.0)
nokogiri (1.5.0) nokogiri (1.4.7)
rack (1.3.3) nokogiri (1.4.7-java)
weakling (>= 0.0.3)
rack (1.4.1)
rack-test (0.6.1) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rake (0.9.2.2) rake (0.9.2.2)
rdiscount (1.6.8) rspec (2.9.0)
rspec (2.6.0) rspec-core (~> 2.9.0)
rspec-core (~> 2.6.0) rspec-expectations (~> 2.9.0)
rspec-expectations (~> 2.6.0) rspec-mocks (~> 2.9.0)
rspec-mocks (~> 2.6.0) rspec-core (2.9.0)
rspec-core (2.6.4) rspec-expectations (2.9.0)
rspec-expectations (2.6.0) diff-lcs (~> 1.1.3)
diff-lcs (~> 1.1.2) rspec-mocks (2.9.0)
rspec-mocks (2.6.0)
ruby-hmac (0.4.0) ruby-hmac (0.4.0)
rubyzip (0.9.4) rubyzip (0.9.6.1)
selenium-webdriver (2.7.0) selenium-webdriver (2.20.0)
childprocess (>= 0.2.1) childprocess (>= 0.2.5)
ffi (>= 1.0.7) ffi (~> 1.0)
json_pure multi_json (~> 1.0)
rubyzip rubyzip
shoulda (2.11.3) shoulda (3.0.1)
sqlite3 (1.3.4) shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
sqlite3 (1.3.5)
term-ansicolor (1.0.7) term-ansicolor (1.0.7)
tzinfo (0.3.32) tzinfo (0.3.32)
uuidtools (2.1.2) uuidtools (2.1.2)
weakling (0.0.4-java)
xpath (0.1.4) xpath (0.1.4)
nokogiri (~> 1.3) nokogiri (~> 1.3)
PLATFORMS PLATFORMS
java
ruby ruby
DEPENDENCIES DEPENDENCIES
activerecord-jdbcsqlite3-adapter
appraisal (~> 0.4.0) appraisal (~> 0.4.0)
aruba aruba
aws-sdk aws-sdk (~> 1.3.8)
bundler bundler
capybara capybara
cocaine (~> 0.2) cocaine (~> 0.2)
...@@ -132,7 +148,7 @@ DEPENDENCIES ...@@ -132,7 +148,7 @@ DEPENDENCIES
fog fog
jruby-openssl jruby-openssl
mocha mocha
nokogiri (~> 1.4.7)
paperclip! paperclip!
rake
shoulda shoulda
sqlite3 (~> 1.3.4) sqlite3
...@@ -11,7 +11,7 @@ Feature: Rails integration ...@@ -11,7 +11,7 @@ Feature: Rails integration
Scenario: Filesystem integration test Scenario: Filesystem integration test
Given I add this snippet to the User model: Given I add this snippet to the User model:
""" """
has_attached_file :attachment has_attached_file :attachment, :url => "/system/:attachment/:style/:filename"
""" """
And I start the rails application And I start the rails application
When I go to the new user page When I go to the new user page
...@@ -19,15 +19,15 @@ Feature: Rails integration ...@@ -19,15 +19,15 @@ Feature: Rails integration
And I attach the file "test/fixtures/5k.png" to "Attachment" And I attach the file "test/fixtures/5k.png" to "Attachment"
And I press "Submit" And I press "Submit"
Then I should see "Name: something" Then I should see "Name: something"
And I should see an image with a path of "/system/users/attachments/000/000/001/original/5k.png" And I should see an image with a path of "/system/attachments/original/5k.png"
And the file at "/system/users/attachments/000/000/001/original/5k.png" should be the same as "test/fixtures/5k.png" And the file at "/system/attachments/original/5k.png" should be the same as "test/fixtures/5k.png"
Scenario: S3 Integration test Scenario: S3 Integration test
Given I add this snippet to the User model: Given I add this snippet to the User model:
""" """
has_attached_file :attachment, has_attached_file :attachment,
:storage => :s3, :storage => :s3,
:path => "/:attachment/:id/:style/:filename", :path => "/:attachment/:style/:filename",
:s3_credentials => Rails.root.join("config/s3.yml") :s3_credentials => Rails.root.join("config/s3.yml")
""" """
And I write to "config/s3.yml" with: And I write to "config/s3.yml" with:
...@@ -42,5 +42,5 @@ Feature: Rails integration ...@@ -42,5 +42,5 @@ Feature: Rails integration
And I attach the file "test/fixtures/5k.png" to "Attachment" on S3 And I attach the file "test/fixtures/5k.png" to "Attachment" on S3
And I press "Submit" And I press "Submit"
Then I should see "Name: something" Then I should see "Name: something"
And I should see an image with a path of "http://s3.amazonaws.com/paperclip/attachments/1/original/5k.png" And I should see an image with a path of "http://s3.amazonaws.com/paperclip/attachments/original/5k.png"
And the file at "http://s3.amazonaws.com/paperclip/attachments/1/original/5k.png" should be uploaded to S3 And the file at "http://s3.amazonaws.com/paperclip/attachments/original/5k.png" should be uploaded to S3
...@@ -7,7 +7,9 @@ Given /^I generate a new rails application$/ do ...@@ -7,7 +7,9 @@ Given /^I generate a new rails application$/ do
""" """
source "http://rubygems.org" source "http://rubygems.org"
gem "rails", "#{framework_version}" gem "rails", "#{framework_version}"
gem "sqlite3" gem "sqlite3", :platform => :ruby
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
gem "jruby-openssl", :platform => :jruby
gem "capybara" gem "capybara"
gem "gherkin" gem "gherkin"
gem "aws-sdk" gem "aws-sdk"
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
source "http://rubygems.org" source "http://rubygems.org"
gem "jruby-openssl", :platform=>:jruby gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 3.0.12" gem "rails", "~> 3.0.12"
gem "paperclip", :path=>"../" gem "paperclip", :path=>"../"
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
source "http://rubygems.org" source "http://rubygems.org"
gem "jruby-openssl", :platform=>:jruby gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 3.1.4" gem "rails", "~> 3.1.4"
gem "paperclip", :path=>"../" gem "paperclip", :path=>"../"
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
source "http://rubygems.org" source "http://rubygems.org"
gem "jruby-openssl", :platform=>:jruby gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 3.2.2" gem "rails", "~> 3.2.2"
gem "paperclip", :path=>"../" gem "paperclip", :path=>"../"
......
...@@ -33,6 +33,7 @@ require 'paperclip/upfile' ...@@ -33,6 +33,7 @@ require 'paperclip/upfile'
require 'paperclip/iostream' require 'paperclip/iostream'
require 'paperclip/geometry' require 'paperclip/geometry'
require 'paperclip/processor' require 'paperclip/processor'
require 'paperclip/tempfile'
require 'paperclip/thumbnail' require 'paperclip/thumbnail'
require 'paperclip/interpolations' require 'paperclip/interpolations'
require 'paperclip/style' require 'paperclip/style'
......
...@@ -70,26 +70,4 @@ module Paperclip ...@@ -70,26 +70,4 @@ module Paperclip
@known_processors[name.to_s] = processor @known_processors[name.to_s] = processor
end end
end end
# Due to how ImageMagick handles its image format conversion and how Tempfile
# handles its naming scheme, it is necessary to override how Tempfile makes
# its names so as to allow for file extensions. Idea taken from the comments
# on this blog post:
# http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions
class Tempfile < ::Tempfile
# This is Ruby 1.8.7's implementation.
if RUBY_PLATFORM =~ /java/
def make_tmpname(basename, n)
case basename
when Array
prefix, suffix = *basename
else
prefix, suffix = basename, ''
end
t = Time.now.strftime("%y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
end
end
end
end end
module Paperclip
# Overriding some implementation of Tempfile
class Tempfile < ::Tempfile
# Due to how ImageMagick handles its image format conversion and how
# Tempfile handles its naming scheme, it is necessary to override how
# Tempfile makes # its names so as to allow for file extensions. Idea
# taken from the comments on this blog post:
# http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions
#
# This is Ruby 1.8.7's implementation.
def make_tmpname(basename, n)
if RUBY_PLATFORM =~ /java/
case basename
when Array
prefix, suffix = *basename
else
prefix, suffix = basename, ''
end
t = Time.now.strftime("%y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
else
super
end
end
end
module TempfileEncoding
# This overrides Tempfile#binmode to make sure that the extenal encoding
# for binary mode is ASCII-8BIT. This behavior is what's in CRuby, but not
# in JRuby
def binmode
set_encoding('ASCII-8BIT')
super
end
end
end
if RUBY_PLATFORM =~ /java/
::Tempfile.send :include, Paperclip::TempfileEncoding
end
...@@ -29,14 +29,13 @@ Gem::Specification.new do |s| ...@@ -29,14 +29,13 @@ Gem::Specification.new do |s|
s.add_development_dependency('shoulda') s.add_development_dependency('shoulda')
s.add_development_dependency('appraisal', '~> 0.4.0') s.add_development_dependency('appraisal', '~> 0.4.0')
s.add_development_dependency('mocha') s.add_development_dependency('mocha')
s.add_development_dependency('aws-sdk') s.add_development_dependency('aws-sdk', '~> 1.3.8')
s.add_development_dependency('sqlite3', '~> 1.3.4')
s.add_development_dependency('cucumber', '~> 1.1.0') s.add_development_dependency('cucumber', '~> 1.1.0')
s.add_development_dependency('aruba') s.add_development_dependency('aruba')
s.add_development_dependency('nokogiri', '~> 1.4.7')
s.add_development_dependency('capybara') s.add_development_dependency('capybara')
s.add_development_dependency('bundler') s.add_development_dependency('bundler')
s.add_development_dependency('cocaine', '~> 0.2') s.add_development_dependency('cocaine', '~> 0.2')
s.add_development_dependency('fog') s.add_development_dependency('fog')
s.add_development_dependency('rake')
s.add_development_dependency('fakeweb') s.add_development_dependency('fakeweb')
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment