turbolinks 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fc429267a56c52d8ad8e261111ada8235379ad3
4
- data.tar.gz: 4ff6f9fbf881ecae991b28c0db0709922143af4f
3
+ metadata.gz: 3d6b9a579870be137cebb067ea600acc34196de8
4
+ data.tar.gz: 8d42fb2b61a68595ef627de80ab4e0e899769d8e
5
5
  SHA512:
6
- metadata.gz: aa72fe1ce6bd6de809645f166696bc23d1da44de6e2b43263dc13477a52057c1c3455c3f7ce61bcc415f4493f5ff8d4946e09dd2ab0e2c3fcc36b6e3d8b751c7
7
- data.tar.gz: db5085ab615012760ed1a9d2e31c6aaf33de08a4494788cfa40af5167d8dfdf3fa115ec79f12020e9bc1e59b5d6d063750c325bcdb5d20fa221330ae18f7d3f6
6
+ metadata.gz: f02d8828f9b479fb9e803f7894605e2a55b3a3770ed106afaeb7de2896232af7e310313237365738f8c591278b267be1983cf6530935b2d2778af52268e005dd
7
+ data.tar.gz: 9ac399b5e08349a4e4166c8859448a109e9b13f5377993a6c467b2cccdebbcd6a8ebe86d1b7a2aeec2bc61d1fc20f43ed7d2f12ef4f17357d3180ebe2769de41
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2016 Basecamp, LLC
1
+ Copyright 2018 Basecamp, LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,5 +1,6 @@
1
1
  require 'turbolinks/version'
2
2
  require 'turbolinks/redirection'
3
+ require 'turbolinks/assertions'
3
4
  require 'turbolinks/source'
4
5
 
5
6
  module Turbolinks
@@ -14,12 +15,14 @@ module Turbolinks
14
15
  class Engine < ::Rails::Engine
15
16
  config.turbolinks = ActiveSupport::OrderedOptions.new
16
17
  config.turbolinks.auto_include = true
17
- config.assets.paths += [Turbolinks::Source.asset_path]
18
+ config.assets.paths += [Turbolinks::Source.asset_path] if config.respond_to?(:assets)
18
19
 
19
20
  initializer :turbolinks do |app|
20
21
  ActiveSupport.on_load(:action_controller) do
21
22
  if app.config.turbolinks.auto_include
22
23
  include Controller
24
+
25
+ ::ActionDispatch::Assertions.include ::Turbolinks::Assertions
23
26
  end
24
27
  end
25
28
  end
@@ -0,0 +1,46 @@
1
+ module Turbolinks
2
+ module Assertions
3
+ TURBOLINKS_VISIT = /Turbolinks\.visit\("([^"]+)", {"action":"([^"]+)"}\)/
4
+
5
+ def assert_redirected_to(options = {}, message = nil)
6
+ if turbolinks_request?
7
+ assert_turbolinks_visited(options, message)
8
+ else
9
+ super
10
+ end
11
+ end
12
+
13
+ def assert_turbolinks_visited(options = {}, message = nil)
14
+ assert_response(:ok, message)
15
+ assert_equal("text/javascript", response.content_type)
16
+
17
+ visit_location, visit_action = turbolinks_visit_location_and_action
18
+
19
+ redirect_is = normalize_argument_to_redirection(visit_location)
20
+ redirect_expected = normalize_argument_to_redirection(options)
21
+
22
+ message ||= "Expected response to be a Turbolinks visit to <#{redirect_expected}> but was a visit to <#{redirect_is}>"
23
+ assert_operator redirect_expected, :===, redirect_is, message
24
+ end
25
+
26
+ # Rough heuristic to detect whether this was a Turbolinks request:
27
+ # non-GET request with a text/javascript response.
28
+ #
29
+ # Technically we'd check that Turbolinks-Referrer request header is
30
+ # also set, but that'd require us to pass the header from post/patch/etc
31
+ # test methods by overriding them to provide a `turbolinks:` option.
32
+ #
33
+ # We can't check `request.xhr?` here, either, since the X-Requested-With
34
+ # header is cleared after controller action processing to prevent it
35
+ # from leaking into subsequent requests.
36
+ def turbolinks_request?
37
+ !request.get? && response.content_type == "text/javascript"
38
+ end
39
+
40
+ def turbolinks_visit_location_and_action
41
+ if response.body =~ TURBOLINKS_VISIT
42
+ [ $1, $2 ]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Turbolinks
2
- VERSION = '5.0.1'
2
+ VERSION = '5.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbolinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-31 00:00:00.000000000 Z
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turbolinks-source
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '5.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '5.1'
27
27
  description: Rails engine for Turbolinks 5 support
28
28
  email: david@loudthinking.com
29
29
  executables: []
@@ -33,6 +33,7 @@ files:
33
33
  - LICENSE
34
34
  - README.md
35
35
  - lib/turbolinks.rb
36
+ - lib/turbolinks/assertions.rb
36
37
  - lib/turbolinks/redirection.rb
37
38
  - lib/turbolinks/version.rb
38
39
  homepage: https://github.com/turbolinks/turbolinks
@@ -55,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
56
  version: '0'
56
57
  requirements: []
57
58
  rubyforge_project:
58
- rubygems_version: 2.4.8
59
+ rubygems_version: 2.6.13
59
60
  signing_key:
60
61
  specification_version: 4
61
62
  summary: Turbolinks makes navigating your web application faster