rails-rfc6570 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rails/rfc6570.rb +8 -2
- data/lib/rails/rfc6570/version.rb +1 -1
- data/spec/dummy/log/test.log +2600 -0
- data/spec/rfc6570_spec.rb +25 -1
- metadata +3 -3
data/spec/rfc6570_spec.rb
CHANGED
@@ -28,6 +28,7 @@ class APIController < ApplicationController
|
|
28
28
|
rfc6570_params action: [:param1, :param2]
|
29
29
|
def action
|
30
30
|
render json: {
|
31
|
+
ref: action_url,
|
31
32
|
template: action_rfc6570,
|
32
33
|
template_url: action_url_rfc6570,
|
33
34
|
template_path: action_path_rfc6570,
|
@@ -35,6 +36,14 @@ class APIController < ApplicationController
|
|
35
36
|
expand: test6_rfc6570.expand(capture: %w(a b), title: 'TITLE')
|
36
37
|
}
|
37
38
|
end
|
39
|
+
|
40
|
+
def default_url_options
|
41
|
+
if (root = request.headers['__OSN']).present?
|
42
|
+
super.merge original_script_name: root
|
43
|
+
else
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
38
47
|
end
|
39
48
|
|
40
49
|
describe Rails::RFC6570, type: :request do
|
@@ -78,7 +87,7 @@ describe Rails::RFC6570, type: :request do
|
|
78
87
|
end
|
79
88
|
|
80
89
|
context 'action' do
|
81
|
-
before { get '/action' }
|
90
|
+
before { get '/action', headers: headers }
|
82
91
|
|
83
92
|
it 'should include URL helpers' do
|
84
93
|
expect(response.status).to eq 200
|
@@ -103,5 +112,20 @@ describe Rails::RFC6570, type: :request do
|
|
103
112
|
it 'should allow to return and render expanded templates' do
|
104
113
|
expect(json['expand']).to eq "#{host}/path/a/b/TITLE"
|
105
114
|
end
|
115
|
+
|
116
|
+
context 'with origin_script_name' do
|
117
|
+
let(:headers) { {'__OSN' => '/fuubar'} }
|
118
|
+
|
119
|
+
before do
|
120
|
+
if Rails::VERSION::MAJOR >= 5
|
121
|
+
# Consistency check with normal URL helper
|
122
|
+
expect(json['ref']).to eq "#{host}/fuubar/action"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'prefixes origin script name' do
|
127
|
+
expect(json['template']).to eq "#{host}/fuubar/action{?param1,param2}"
|
128
|
+
end
|
129
|
+
end
|
106
130
|
end
|
107
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-rfc6570
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.6.
|
126
|
+
rubygems_version: 2.6.13
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Pragmatical access to your Rails routes as RFC6570 URI templates.
|