Skip to content

Commit 914416d

Browse files
committed
setup and integration spec with a Rails 4.1 stub
1 parent dae7ca7 commit 914416d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+712
-87
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ gemfile:
2222
- gemfiles/rails31.gemfile
2323
- gemfiles/rails32.gemfile
2424
- gemfiles/rails40.gemfile
25-
#- gemfiles/rails41.gemfile
25+
- gemfiles/rails41.gemfile
2626
env:
2727
- JRUBY_OPTS="--1.8 $JRUBY_OPTS"
2828
- JRUBY_OPTS="$JRUBY_OPTS" JAVA_OPTS="-Djruby.version=$JRUBY_VERSION" # for mvn's jruby plugins

gemfiles/rails40.gemfile.lock

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actionmailer (4.0.8)
5-
actionpack (= 4.0.8)
6-
mail (~> 2.5.4)
7-
actionpack (4.0.8)
8-
activesupport (= 4.0.8)
4+
actionmailer (4.0.13)
5+
actionpack (= 4.0.13)
6+
mail (~> 2.5, >= 2.5.4)
7+
actionpack (4.0.13)
8+
activesupport (= 4.0.13)
99
builder (~> 3.1.0)
1010
erubis (~> 2.7.0)
1111
rack (~> 1.5.2)
1212
rack-test (~> 0.6.2)
13-
activemodel (4.0.8)
14-
activesupport (= 4.0.8)
13+
activemodel (4.0.13)
14+
activesupport (= 4.0.13)
1515
builder (~> 3.1.0)
16-
activerecord (4.0.8)
17-
activemodel (= 4.0.8)
16+
activerecord (4.0.13)
17+
activemodel (= 4.0.13)
1818
activerecord-deprecated_finders (~> 1.0.2)
19-
activesupport (= 4.0.8)
19+
activesupport (= 4.0.13)
2020
arel (~> 4.0.0)
2121
activerecord-deprecated_finders (1.0.3)
22-
activesupport (4.0.8)
22+
activesupport (4.0.13)
2323
i18n (~> 0.6, >= 0.6.9)
2424
minitest (~> 4.2)
2525
multi_json (~> 1.3)
@@ -30,28 +30,26 @@ GEM
3030
diff-lcs (1.2.5)
3131
erubis (2.7.0)
3232
hike (1.2.3)
33-
i18n (0.6.11)
34-
mail (2.5.4)
35-
mime-types (~> 1.16)
36-
treetop (~> 1.4.8)
37-
mime-types (1.25.1)
33+
i18n (0.7.0)
34+
mail (2.6.3)
35+
mime-types (>= 1.16, < 3)
36+
mime-types (2.4.3)
3837
minitest (4.7.5)
3938
multi_json (1.10.1)
40-
polyglot (0.3.5)
4139
rack (1.5.2)
42-
rack-test (0.6.2)
40+
rack-test (0.6.3)
4341
rack (>= 1.0)
44-
rails (4.0.8)
45-
actionmailer (= 4.0.8)
46-
actionpack (= 4.0.8)
47-
activerecord (= 4.0.8)
48-
activesupport (= 4.0.8)
42+
rails (4.0.13)
43+
actionmailer (= 4.0.13)
44+
actionpack (= 4.0.13)
45+
activerecord (= 4.0.13)
46+
activesupport (= 4.0.13)
4947
bundler (>= 1.3.0, < 2.0)
50-
railties (= 4.0.8)
48+
railties (= 4.0.13)
5149
sprockets-rails (~> 2.0)
52-
railties (4.0.8)
53-
actionpack (= 4.0.8)
54-
activesupport (= 4.0.8)
50+
railties (4.0.13)
51+
actionpack (= 4.0.13)
52+
activesupport (= 4.0.13)
5553
rake (>= 0.8.7)
5654
thor (>= 0.18.1, < 2.0)
5755
rake (10.3.2)
@@ -63,22 +61,19 @@ GEM
6361
rspec-expectations (2.14.5)
6462
diff-lcs (>= 1.1.3, < 2.0)
6563
rspec-mocks (2.14.6)
66-
sprockets (2.12.1)
64+
sprockets (2.12.3)
6765
hike (~> 1.2)
6866
multi_json (~> 1.0)
6967
rack (~> 1.0)
7068
tilt (~> 1.1, != 1.3.0)
71-
sprockets-rails (2.1.3)
69+
sprockets-rails (2.2.2)
7270
actionpack (>= 3.0)
7371
activesupport (>= 3.0)
74-
sprockets (~> 2.8)
72+
sprockets (>= 2.8, < 4.0)
7573
thor (0.19.1)
7674
thread_safe (0.3.4-java)
7775
tilt (1.4.1)
78-
treetop (1.4.15)
79-
polyglot
80-
polyglot (>= 0.3.1)
81-
tzinfo (0.3.40)
76+
tzinfo (0.3.42)
8277

8378
PLATFORMS
8479
java

gemfiles/rails41.gemfile.lock

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actionmailer (4.1.4)
5-
actionpack (= 4.1.4)
6-
actionview (= 4.1.4)
7-
mail (~> 2.5.4)
8-
actionpack (4.1.4)
9-
actionview (= 4.1.4)
10-
activesupport (= 4.1.4)
4+
actionmailer (4.1.9)
5+
actionpack (= 4.1.9)
6+
actionview (= 4.1.9)
7+
mail (~> 2.5, >= 2.5.4)
8+
actionpack (4.1.9)
9+
actionview (= 4.1.9)
10+
activesupport (= 4.1.9)
1111
rack (~> 1.5.2)
1212
rack-test (~> 0.6.2)
13-
actionview (4.1.4)
14-
activesupport (= 4.1.4)
13+
actionview (4.1.9)
14+
activesupport (= 4.1.9)
1515
builder (~> 3.1)
1616
erubis (~> 2.7.0)
17-
activemodel (4.1.4)
18-
activesupport (= 4.1.4)
17+
activemodel (4.1.9)
18+
activesupport (= 4.1.9)
1919
builder (~> 3.1)
20-
activerecord (4.1.4)
21-
activemodel (= 4.1.4)
22-
activesupport (= 4.1.4)
20+
activerecord (4.1.9)
21+
activemodel (= 4.1.9)
22+
activesupport (= 4.1.9)
2323
arel (~> 5.0.0)
24-
activesupport (4.1.4)
24+
activesupport (4.1.9)
2525
i18n (~> 0.6, >= 0.6.9)
2626
json (~> 1.7, >= 1.7.7)
2727
minitest (~> 5.1)
@@ -32,31 +32,29 @@ GEM
3232
diff-lcs (1.2.5)
3333
erubis (2.7.0)
3434
hike (1.2.3)
35-
i18n (0.6.11)
36-
json (1.8.1-java)
37-
mail (2.5.4)
38-
mime-types (~> 1.16)
39-
treetop (~> 1.4.8)
40-
mime-types (1.25.1)
41-
minitest (5.4.0)
35+
i18n (0.7.0)
36+
json (1.8.2-java)
37+
mail (2.6.3)
38+
mime-types (>= 1.16, < 3)
39+
mime-types (2.4.3)
40+
minitest (5.5.1)
4241
multi_json (1.10.1)
43-
polyglot (0.3.5)
4442
rack (1.5.2)
45-
rack-test (0.6.2)
43+
rack-test (0.6.3)
4644
rack (>= 1.0)
47-
rails (4.1.4)
48-
actionmailer (= 4.1.4)
49-
actionpack (= 4.1.4)
50-
actionview (= 4.1.4)
51-
activemodel (= 4.1.4)
52-
activerecord (= 4.1.4)
53-
activesupport (= 4.1.4)
45+
rails (4.1.9)
46+
actionmailer (= 4.1.9)
47+
actionpack (= 4.1.9)
48+
actionview (= 4.1.9)
49+
activemodel (= 4.1.9)
50+
activerecord (= 4.1.9)
51+
activesupport (= 4.1.9)
5452
bundler (>= 1.3.0, < 2.0)
55-
railties (= 4.1.4)
53+
railties (= 4.1.9)
5654
sprockets-rails (~> 2.0)
57-
railties (4.1.4)
58-
actionpack (= 4.1.4)
59-
activesupport (= 4.1.4)
55+
railties (4.1.9)
56+
actionpack (= 4.1.9)
57+
activesupport (= 4.1.9)
6058
rake (>= 0.8.7)
6159
thor (>= 0.18.1, < 2.0)
6260
rake (10.3.2)
@@ -68,22 +66,19 @@ GEM
6866
rspec-expectations (2.14.5)
6967
diff-lcs (>= 1.1.3, < 2.0)
7068
rspec-mocks (2.14.6)
71-
sprockets (2.12.1)
69+
sprockets (2.12.3)
7270
hike (~> 1.2)
7371
multi_json (~> 1.0)
7472
rack (~> 1.0)
7573
tilt (~> 1.1, != 1.3.0)
76-
sprockets-rails (2.1.3)
74+
sprockets-rails (2.2.2)
7775
actionpack (>= 3.0)
7876
activesupport (>= 3.0)
79-
sprockets (~> 2.8)
77+
sprockets (>= 2.8, < 4.0)
8078
thor (0.19.1)
8179
thread_safe (0.3.4-java)
8280
tilt (1.4.1)
83-
treetop (1.4.15)
84-
polyglot
85-
polyglot (>= 0.3.1)
86-
tzinfo (1.2.1)
81+
tzinfo (1.2.2)
8782
thread_safe (~> 0.1)
8883

8984
PLATFORMS

src/spec/ruby/jruby/rack/integration_spec.rb

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11

22
require File.expand_path('spec_helper', File.dirname(__FILE__) + '/../..')
3-
require 'fileutils'
4-
require 'jruby'
53

64
java_import org.jruby.rack.RackContext
75
java_import org.jruby.rack.servlet.ServletRackContext
@@ -15,6 +13,8 @@
1513

1614
describe "integration" do
1715

16+
before(:all) { require 'fileutils' }
17+
1818
#after(:all) { JRuby::Rack.context = nil }
1919

2020
describe 'rack (lambda)' do
@@ -90,12 +90,7 @@
9090

9191
shared_examples_for 'a rails app', :shared => true do
9292

93-
let(:servlet_context) do
94-
servlet_context = org.jruby.rack.mock.MockServletContext.new base_path
95-
servlet_context.logger = raise_logger
96-
set_compat_version servlet_context
97-
servlet_context
98-
end
93+
let(:servlet_context) { new_servlet_context(base_path) }
9994

10095
it "initializes (pooling by default)" do
10196
listener = org.jruby.rack.rails.RailsServletContextListener.new
@@ -318,6 +313,55 @@
318313

319314
end
320315

316+
describe 'rails 4.1', :lib => :rails41 do
317+
318+
before(:all) do name = :rails41 # copy_gemfile :
319+
FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile"), File.join(STUB_DIR, "#{name}/Gemfile")
320+
FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile.lock"), File.join(STUB_DIR, "#{name}/Gemfile.lock")
321+
Dir.chdir File.join(STUB_DIR, name.to_s)
322+
end
323+
324+
def prepare_servlet_context(servlet_context)
325+
servlet_context.addInitParameter('rails.root', "#{STUB_DIR}/rails41")
326+
servlet_context.addInitParameter('jruby.rack.layout_class', 'FileSystemLayout')
327+
end
328+
329+
def base_path; "file://#{STUB_DIR}/rails41" end
330+
# let(:base_path) { "file://#{STUB_DIR}/rails41" }
331+
332+
it_should_behave_like 'a rails app'
333+
334+
context "initialized" do
335+
336+
before(:all) { initialize_rails 'production', base_path }
337+
after(:all) { restore_rails }
338+
339+
it "loaded rack ~> 1.5" do
340+
@runtime = @rack_factory.getApplication.getRuntime
341+
should_eval_as_not_nil "defined?(Rack.release)"
342+
should_eval_as_eql_to "Rack.release.to_s[0, 3]", '1.5'
343+
end
344+
345+
it "booted with a servlet logger" do
346+
@runtime = @rack_factory.getApplication.getRuntime
347+
should_eval_as_not_nil "defined?(Rails)"
348+
should_eval_as_not_nil "Rails.logger"
349+
# NOTE: TaggedLogging is a module that extends the instance now :
350+
should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::TaggedLogging", true
351+
should_eval_as_eql_to "Rails.logger.instance_variable_get(:'@logdev').dev.class.name",
352+
'JRuby::Rack::ServletLog'
353+
should_eval_as_eql_to "Rails.logger.level", Logger::INFO
354+
end
355+
356+
it "sets up public_path (as for a war)" do
357+
@runtime = @rack_factory.getApplication.getRuntime
358+
should_eval_as_eql_to "Rails.public_path.to_s", "#{STUB_DIR}/rails41/public"
359+
end
360+
361+
end
362+
363+
end
364+
321365
describe 'rails 2.3', :lib => :rails23 do
322366

323367
before(:all) do
@@ -411,11 +455,15 @@ def restore_rails
411455
def new_servlet_context(base_path = nil)
412456
servlet_context = org.jruby.rack.mock.MockServletContext.new base_path
413457
servlet_context.logger = raise_logger
414-
set_compat_version servlet_context
458+
prepare_servlet_context servlet_context
415459
servlet_context
416460
end
417461

418-
def set_compat_version(servlet_context = @servlet_context)
462+
def prepare_servlet_context(servlet_context)
463+
set_compat_version servlet_context
464+
end
465+
466+
def set_compat_version(servlet_context = @servlet_context); require 'jruby'
419467
compat_version = JRuby.runtime.getInstanceConfig.getCompatVersion # RUBY1_9
420468
servlet_context.addInitParameter("jruby.compat.version", compat_version.to_s)
421469
end

src/spec/stub/rails41/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Gemfile
2+
Gemfile.lock

src/spec/stub/rails41/Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require File.expand_path('../config/application', __FILE__)
5+
6+
Rails.application.load_tasks

src/spec/stub/rails41/app/assets/images/.keep

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This is a manifest file that'll be compiled into application.js, which will include all the files
2+
// listed below.
3+
//
4+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6+
//
7+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8+
// compiled file.
9+
//
10+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11+
// about supported directives.
12+
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
//= require turbolinks
16+
//= require_tree .
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This is a manifest file that'll be compiled into application.css, which will include all the files
3+
* listed below.
4+
*
5+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7+
*
8+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
9+
* compiled file so the styles you add here take precedence over styles defined in any styles
10+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11+
* file per style scope.
12+
*
13+
*= require_tree .
14+
*= require_self
15+
*/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ApplicationController < ActionController::Base
2+
# Prevent CSRF attacks by raising an exception.
3+
# For APIs, you may want to use :null_session instead.
4+
protect_from_forgery with: :exception
5+
end

0 commit comments

Comments
 (0)