inertia_rails 1.7.0 → 1.9.2
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 +4 -4
- data/.github/workflows/push.yml +1 -1
- data/Appraisals +4 -0
- data/CHANGELOG.md +21 -0
- data/app/controllers/inertia_rails/static_controller.rb +7 -0
- data/gemfiles/rails_6.1.gemfile +7 -0
- data/inertia_rails.gemspec +1 -0
- data/lib/inertia_rails.rb +1 -0
- data/lib/inertia_rails/controller.rb +18 -4
- data/lib/inertia_rails/lazy.rb +23 -21
- data/lib/inertia_rails/rspec.rb +7 -1
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/patches/mapper.rb +8 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d7a55c30678d9984236bdca8442ff34268cb09ff8795560d0506678acf9ab8
|
4
|
+
data.tar.gz: 48308b96e0e2cf06c70027649acc8e992f280743fd5cae05c70a49c4d8ec343e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ab3b00e2ee6a44649924fd60aefad32bd5bd33621a12c45ddb692f49d7220a4f1a3837334d983ce614a30c9144249c23f280918b8fbc9b75aef2f97cfad04d
|
7
|
+
data.tar.gz: de4d10ec3200f4d45a50c2a1cb2abcc479182f4cee135b9401f43679ad1e296031c644982b9d2fa5e5a5875f1fe909b8dfcda941e933927028b0f7cbdbbb8d97
|
data/.github/workflows/push.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.9.2] - 2021-02-23
|
8
|
+
|
9
|
+
* Improve method for detecting whether a user used the RSpec helpers without adding `inertia: true` to the spec
|
10
|
+
* Emit a warning when expecting an Inertia response in RSpec and never reaching a `render inertia:` call
|
11
|
+
|
12
|
+
## [1.9.1] - 2021-02-10
|
13
|
+
|
14
|
+
* Define `redirect_to` and `redirect_back` as public methods for compatibility with other code using them
|
15
|
+
|
16
|
+
## [1.9.0] - 2021-01-17
|
17
|
+
|
18
|
+
* Added the same inertia awareness that redirect_to has to redirect_back
|
19
|
+
|
20
|
+
## [1.8.0] - 2020-12-08
|
21
|
+
|
22
|
+
* Add `inertia` route helper feature
|
23
|
+
|
24
|
+
## [1.7.1] - 2020-11-24
|
25
|
+
|
26
|
+
* Fix the definition for InertiaRails::Lazy to avoid an uninitialized constant error when booting an application.
|
27
|
+
|
7
28
|
## [1.7.0] - 2020-11-24
|
8
29
|
|
9
30
|
* Add support for "lazy" props while rendering. These are props that never compute on the initial page load. The only render during a partial update that calls for them explicitly.
|
data/inertia_rails.gemspec
CHANGED
data/lib/inertia_rails.rb
CHANGED
@@ -20,17 +20,31 @@ module InertiaRails
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def redirect_to(options = {}, response_options = {})
|
24
|
+
capture_inertia_errors(response_options)
|
25
|
+
super(options, response_options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def redirect_back(fallback_location:, allow_other_host: true, **options)
|
29
|
+
capture_inertia_errors(options)
|
30
|
+
super(
|
31
|
+
fallback_location: fallback_location,
|
32
|
+
allow_other_host: allow_other_host,
|
33
|
+
**options,
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
23
39
|
def inertia_location(url)
|
24
40
|
headers['X-Inertia-Location'] = url
|
25
41
|
head :conflict
|
26
42
|
end
|
27
43
|
|
28
|
-
def
|
29
|
-
if (inertia_errors =
|
44
|
+
def capture_inertia_errors(options)
|
45
|
+
if (inertia_errors = options.dig(:inertia, :errors))
|
30
46
|
session[:inertia_errors] = inertia_errors
|
31
47
|
end
|
32
|
-
|
33
|
-
super(options, response_options)
|
34
48
|
end
|
35
49
|
end
|
36
50
|
end
|
data/lib/inertia_rails/lazy.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module InertiaRails
|
2
|
+
class Lazy
|
3
|
+
def initialize(value = nil, &block)
|
4
|
+
@value = value
|
5
|
+
@block = block
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def call
|
9
|
+
to_proc.call
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
def to_proc
|
13
|
+
# This is called by controller.instance_exec, which changes self to the
|
14
|
+
# controller instance. That makes the instance variables unavailable to the
|
15
|
+
# proc via closure. Copying the instance variables to local variables before
|
16
|
+
# the proc is returned keeps them in scope for the returned proc.
|
17
|
+
value = @value
|
18
|
+
block = @block
|
19
|
+
if value.respond_to?(:call)
|
20
|
+
value
|
21
|
+
elsif value
|
22
|
+
Proc.new { value }
|
23
|
+
else
|
24
|
+
block
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/inertia_rails/rspec.rb
CHANGED
@@ -35,6 +35,9 @@ module InertiaRails
|
|
35
35
|
def inertia
|
36
36
|
raise 'Inertia test helpers aren\'t set up! Make sure you add inertia: true to describe blocks using inertia tests.' unless inertia_tests_setup?
|
37
37
|
|
38
|
+
if @_inertia_render_wrapper.nil? && !::RSpec.configuration.inertia[:skip_missing_renderer_warnings]
|
39
|
+
warn 'WARNING: the test never created an Inertia renderer. Maybe the code wasn\'t able to reach a `render inertia:` call? If this was intended, or you don\'t want to see this message, set ::RSpec.configuration.inertia[:skip_missing_renderer_warnings] = true'
|
40
|
+
end
|
38
41
|
@_inertia_render_wrapper
|
39
42
|
end
|
40
43
|
|
@@ -49,7 +52,7 @@ module InertiaRails
|
|
49
52
|
protected
|
50
53
|
|
51
54
|
def inertia_tests_setup?
|
52
|
-
|
55
|
+
::RSpec.current_example.metadata.fetch(:inertia, false)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
@@ -57,6 +60,9 @@ end
|
|
57
60
|
|
58
61
|
RSpec.configure do |config|
|
59
62
|
config.include ::InertiaRails::RSpec::Helpers
|
63
|
+
config.add_setting :inertia, default: {
|
64
|
+
skip_missing_renderer_warnings: false
|
65
|
+
}
|
60
66
|
|
61
67
|
config.before(:each, inertia: true) do
|
62
68
|
new_renderer = InertiaRails::Renderer.method(:new)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inertia_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Knoles
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -110,6 +110,20 @@ dependencies:
|
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: responders
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
113
127
|
description:
|
114
128
|
email:
|
115
129
|
- brain@bellawatt.com
|
@@ -129,6 +143,7 @@ files:
|
|
129
143
|
- LICENSE.txt
|
130
144
|
- README.md
|
131
145
|
- Rakefile
|
146
|
+
- app/controllers/inertia_rails/static_controller.rb
|
132
147
|
- app/views/inertia.html.erb
|
133
148
|
- bin/console
|
134
149
|
- bin/setup
|
@@ -136,6 +151,7 @@ files:
|
|
136
151
|
- gemfiles/rails_5.1.gemfile
|
137
152
|
- gemfiles/rails_5.2.gemfile
|
138
153
|
- gemfiles/rails_6.0.gemfile
|
154
|
+
- gemfiles/rails_6.1.gemfile
|
139
155
|
- inertia_rails.gemspec
|
140
156
|
- lib/inertia_rails.rb
|
141
157
|
- lib/inertia_rails/controller.rb
|
@@ -150,6 +166,7 @@ files:
|
|
150
166
|
- lib/patches/debug_exceptions.rb
|
151
167
|
- lib/patches/debug_exceptions/patch-5-0.rb
|
152
168
|
- lib/patches/debug_exceptions/patch-5-1.rb
|
169
|
+
- lib/patches/mapper.rb
|
153
170
|
- lib/patches/request.rb
|
154
171
|
homepage: https://github.com/inertiajs/inertia-rails
|
155
172
|
licenses:
|