Skip to content

Commit 2a09611

Browse files
authored
Merge pull request #697 from reactjs/rails-5-1
feat(Rails) support 5.1
2 parents 5a6612a + 4af6cae commit 2a09611

File tree

8 files changed

+23
-11
lines changed

8 files changed

+23
-11
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ gemfile:
2121
- gemfiles/rails_4.2_sprockets_2.gemfile
2222
- gemfiles/rails_4.2_sprockets_3.gemfile
2323
- gemfiles/rails_5_no_sprockets.gemfile
24-
- gemfiles/rails_5_sprockets_4.gemfile
24+
- gemfiles/rails_5.1_sprockets_4.gemfile
2525

2626
matrix:
2727
fast_finish: true
@@ -43,7 +43,7 @@ matrix:
4343
- rvm: 2.1
4444
gemfile: gemfiles/rails_5_no_sprockets.gemfile
4545
- rvm: 2.1
46-
gemfile: gemfiles/rails_5_sprockets_4.gemfile
46+
gemfile: gemfiles/rails_5.1_sprockets_4.gemfile
4747
- rvm: jruby-9.0.1.0
4848
gemfile: gemfiles/rails_4.0.gemfile
4949
- rvm: jruby-9.0.1.0

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/dummy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"rails-erb-loader": "^4.0.0",
2222
"react": "^15.4.2",
2323
"react-dom": "^15.4.2",
24-
"react_ujs": "^1.0.0",
24+
"react_ujs": "^2.0.2",
2525
"sass-loader": "^6.0.3",
2626
"style-loader": "^0.16.1",
2727
"webpack": "^2.3.3",

test/dummy/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,9 +3450,9 @@ react@^15.4.2:
34503450
loose-envify "^1.1.0"
34513451
object-assign "^4.1.0"
34523452

3453-
react_ujs@^1.0.0:
3454-
version "1.0.0"
3455-
resolved "https://registry.yarnpkg.com/react_ujs/-/react_ujs-1.0.0.tgz#33fbae8cd949fbdd28914d7a0b69bf3c078aa4be"
3453+
react_ujs@^2.0.2:
3454+
version "2.0.2"
3455+
resolved "https://registry.yarnpkg.com/react_ujs/-/react_ujs-2.0.2.tgz#0020f38fa2e47a04c03faa080325324bfa6d1f0b"
34563456

34573457
read-cache@^1.0.0:
34583458
version "1.0.0"

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::MAJOR > 4
109+
{params: params}
110+
else
111+
params
112+
end
113+
end
114+
end

0 commit comments

Comments
 (0)