versioncake 4.0.2 → 4.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 +4 -4
- data/.github/workflows/ruby.yml +33 -0
- data/Appraisals +9 -3
- data/CHANGELOG.md +16 -1
- data/Gemfile.lock +25 -23
- data/README.md +13 -11
- data/SECURITY.md +9 -0
- data/gemfiles/rails5.0.gemfile.lock +26 -24
- data/gemfiles/rails5.2.gemfile.lock +36 -34
- data/gemfiles/rails6.0.gemfile +3 -3
- data/gemfiles/rails6.0.gemfile.lock +44 -40
- data/gemfiles/rails7.0.gemfile +9 -0
- data/gemfiles/rails7.0.gemfile.lock +127 -0
- data/lib/versioncake/response_strategy/http_content_type_strategy.rb +4 -2
- data/lib/versioncake/strategies/extraction_strategy.rb +11 -7
- data/lib/versioncake/version.rb +1 -1
- data/lib/versioncake/version_checker.rb +2 -1
- data/lib/versioncake/version_context_service.rb +1 -1
- data/lib/versioncake/versioned_request.rb +1 -1
- data/lib/versioncake/view_additions.rb +8 -88
- data/lib/versioncake/view_additions_rails5.rb +70 -0
- data/lib/versioncake/view_additions_rails6.rb +69 -0
- data/lib/versioncake/view_additions_rails7.rb +155 -0
- data/spec/integration/controller/unversioned_controller_spec.rb +1 -1
- data/spec/integration/view/render_spec.rb +8 -1
- data/spec/integration/view/view_additions_rails5_spec.rb +67 -0
- data/spec/integration/view/view_additions_rails6_spec.rb +44 -0
- data/spec/integration/view/view_additions_rails7_spec.rb +76 -0
- data/spec/unit/strategies/extraction_strategy_spec.rb +2 -2
- data/spec/unit/version_checker_spec.rb +1 -1
- data/spec/unit/versioned_request_spec.rb +0 -7
- metadata +16 -8
- data/.travis.yml +0 -20
- data/spec/integration/view/view_additions_spec.rb +0 -42
@@ -0,0 +1,67 @@
|
|
1
|
+
require './spec/rails_helper'
|
2
|
+
|
3
|
+
if ActionPack::VERSION::MAJOR == 5
|
4
|
+
describe ActionView::PathResolver do
|
5
|
+
let(:resolver) { ActionView::PathResolver.new }
|
6
|
+
|
7
|
+
context '#extract_handler_and_format_and_variant' do
|
8
|
+
subject do
|
9
|
+
resolver.extract_handler_and_format_and_variant("application.#{extension}")
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:variant) { subject[2].to_s }
|
13
|
+
let(:format) { subject[1].to_s }
|
14
|
+
let(:handler) { subject[0] }
|
15
|
+
|
16
|
+
context 'when only handler and format are present' do
|
17
|
+
let(:extension) { 'html.erb' }
|
18
|
+
|
19
|
+
it do
|
20
|
+
expect(format).to eq 'text/html'
|
21
|
+
expect(variant).to be_empty
|
22
|
+
expect(handler).to be_a ActionView::Template::Handlers::ERB
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when handler, format and version are present' do
|
27
|
+
let(:extension) { 'json.v1.jbuilder' }
|
28
|
+
|
29
|
+
it do
|
30
|
+
expect(format).to eq 'application/json'
|
31
|
+
expect(variant).to be_empty
|
32
|
+
expect(handler).to be_a ActionView::Template::Handlers::Raw
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when handler, format and locale are present' do
|
37
|
+
let(:extension) { 'en.json.jbuilder' }
|
38
|
+
|
39
|
+
it do
|
40
|
+
expect(format).to eq 'application/json'
|
41
|
+
expect(variant).to be_empty
|
42
|
+
expect(handler).to be_a ActionView::Template::Handlers::Raw
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when handler, format, locale and version are present' do
|
47
|
+
let(:extension) { 'en.json.v1.jbuilder' }
|
48
|
+
|
49
|
+
it do
|
50
|
+
expect(format).to eq 'application/json'
|
51
|
+
expect(variant).to be_empty
|
52
|
+
expect(handler).to be_a ActionView::Template::Handlers::Raw
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when handler, format, variant and version are present' do
|
57
|
+
let(:extension) { 'json+tablet.v1.jbuilder' }
|
58
|
+
|
59
|
+
it do
|
60
|
+
expect(format).to eq 'application/json'
|
61
|
+
expect(variant).to eq 'tablet'
|
62
|
+
expect(handler).to be_a ActionView::Template::Handlers::Raw
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require './spec/rails_helper'
|
2
|
+
|
3
|
+
if ActionPack::VERSION::MAJOR == 6
|
4
|
+
describe ActionView::PathResolver do
|
5
|
+
let(:resolver) { ActionView::PathResolver.new }
|
6
|
+
|
7
|
+
context '#extract_handler_and_format' do
|
8
|
+
subject(:template_format) do
|
9
|
+
_, format = resolver.extract_handler_and_format("application.#{template_extension}", nil)
|
10
|
+
format.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when only handler and format are present' do
|
14
|
+
let(:template_extension) { 'html.erb' }
|
15
|
+
|
16
|
+
it { expect(template_format).to eq 'text/html' }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when handler, format and version are present' do
|
20
|
+
let(:template_extension) { 'json.v1.jbuilder' }
|
21
|
+
|
22
|
+
it { expect(template_format).to eq 'application/json' }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when handler, format and locale are present' do
|
26
|
+
let(:template_extension) { 'en.json.jbuilder' }
|
27
|
+
|
28
|
+
it { expect(template_format).to eq 'application/json' }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when handler, format, locale and version are present' do
|
32
|
+
let(:template_extension) { 'en.json.v1.jbuilder' }
|
33
|
+
|
34
|
+
it { expect(template_format).to eq 'application/json' }
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when handler, format, variant and version are present' do
|
38
|
+
let(:template_extension) { 'application.json+tablet.v1.jbuilder' }
|
39
|
+
|
40
|
+
it { expect(template_format).to eq 'application/json' }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require './spec/rails_helper'
|
2
|
+
|
3
|
+
if ActionPack::VERSION::MAJOR == 7
|
4
|
+
describe ActionView::Resolver::PathParser do
|
5
|
+
let(:resolver) { ActionView::Resolver::PathParser.new }
|
6
|
+
|
7
|
+
context '#extract_handler_and_format' do
|
8
|
+
subject(:parsed_path) do
|
9
|
+
resolver.parse("application.#{template_extension}")
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when only handler and format are present' do
|
13
|
+
let(:template_extension) { 'html.erb' }
|
14
|
+
|
15
|
+
it do
|
16
|
+
expect(parsed_path.details.format).to eq :html
|
17
|
+
expect(parsed_path.details.handler).to eq :erb
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when handler, format and version are present' do
|
22
|
+
let(:template_extension) { 'json.v1.builder' }
|
23
|
+
|
24
|
+
it do
|
25
|
+
expect(parsed_path.details.format).to eq :json
|
26
|
+
expect(parsed_path.details.handler).to eq :builder
|
27
|
+
expect(parsed_path.details.version).to eq :v1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when handler, format and locale are present' do
|
32
|
+
let(:template_extension) { 'en.json.builder' }
|
33
|
+
|
34
|
+
it do
|
35
|
+
expect(parsed_path.details.locale).to eq :en
|
36
|
+
expect(parsed_path.details.format).to eq :json
|
37
|
+
expect(parsed_path.details.handler).to eq :builder
|
38
|
+
expect(parsed_path.details.version).to eq nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when handler, format, locale and version are present' do
|
43
|
+
let(:template_extension) { 'en.json.v1.builder' }
|
44
|
+
|
45
|
+
it do
|
46
|
+
expect(parsed_path.details.format).to eq :json
|
47
|
+
expect(parsed_path.details.handler).to eq :builder
|
48
|
+
expect(parsed_path.details.version).to eq :v1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when handler, format, variant and version are present' do
|
53
|
+
let(:template_extension) { 'json+tablet.v1.builder' }
|
54
|
+
|
55
|
+
it do
|
56
|
+
expect(parsed_path.details.variant).to eq :tablet
|
57
|
+
expect(parsed_path.details.format).to eq :json
|
58
|
+
expect(parsed_path.details.handler).to eq :builder
|
59
|
+
expect(parsed_path.details.version).to eq :v1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when handler, format, variant, locale and version are present' do
|
64
|
+
let(:template_extension) { 'en.json+tablet.v1.builder' }
|
65
|
+
|
66
|
+
it do
|
67
|
+
expect(parsed_path.details.locale).to eq :en
|
68
|
+
expect(parsed_path.details.variant).to eq :tablet
|
69
|
+
expect(parsed_path.details.format).to eq :json
|
70
|
+
expect(parsed_path.details.handler).to eq :builder
|
71
|
+
expect(parsed_path.details.version).to eq :v1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -60,13 +60,13 @@ describe VersionCake::ExtractionStrategy do
|
|
60
60
|
it "it fails to create a custom strategy for a proc with no parameters" do
|
61
61
|
expect do
|
62
62
|
VersionCake::ExtractionStrategy.lookup(lambda{})
|
63
|
-
end.to raise_error(
|
63
|
+
end.to raise_error(VersionCake::ExtractionStrategy::InvalidStrategyError)
|
64
64
|
end
|
65
65
|
|
66
66
|
it "it raises error when no strategy is found" do
|
67
67
|
expect do
|
68
68
|
VersionCake::ExtractionStrategy.lookup(:fake_extraction)
|
69
|
-
end.to raise_error(
|
69
|
+
end.to raise_error(VersionCake::ExtractionStrategy::InvalidStrategyError)
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '.list' do
|
@@ -24,12 +24,5 @@ describe VersionCake::VersionedRequest do
|
|
24
24
|
it { expect(versioned_request.version).to be_nil }
|
25
25
|
it { expect(versioned_request.failed).to be_falsey }
|
26
26
|
end
|
27
|
-
|
28
|
-
context 'with a strategy failure' do
|
29
|
-
let(:strategies) { [ lambda { raise 'Failed extraction' } ] }
|
30
|
-
|
31
|
-
it { expect(versioned_request.version).to be_nil }
|
32
|
-
it { expect(versioned_request.failed).to be_truthy }
|
33
|
-
end
|
34
27
|
end
|
35
28
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versioncake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Jones
|
8
8
|
- Ben Willis
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -146,9 +146,9 @@ executables:
|
|
146
146
|
extensions: []
|
147
147
|
extra_rdoc_files: []
|
148
148
|
files:
|
149
|
+
- ".github/workflows/ruby.yml"
|
149
150
|
- ".gitignore"
|
150
151
|
- ".rspec"
|
151
|
-
- ".travis.yml"
|
152
152
|
- Appraisals
|
153
153
|
- CHANGELOG.md
|
154
154
|
- CONTRIBUTING.md
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- README.md
|
158
158
|
- RELEASE.md
|
159
159
|
- Rakefile
|
160
|
+
- SECURITY.md
|
160
161
|
- bin/versioncake
|
161
162
|
- gemfiles/.bundle/config
|
162
163
|
- gemfiles/rails5.0.gemfile
|
@@ -165,6 +166,8 @@ files:
|
|
165
166
|
- gemfiles/rails5.2.gemfile.lock
|
166
167
|
- gemfiles/rails6.0.gemfile
|
167
168
|
- gemfiles/rails6.0.gemfile.lock
|
169
|
+
- gemfiles/rails7.0.gemfile
|
170
|
+
- gemfiles/rails7.0.gemfile.lock
|
168
171
|
- images/versioncake-logo450x100.png
|
169
172
|
- lib/generators/templates/versioncake.rb
|
170
173
|
- lib/generators/versioncake/install_generator.rb
|
@@ -195,6 +198,9 @@ files:
|
|
195
198
|
- lib/versioncake/versioned_resource.rb
|
196
199
|
- lib/versioncake/versioned_response_service.rb
|
197
200
|
- lib/versioncake/view_additions.rb
|
201
|
+
- lib/versioncake/view_additions_rails5.rb
|
202
|
+
- lib/versioncake/view_additions_rails6.rb
|
203
|
+
- lib/versioncake/view_additions_rails7.rb
|
198
204
|
- spec/fixtures/partials/_versioned.erb
|
199
205
|
- spec/fixtures/partials/_versioned.v1.erb
|
200
206
|
- spec/fixtures/partials/_versioned.v2.erb
|
@@ -213,7 +219,9 @@ files:
|
|
213
219
|
- spec/integration/controller/unversioned_controller_spec.rb
|
214
220
|
- spec/integration/rack/middleware_regression_spec.rb
|
215
221
|
- spec/integration/view/render_spec.rb
|
216
|
-
- spec/integration/view/
|
222
|
+
- spec/integration/view/view_additions_rails5_spec.rb
|
223
|
+
- spec/integration/view/view_additions_rails6_spec.rb
|
224
|
+
- spec/integration/view/view_additions_rails7_spec.rb
|
217
225
|
- spec/rails_helper.rb
|
218
226
|
- spec/spec_helper.rb
|
219
227
|
- spec/test_app/Rakefile
|
@@ -253,7 +261,7 @@ homepage: http://bwillis.github.io/versioncake
|
|
253
261
|
licenses:
|
254
262
|
- MIT
|
255
263
|
metadata: {}
|
256
|
-
post_install_message:
|
264
|
+
post_install_message:
|
257
265
|
rdoc_options: []
|
258
266
|
require_paths:
|
259
267
|
- lib
|
@@ -268,8 +276,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
276
|
- !ruby/object:Gem::Version
|
269
277
|
version: '0'
|
270
278
|
requirements: []
|
271
|
-
rubygems_version: 3.
|
272
|
-
signing_key:
|
279
|
+
rubygems_version: 3.1.6
|
280
|
+
signing_key:
|
273
281
|
specification_version: 4
|
274
282
|
summary: Easily render versions of your rails views.
|
275
283
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
before_install: gem install bundler && bundle update --bundler
|
4
|
-
|
5
|
-
rvm:
|
6
|
-
- 2.3.3
|
7
|
-
- 2.4.7
|
8
|
-
- 2.5.6
|
9
|
-
|
10
|
-
gemfile:
|
11
|
-
- gemfiles/rails5.0.gemfile
|
12
|
-
- gemfiles/rails5.2.gemfile
|
13
|
-
- gemfiles/rails6.0.gemfile
|
14
|
-
|
15
|
-
matrix:
|
16
|
-
exclude:
|
17
|
-
- rvm: 2.3.3
|
18
|
-
gemfile: gemfiles/rails6.0.gemfile
|
19
|
-
- rvm: 2.4.7
|
20
|
-
gemfile: gemfiles/rails6.0.gemfile
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require './spec/rails_helper'
|
2
|
-
|
3
|
-
describe ActionView::PathResolver do
|
4
|
-
let(:resolver) { ActionView::PathResolver.new }
|
5
|
-
|
6
|
-
context '#extract_handler_and_format' do
|
7
|
-
subject(:template_format) do
|
8
|
-
_, format = resolver.extract_handler_and_format("application.#{template_extension}", nil)
|
9
|
-
format.to_s
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'when only handler and format are present' do
|
13
|
-
let(:template_extension) { 'html.erb' }
|
14
|
-
|
15
|
-
it { expect(template_format).to eq 'text/html' }
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when handler, format and version are present' do
|
19
|
-
let(:template_extension) { 'json.v1.jbuilder' }
|
20
|
-
|
21
|
-
it { expect(template_format).to eq 'application/json' }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when handler, format and locale are present' do
|
25
|
-
let(:template_extension) { 'en.json.jbuilder' }
|
26
|
-
|
27
|
-
it { expect(template_format).to eq 'application/json' }
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when handler, format, locale and version are present' do
|
31
|
-
let(:template_extension) { 'en.json.v1.jbuilder' }
|
32
|
-
|
33
|
-
it { expect(template_format).to eq 'application/json' }
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when handler, format, variant and version are present' do
|
37
|
-
let(:template_extension) { 'application.json+tablet.v1.jbuilder' }
|
38
|
-
|
39
|
-
it { expect(template_format).to eq 'application/json' }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|