Skip to content

Commit 8c1be8f

Browse files
committed
Write test for #743
1 parent b1eafb7 commit 8c1be8f

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

test/dummy_sprockets/app/assets/config/manifest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
//= link application.js
44
//= link turbolinks_only.js
55
//= link application.css
6+
//= link app_no_turbolinks.js
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//= require react
2+
//= require react_ujs
3+
//= require_tree ./components

test/dummy_sprockets/app/controllers/pages_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ def show
1818
js_context.exec("global.ctx = undefined;")
1919
end
2020
end
21+
22+
def no_turbolinks
23+
@prerender = false
24+
render :show, layout: 'app_no_turbolinks'
25+
end
2126
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Dummy</title>
5+
<%= javascript_include_tag "app_no_turbolinks" %>
6+
<%= csrf_meta_tags %>
7+
</head>
8+
<body>
9+
10+
<%= yield %>
11+
12+
</body>
13+
</html>

test/dummy_sprockets/config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Dummy::Application.routes.draw do
2+
get 'no-turbolinks', to: 'pages#no_turbolinks'
23
resources :pages, only: [:show]
34
resources :server, only: [:show] do
45
collection do

test/react/rails/react_rails_ujs_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def refute_greeting(page, greeting)
101101
assert_greeting(page, 'Hello Bob')
102102
end
103103

104+
test 'react_ujs works without Turbolinks' do # Fixes #743
105+
visit '/no-turbolinks'
106+
assert page.execute_script('ReactRailsUJS.detectEvents()')
107+
end
108+
104109
test 'react_ujs can unmount/mount using a selector reference for a component parent' do
105110
visit '/pages/1'
106111
assert_greeting(page, 'Hello Bob')

0 commit comments

Comments
 (0)