Skip to content

Commit

Permalink
feat(Rails) support 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Apr 18, 2017
1 parent fc7b165 commit 698bcc5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Appraisals
Expand Up @@ -65,8 +65,8 @@ appraise "rails-5-no_sprockets" do
gem 'rails', '~> 5.0.0'
end

appraise "rails-5-sprockets_4" do
gem "rails", "~> 5.0.0"
appraise "rails-5.1-sprockets_4" do
gem "rails", "5.1.0.rc1"
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 5.0.0"
end
Expand Up @@ -3,7 +3,7 @@
source "http://rubygems.org"

gem "turbolinks", "~> 5.0.0"
gem "rails", "~> 5.0.0"
gem "rails", "5.1.0.rc1"
gem "sprockets", "~> 4.0.x"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion lib/react/rails/railtie.rb
Expand Up @@ -33,7 +33,7 @@ class Railtie < ::Rails::Railtie
end

# Rails checks these objects for changes:
app.reloaders << app.config.file_watcher.new([], reload_paths)
app.reloaders << app.config.file_watcher.new([], reload_paths) {}
# Reload renderers in dev when files change
config.to_prepare { React::ServerRendering.reset_pool }
end
Expand Down
3 changes: 2 additions & 1 deletion test/react/rails/pages_controller_test.rb
@@ -1,12 +1,13 @@
require 'test_helper'

class PagesControllerTest < ActionController::TestCase
include ParamsHelper
setup do
WebpackerHelpers.compile_if_missing
end

test 'renders successfully' do
get :show, id: 1
get :show, query_params(id: 1)
assert_equal(200, response.status)
end

Expand Down
11 changes: 11 additions & 0 deletions test/test_helper.rb
Expand Up @@ -101,3 +101,14 @@ def when_stateful_js_context_available
yield
end
end

module ParamsHelper
# Normalize params for Rails 5.1+
def query_params(params)
if Rails::VERSION.to_s > "5.0"
{params: params}
else
params
end
end
end

0 comments on commit 698bcc5

Please sign in to comment.