diff --git a/.travis.yml b/.travis.yml index eb9b6c2a..d59f7c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,6 @@ before_install: - ((echo $BUNDLE_GEMFILE | grep rails23) && jruby --1.9 -S gem update --system 1.8.29) || true matrix: allow_failures: - #- rvm: jruby-head #- gemfile: gemfiles/rails41.gemfile exclude: ## avoid jruby-head with JDK6 : @@ -123,6 +122,14 @@ matrix: gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" jdk: oraclejdk7 + - rvm: jruby-1.7.16 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: openjdk6 + - rvm: jruby-1.7.16 + gemfile: gemfiles/rails41.gemfile + env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" + jdk: oraclejdk7 - rvm: jruby-1.7.16 gemfile: gemfiles/rails41.gemfile env: JRUBY_OPTS="--1.8 $JRUBY_OPTS" diff --git a/History.md b/History.md index 17e2531d..511ae9fb 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,14 @@ +## 1.1.18 (13/01/15) + +- back-port Rack::ShowStatus to be used with out ErrorApp (contains XSS fix #190) +- search rackup (config.ru) on context-classloader if not found elsewhere +- introduce a new ClassPathLayout where the whole app + gems are on CP (#191) +- update to (vendored) rack ~> 1.5.2 (for JRuby-Rack 1.1.x) +- use Rack::Utils.best_q_match in ErrorApp if available +- improved rack-compatibility for our "pure" servlet-env request env parsing + * raise a TypeError just like rack does when it detects invalid parameters + * compatibility with rack's parse_nested_query logic + ## 1.1.17 (30/12/14) This release changes deployment from codehaus.org to oss.sonatype.org for artifacts. diff --git a/gemfiles/rails40.gemfile.lock b/gemfiles/rails40.gemfile.lock index d8993951..b55cc6d9 100644 --- a/gemfiles/rails40.gemfile.lock +++ b/gemfiles/rails40.gemfile.lock @@ -1,25 +1,25 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.8) - actionpack (= 4.0.8) - mail (~> 2.5.4) - actionpack (4.0.8) - activesupport (= 4.0.8) + actionmailer (4.0.13) + actionpack (= 4.0.13) + mail (~> 2.5, >= 2.5.4) + actionpack (4.0.13) + activesupport (= 4.0.13) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.8) - activesupport (= 4.0.8) + activemodel (4.0.13) + activesupport (= 4.0.13) builder (~> 3.1.0) - activerecord (4.0.8) - activemodel (= 4.0.8) + activerecord (4.0.13) + activemodel (= 4.0.13) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.8) + activesupport (= 4.0.13) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.8) + activesupport (4.0.13) i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) @@ -30,28 +30,26 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) hike (1.2.3) - i18n (0.6.11) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) + i18n (0.7.0) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) minitest (4.7.5) multi_json (1.10.1) - polyglot (0.3.5) rack (1.5.2) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rails (4.0.8) - actionmailer (= 4.0.8) - actionpack (= 4.0.8) - activerecord (= 4.0.8) - activesupport (= 4.0.8) + rails (4.0.13) + actionmailer (= 4.0.13) + actionpack (= 4.0.13) + activerecord (= 4.0.13) + activesupport (= 4.0.13) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.8) + railties (= 4.0.13) sprockets-rails (~> 2.0) - railties (4.0.8) - actionpack (= 4.0.8) - activesupport (= 4.0.8) + railties (4.0.13) + actionpack (= 4.0.13) + activesupport (= 4.0.13) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) @@ -63,22 +61,19 @@ GEM rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) - sprockets (2.12.1) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.2.2) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) + sprockets (>= 2.8, < 4.0) thor (0.19.1) thread_safe (0.3.4-java) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.41) + tzinfo (0.3.42) PLATFORMS java diff --git a/gemfiles/rails41.gemfile.lock b/gemfiles/rails41.gemfile.lock index 7daa5dbf..d94a8d58 100644 --- a/gemfiles/rails41.gemfile.lock +++ b/gemfiles/rails41.gemfile.lock @@ -1,27 +1,27 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.4) - actionpack (= 4.1.4) - actionview (= 4.1.4) - mail (~> 2.5.4) - actionpack (4.1.4) - actionview (= 4.1.4) - activesupport (= 4.1.4) + actionmailer (4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.9) + actionview (= 4.1.9) + activesupport (= 4.1.9) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.4) - activesupport (= 4.1.4) + actionview (4.1.9) + activesupport (= 4.1.9) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.4) - activesupport (= 4.1.4) + activemodel (4.1.9) + activesupport (= 4.1.9) builder (~> 3.1) - activerecord (4.1.4) - activemodel (= 4.1.4) - activesupport (= 4.1.4) + activerecord (4.1.9) + activemodel (= 4.1.9) + activesupport (= 4.1.9) arel (~> 5.0.0) - activesupport (4.1.4) + activesupport (4.1.9) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -32,31 +32,29 @@ GEM diff-lcs (1.2.5) erubis (2.7.0) hike (1.2.3) - i18n (0.6.11) - json (1.8.1-java) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - minitest (5.4.0) + i18n (0.7.0) + json (1.8.2-java) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) + minitest (5.5.1) multi_json (1.10.1) - polyglot (0.3.5) rack (1.5.2) - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rails (4.1.4) - actionmailer (= 4.1.4) - actionpack (= 4.1.4) - actionview (= 4.1.4) - activemodel (= 4.1.4) - activerecord (= 4.1.4) - activesupport (= 4.1.4) + rails (4.1.9) + actionmailer (= 4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) + activemodel (= 4.1.9) + activerecord (= 4.1.9) + activesupport (= 4.1.9) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.4) + railties (= 4.1.9) sprockets-rails (~> 2.0) - railties (4.1.4) - actionpack (= 4.1.4) - activesupport (= 4.1.4) + railties (4.1.9) + actionpack (= 4.1.9) + activesupport (= 4.1.9) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.3.2) @@ -68,21 +66,18 @@ GEM rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) rspec-mocks (2.14.6) - sprockets (2.12.1) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.1.3) + sprockets-rails (2.2.2) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) + sprockets (>= 2.8, < 4.0) thor (0.19.1) thread_safe (0.3.4-java) tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) tzinfo (1.2.2) thread_safe (~> 0.1) diff --git a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java index 2eaa0b27..5784b03d 100644 --- a/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java +++ b/src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java @@ -7,13 +7,14 @@ package org.jruby.rack; -import java.io.IOException; + import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URISyntaxException; import java.net.URL; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -195,7 +196,7 @@ public IRubyObject createErrorApplicationObject(final Ruby runtime) { } if (errorApp == null) { errorApp = "require 'jruby/rack/error_app' \n" + - "use Rack::ShowStatus \n" + + "use JRuby::Rack::ErrorApp::ShowStatus \n" + "run JRuby::Rack::ErrorApp.new"; } runtime.evalScriptlet("load 'jruby/rack/boot/rack.rb'"); @@ -510,13 +511,11 @@ private String findConfigRuPathInSubDirectories(final String path, int level) { if (level > 0) { level--; - for ( Iterator i = entries.iterator(); i.hasNext(); ) { - String subpath = i.next(); - if (subpath.endsWith("/")) { + for ( String subpath : entries ) { + final int len = subpath.length(); + if ( len > 0 && subpath.charAt(len - 1) == '/' ) { subpath = findConfigRuPathInSubDirectories(subpath, level); - if (subpath != null) { - return subpath; - } + if ( subpath != null ) return subpath; } } } @@ -524,9 +523,22 @@ private String findConfigRuPathInSubDirectories(final String path, int level) { return null; } - private String resolveRackupScript() throws RackInitializationException { - rackupLocation = ""; + private static String getContextLoaderScript(final String name, final boolean silent) + throws IOException { + try { // still try context-loader for resolving rackup : + final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); + InputStream is = contextLoader.getResourceAsStream(name); + return IOHelpers.inputStreamToString(is); + } + catch (IOException e) { + if ( silent ) return null; throw e; + } + catch (RuntimeException e) { + if ( silent ) return null; throw e; + } + } + private String resolveRackupScript() throws RackInitializationException { String rackup = rackContext.getConfig().getRackup(); if (rackup == null) { rackup = rackContext.getConfig().getRackupPath(); @@ -543,9 +555,29 @@ private String resolveRackupScript() throws RackInitializationException { } if (rackup != null) { - rackupLocation = rackContext.getRealPath(rackup); + InputStream is; try { - rackup = IOHelpers.inputStreamToString(rackContext.getResourceAsStream(rackup)); + is = rackContext.getResourceAsStream(rackup); + rackupLocation = rackContext.getRealPath(rackup); + return this.rackupScript = IOHelpers.inputStreamToString(is); + } + catch (IOException e) { + try { // last - try context-loader for resolving rackup : + if ( (rackup = getContextLoaderScript(rackup, true)) != null ) { + return this.rackupScript = rackup; + } + } + catch (IOException ex) { /* won't happen */ } + + rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); + throw new RackInitializationException("failed to read rackup input", e); + } + } + else { + rackup = "config.ru"; + try { + rackup = getContextLoaderScript(rackup, false); + rackupLocation = "uri:classloader://config.ru"; } catch (IOException e) { rackContext.log(ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")"); @@ -553,6 +585,9 @@ private String resolveRackupScript() throws RackInitializationException { } } } + else { + rackupLocation = ""; + } return this.rackupScript = rackup; } diff --git a/src/main/ruby/jruby/rack/app_layout.rb b/src/main/ruby/jruby/rack/app_layout.rb index ef1425a1..7ff3342f 100644 --- a/src/main/ruby/jruby/rack/app_layout.rb +++ b/src/main/ruby/jruby/rack/app_layout.rb @@ -42,6 +42,7 @@ def expand_path(path) def real_path(path) real_path = @rack_context.getRealPath(path) real_path.chomp!('/') if real_path + # just use the given path if there is no real path real_path end @@ -107,6 +108,31 @@ def expand_path(path) RailsWebInfLayout = WebInfLayout + class ClassPathLayout < WebInfLayout + + URI_CLASSLOADER = 'uri:classloader://' + + def real_path(path) + if path.start_with? URI_CLASSLOADER + path + else + super + end + end + + def app_uri + @app_uri ||= + @rack_context.getInitParameter('app.root') || + URI_CLASSLOADER + end + + def gem_uri + @gem_uri ||= + @rack_context.getInitParameter('gem.path') || + URI_CLASSLOADER + end + end + # File system layout, simply assumes application is not packaged # (or expanded in a way as if it where not packaged previously). class FileSystemLayout < AppLayout diff --git a/src/main/ruby/jruby/rack/error_app.rb b/src/main/ruby/jruby/rack/error_app.rb index 3e7d27d3..8763a126 100644 --- a/src/main/ruby/jruby/rack/error_app.rb +++ b/src/main/ruby/jruby/rack/error_app.rb @@ -9,6 +9,8 @@ module JRuby module Rack class ErrorApp + autoload :ShowStatus, 'jruby/rack/error_app/show_status' + EXCEPTION = org.jruby.rack.RackEnvironment::EXCEPTION DEFAULT_RESPONSE_CODE = 500 diff --git a/src/main/ruby/jruby/rack/error_app/show_status.rb b/src/main/ruby/jruby/rack/error_app/show_status.rb new file mode 100644 index 00000000..8adf37a6 --- /dev/null +++ b/src/main/ruby/jruby/rack/error_app/show_status.rb @@ -0,0 +1,107 @@ +require 'erb' + +class JRuby::Rack::ErrorApp + + # catches empty responses and replaces them with a site explaining the error. + # + # @note kindly adapted from on Rack::ShowStatus + # @private internal API - likely won't exist in 1.2.x + class ShowStatus + + def initialize(app) + require 'rack/request'; require 'rack/utils' + @app = app + @template = ERB.new(TEMPLATE) + end + + def call(env) + status, headers, body = @app.call(env) + headers = ::Rack::Utils::HeaderHash.new(headers) + empty = headers['Content-Length'].to_i <= 0 + + # client or server error, or explicit message + if (status.to_i >= 400 && empty) || env["rack.showstatus.detail"] + # required erb template variables (captured with binding) : + req = req = ::Rack::Request.new(env) + message = ::Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s + detail = detail = env["rack.showstatus.detail"] || message + + body = @template.result(binding) + size = ::Rack::Utils.bytesize(body) + [status, headers.merge('Content-Type' => "text/html", 'Content-Length' => size.to_s), [body]] + else + [status, headers, body] + end + end + + # @private + def h(obj) + case obj + when String + ::Rack::Utils.escape_html(obj) + else + ::Rack::Utils.escape_html(obj.inspect) + end + end + + # :stopdoc: + +# adapted from Django +# Copyright (c) 2005, the Lawrence Journal-World +# Used under the modified BSD license: +# http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5 +TEMPLATE = <<'HTML' + + + + + <%=h message %> at <%=h req.script_name + req.path_info %> + + + + +
+

<%=h message %> (<%= status.to_i %>)

+ + + + + + + + + +
Request Method:<%=h req.request_method %>
Request URL:<%=h req.url %>
+
+
+

<%=h detail %>

+
+ +
+

+ You're seeing this error because you use JRuby::Rack::ErrorApp::ShowStatus. +

+
+ + +HTML + + # :startdoc: + end +end diff --git a/src/spec/ruby/cgi/session/java_servlet_store_spec.rb b/src/spec/ruby/cgi/session/java_servlet_store_spec.rb index 5a1d99c2..602dbb2a 100644 --- a/src/spec/ruby/cgi/session/java_servlet_store_spec.rb +++ b/src/spec/ruby/cgi/session/java_servlet_store_spec.rb @@ -171,6 +171,6 @@ def hmac(key, data) @session.should_receive(:getLastAccessedTime).and_return 123 @session.should_receive(:setAttribute).with("__rails_secret", "abcrandom123") @dbman.generate_digest("key").should == hmac("abcrandom123", "key") - end + end unless JRUBY_VERSION < '1.7.0' end end diff --git a/src/spec/ruby/jruby/rack/integration_spec.rb b/src/spec/ruby/jruby/rack/integration_spec.rb index 46bbcf1d..77a0c3cb 100644 --- a/src/spec/ruby/jruby/rack/integration_spec.rb +++ b/src/spec/ruby/jruby/rack/integration_spec.rb @@ -1,7 +1,5 @@ require File.expand_path('spec_helper', File.dirname(__FILE__) + '/../..') -require 'fileutils' -require 'jruby' java_import org.jruby.rack.RackContext java_import org.jruby.rack.servlet.ServletRackContext @@ -15,6 +13,8 @@ describe "integration" do + before(:all) { require 'fileutils' } + #after(:all) { JRuby::Rack.context = nil } describe 'rack (lambda)' do @@ -89,12 +89,7 @@ shared_examples_for 'a rails app', :shared => true do - let(:servlet_context) do - servlet_context = org.jruby.rack.mock.MockServletContext.new base_path - servlet_context.logger = raise_logger - set_compat_version servlet_context - servlet_context - end + let(:servlet_context) { new_servlet_context(base_path) } it "initializes (pooling by default)" do listener = org.jruby.rack.rails.RailsServletContextListener.new @@ -317,6 +312,55 @@ def base_path; "file://#{STUB_DIR}/rails40" end end + describe 'rails 4.1', :lib => :rails41 do + + before(:all) do name = :rails41 # copy_gemfile : + FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile"), File.join(STUB_DIR, "#{name}/Gemfile") + FileUtils.cp File.join(GEMFILES_DIR, "#{name}.gemfile.lock"), File.join(STUB_DIR, "#{name}/Gemfile.lock") + Dir.chdir File.join(STUB_DIR, name.to_s) + end + + def prepare_servlet_context(servlet_context) + servlet_context.addInitParameter('rails.root', "#{STUB_DIR}/rails41") + servlet_context.addInitParameter('jruby.rack.layout_class', 'FileSystemLayout') + end + + def base_path; "file://#{STUB_DIR}/rails41" end + # let(:base_path) { "file://#{STUB_DIR}/rails41" } + + it_should_behave_like 'a rails app' + + context "initialized" do + + before(:all) { initialize_rails 'production', base_path } + after(:all) { restore_rails } + + it "loaded rack ~> 1.5" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_not_nil "defined?(Rack.release)" + should_eval_as_eql_to "Rack.release.to_s[0, 3]", '1.5' + end + + it "booted with a servlet logger" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_not_nil "defined?(Rails)" + should_eval_as_not_nil "Rails.logger" + # NOTE: TaggedLogging is a module that extends the instance now : + should_eval_as_eql_to "Rails.logger.is_a? ActiveSupport::TaggedLogging", true + should_eval_as_eql_to "Rails.logger.instance_variable_get(:'@logdev').dev.class.name", + 'JRuby::Rack::ServletLog' + should_eval_as_eql_to "Rails.logger.level", Logger::INFO + end + + it "sets up public_path (as for a war)" do + @runtime = @rack_factory.getApplication.getRuntime + should_eval_as_eql_to "Rails.public_path.to_s", "#{STUB_DIR}/rails41/public" + end + + end + + end + describe 'rails 2.3', :lib => :rails23 do before(:all) do @@ -410,11 +454,15 @@ def restore_rails def new_servlet_context(base_path = nil) servlet_context = org.jruby.rack.mock.MockServletContext.new base_path servlet_context.logger = raise_logger - set_compat_version servlet_context + prepare_servlet_context servlet_context servlet_context end - def set_compat_version(servlet_context = @servlet_context) + def prepare_servlet_context(servlet_context) + set_compat_version servlet_context + end + + def set_compat_version(servlet_context = @servlet_context); require 'jruby' compat_version = JRuby.runtime.getInstanceConfig.getCompatVersion # RUBY1_9 servlet_context.addInitParameter("jruby.compat.version", compat_version.to_s) end diff --git a/src/spec/ruby/rack/application_spec.rb b/src/spec/ruby/rack/application_spec.rb index 47c0dad4..5edc8e07 100644 --- a/src/spec/ruby/rack/application_spec.rb +++ b/src/spec/ruby/rack/application_spec.rb @@ -245,8 +245,8 @@ def newRuntime() # use the current runtime instead of creating new rack_app = error_application.getApplication #expect( rack_app ).to be_a Rack::Handler::Servlet expect( rack_app.class.name ).to eql 'Rack::Handler::Servlet' - expect( rack_app.app ).to be_a Rack::ShowStatus - #expect( app.class.name ).to eql 'Rack::ShowStatus' + expect( rack_app.app ).to be_a JRuby::Rack::ErrorApp::ShowStatus + #expect( app.class.name ).to eql 'JRuby::Rack::ErrorApp::ShowStatus' error_app = rack_app.app.instance_variable_get('@app') expect( error_app ).to be_a JRuby::Rack::ErrorApp #expect( error_app.class.name ).to eql 'JRuby::Rack::ErrorApp' diff --git a/src/spec/ruby/rack/handler/servlet_spec.rb b/src/spec/ruby/rack/handler/servlet_spec.rb index abfbc119..947c5d0f 100644 --- a/src/spec/ruby/rack/handler/servlet_spec.rb +++ b/src/spec/ruby/rack/handler/servlet_spec.rb @@ -417,6 +417,7 @@ def getAttributeNames servlet_request.addParameter('foo[meh[]]', '42') servlet_request.addParameter('huh[1]', 'b') servlet_request.addParameter('huh[0]', 'a') + set_rack_input @servlet_env # due rack_request.POST env = servlet.create_env(@servlet_env) rack_request = Rack::Request.new(env) @@ -443,6 +444,7 @@ def getAttributeNames servlet_request.setQueryString 'foo[]=0&foo[bar]=1' servlet_request.addParameter('foo[]', '0') servlet_request.addParameter('foo[bar]', '1') + set_rack_input @servlet_env # due rack_request.POST env = servlet.create_env(@servlet_env) rack_request = Rack::Request.new(env) @@ -1071,6 +1073,7 @@ def servlet.create_env(servlet_env) # Query params : servlet_request.addParameter('foo', 'bar') servlet_request.addParameter('quux', 'b;la') + set_rack_input servlet_env # due rack_request.POST env = servlet.create_env(servlet_env) rack_request = Rack::Request.new(env) diff --git a/src/spec/stub/rails41/.gitignore b/src/spec/stub/rails41/.gitignore new file mode 100644 index 00000000..65e0d93c --- /dev/null +++ b/src/spec/stub/rails41/.gitignore @@ -0,0 +1,2 @@ +Gemfile +Gemfile.lock diff --git a/src/spec/stub/rails41/Rakefile b/src/spec/stub/rails41/Rakefile new file mode 100644 index 00000000..ba6b733d --- /dev/null +++ b/src/spec/stub/rails41/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/src/spec/stub/rails41/app/assets/images/.keep b/src/spec/stub/rails41/app/assets/images/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/assets/javascripts/application.js b/src/spec/stub/rails41/app/assets/javascripts/application.js new file mode 100644 index 00000000..d6925fa4 --- /dev/null +++ b/src/spec/stub/rails41/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/src/spec/stub/rails41/app/assets/stylesheets/application.css b/src/spec/stub/rails41/app/assets/stylesheets/application.css new file mode 100644 index 00000000..a443db34 --- /dev/null +++ b/src/spec/stub/rails41/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/src/spec/stub/rails41/app/controllers/application_controller.rb b/src/spec/stub/rails41/app/controllers/application_controller.rb new file mode 100644 index 00000000..d83690e1 --- /dev/null +++ b/src/spec/stub/rails41/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/src/spec/stub/rails41/app/controllers/concerns/.keep b/src/spec/stub/rails41/app/controllers/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/helpers/application_helper.rb b/src/spec/stub/rails41/app/helpers/application_helper.rb new file mode 100644 index 00000000..de6be794 --- /dev/null +++ b/src/spec/stub/rails41/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/src/spec/stub/rails41/app/mailers/.keep b/src/spec/stub/rails41/app/mailers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/models/.keep b/src/spec/stub/rails41/app/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/models/concerns/.keep b/src/spec/stub/rails41/app/models/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/app/views/layouts/application.html.erb b/src/spec/stub/rails41/app/views/layouts/application.html.erb new file mode 100644 index 00000000..191ac3c1 --- /dev/null +++ b/src/spec/stub/rails41/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Rails41 + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/src/spec/stub/rails41/config/application.rb b/src/spec/stub/rails41/config/application.rb new file mode 100644 index 00000000..73c653f4 --- /dev/null +++ b/src/spec/stub/rails41/config/application.rb @@ -0,0 +1,26 @@ +require File.expand_path('../boot', __FILE__) + +#require 'rails/all' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'sprockets/railtie' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails41 + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end diff --git a/src/spec/stub/rails41/config/boot.rb b/src/spec/stub/rails41/config/boot.rb new file mode 100644 index 00000000..20fa9d80 --- /dev/null +++ b/src/spec/stub/rails41/config/boot.rb @@ -0,0 +1,4 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/src/spec/stub/rails41/config/environment.rb b/src/spec/stub/rails41/config/environment.rb new file mode 100644 index 00000000..052dd73a --- /dev/null +++ b/src/spec/stub/rails41/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! \ No newline at end of file diff --git a/src/spec/stub/rails41/config/environments/development.rb b/src/spec/stub/rails41/config/environments/development.rb new file mode 100644 index 00000000..c8203c1a --- /dev/null +++ b/src/spec/stub/rails41/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load if config.respond_to?(:active_record) + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/src/spec/stub/rails41/config/environments/production.rb b/src/spec/stub/rails41/config/environments/production.rb new file mode 100644 index 00000000..b6f70024 --- /dev/null +++ b/src/spec/stub/rails41/config/environments/production.rb @@ -0,0 +1,82 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` has moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + #config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + #config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false if config.respond_to?(:active_record) +end diff --git a/src/spec/stub/rails41/config/initializers/assets.rb b/src/spec/stub/rails41/config/initializers/assets.rb new file mode 100644 index 00000000..d2f4ec33 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb b/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb new file mode 100644 index 00000000..59385cdf --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/src/spec/stub/rails41/config/initializers/cookies_serializer.rb b/src/spec/stub/rails41/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7a06a89f --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb b/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/src/spec/stub/rails41/config/initializers/inflections.rb b/src/spec/stub/rails41/config/initializers/inflections.rb new file mode 100644 index 00000000..ac033bf9 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/src/spec/stub/rails41/config/initializers/mime_types.rb b/src/spec/stub/rails41/config/initializers/mime_types.rb new file mode 100644 index 00000000..dc189968 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/src/spec/stub/rails41/config/initializers/session_store.rb b/src/spec/stub/rails41/config/initializers/session_store.rb new file mode 100644 index 00000000..080bcea9 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_rails41_session' diff --git a/src/spec/stub/rails41/config/initializers/wrap_parameters.rb b/src/spec/stub/rails41/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..33725e95 --- /dev/null +++ b/src/spec/stub/rails41/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/src/spec/stub/rails41/config/locales/en.yml b/src/spec/stub/rails41/config/locales/en.yml new file mode 100644 index 00000000..06539571 --- /dev/null +++ b/src/spec/stub/rails41/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/src/spec/stub/rails41/config/routes.rb b/src/spec/stub/rails41/config/routes.rb new file mode 100644 index 00000000..3f66539d --- /dev/null +++ b/src/spec/stub/rails41/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/src/spec/stub/rails41/config/secrets.yml b/src/spec/stub/rails41/config/secrets.yml new file mode 100644 index 00000000..fd32b050 --- /dev/null +++ b/src/spec/stub/rails41/config/secrets.yml @@ -0,0 +1,23 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a9f5a1ab3bfafbb54440df7a8ae935c708164c069e96564617ed1aa4667478afea1ac0e4af1eba9b178820ab56c4caa317d9816e0ecbb0fecdee55946e64e3d3 + +<% if ENV["SECRET_KEY_BASE"] %> +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> +<% else %> + +<% end %> diff --git a/src/spec/stub/rails41/db/seeds.rb b/src/spec/stub/rails41/db/seeds.rb new file mode 100644 index 00000000..4edb1e85 --- /dev/null +++ b/src/spec/stub/rails41/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/src/spec/stub/rails41/lib/assets/.keep b/src/spec/stub/rails41/lib/assets/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/lib/tasks/.keep b/src/spec/stub/rails41/lib/tasks/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/public/404.html b/src/spec/stub/rails41/public/404.html new file mode 100644 index 00000000..b612547f --- /dev/null +++ b/src/spec/stub/rails41/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/422.html b/src/spec/stub/rails41/public/422.html new file mode 100644 index 00000000..a21f82b3 --- /dev/null +++ b/src/spec/stub/rails41/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/500.html b/src/spec/stub/rails41/public/500.html new file mode 100644 index 00000000..061abc58 --- /dev/null +++ b/src/spec/stub/rails41/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/src/spec/stub/rails41/public/robots.txt b/src/spec/stub/rails41/public/robots.txt new file mode 100644 index 00000000..3c9c7c01 --- /dev/null +++ b/src/spec/stub/rails41/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/src/spec/stub/rails41/vendor/assets/javascripts/.keep b/src/spec/stub/rails41/vendor/assets/javascripts/.keep new file mode 100644 index 00000000..e69de29b diff --git a/src/spec/stub/rails41/vendor/assets/stylesheets/.keep b/src/spec/stub/rails41/vendor/assets/stylesheets/.keep new file mode 100644 index 00000000..e69de29b