Skip to content

Commit 698bcc5

Browse files
committed
feat(Rails) support 5.1
1 parent fc7b165 commit 698bcc5

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

Appraisals

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ appraise "rails-5-no_sprockets" do
6565
gem 'rails', '~> 5.0.0'
6666
end
6767

68-
appraise "rails-5-sprockets_4" do
69-
gem "rails", "~> 5.0.0"
68+
appraise "rails-5.1-sprockets_4" do
69+
gem "rails", "5.1.0.rc1"
7070
gem "sprockets", "~> 4.0.x"
7171
gem "turbolinks", "~> 5.0.0"
7272
end

gemfiles/rails_5_sprockets_4.gemfile renamed to gemfiles/rails_5.1_sprockets_4.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
source "http://rubygems.org"
44

55
gem "turbolinks", "~> 5.0.0"
6-
gem "rails", "~> 5.0.0"
6+
gem "rails", "5.1.0.rc1"
77
gem "sprockets", "~> 4.0.x"
88

99
gemspec :path => "../"

lib/react/rails/railtie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Railtie < ::Rails::Railtie
3333
end
3434

3535
# Rails checks these objects for changes:
36-
app.reloaders << app.config.file_watcher.new([], reload_paths)
36+
app.reloaders << app.config.file_watcher.new([], reload_paths) {}
3737
# Reload renderers in dev when files change
3838
config.to_prepare { React::ServerRendering.reset_pool }
3939
end

test/react/rails/pages_controller_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
require 'test_helper'
22

33
class PagesControllerTest < ActionController::TestCase
4+
include ParamsHelper
45
setup do
56
WebpackerHelpers.compile_if_missing
67
end
78

89
test 'renders successfully' do
9-
get :show, id: 1
10+
get :show, query_params(id: 1)
1011
assert_equal(200, response.status)
1112
end
1213

test/test_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,14 @@ def when_stateful_js_context_available
101101
yield
102102
end
103103
end
104+
105+
module ParamsHelper
106+
# Normalize params for Rails 5.1+
107+
def query_params(params)
108+
if Rails::VERSION.to_s > "5.0"
109+
{params: params}
110+
else
111+
params
112+
end
113+
end
114+
end

0 commit comments

Comments
 (0)