gh 0.12.2 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gh/normalizer.rb +1 -1
- data/lib/gh/version.rb +1 -1
- data/spec/normalizer_spec.rb +23 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6111e2fa8dbc01a5d52b267e44617e5096a152c7
|
4
|
+
data.tar.gz: fbd8a0a0658ba302b5901e35d37f07c20463b6fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcc5eb0e275f4e0c268459167d400edb9959f7a5163eeacbd937f381979b7d3ca3672d96ebb70fd5ea7fb9cb2b5ca3e73e4643bb07f86df8704e6824734ebde1
|
7
|
+
data.tar.gz: 3d1088dfd9ce6c426f6821f50edfd847f8b21bb5d8a71f82e7d17a42744107950889c1436f75944e4bec460e90bc87df467adb38e453e6b769d3a403a1892429
|
data/lib/gh/normalizer.rb
CHANGED
@@ -79,7 +79,7 @@ module GH
|
|
79
79
|
when "blog"
|
80
80
|
set_link(hash, key, value)
|
81
81
|
when "url"
|
82
|
-
type =
|
82
|
+
type = value.to_s.start_with?(api_host.to_s) ? "self" : "html"
|
83
83
|
set_link(hash, type, value)
|
84
84
|
when /^(.+)_url$/
|
85
85
|
set_link(hash, $1, value)
|
data/lib/gh/version.rb
CHANGED
data/spec/normalizer_spec.rb
CHANGED
@@ -4,16 +4,16 @@ describe GH::Normalizer do
|
|
4
4
|
before { subject.backend = GH::MockBackend.new }
|
5
5
|
|
6
6
|
def normalize(payload)
|
7
|
-
data['/payload'] = payload
|
7
|
+
data[subject.path_for('/payload')] = payload
|
8
8
|
end
|
9
9
|
|
10
10
|
def with_headers(headers = {})
|
11
11
|
response = GH::Response.new("{}", headers)
|
12
|
-
data['/payload'], response.data = response, data['/payload']
|
12
|
+
data[subject.path_for('/payload')], response.data = response, data[subject.path_for('/payload')]
|
13
13
|
end
|
14
14
|
|
15
15
|
def normalized
|
16
|
-
subject['/payload']
|
16
|
+
subject[subject.path_for('/payload')]
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'is set up properly' do
|
@@ -285,17 +285,35 @@ describe GH::Normalizer do
|
|
285
285
|
end
|
286
286
|
|
287
287
|
it 'detects self urls in url field' do
|
288
|
-
normalize 'url' => '
|
288
|
+
normalize 'url' => 'https://api.github.com/foo'
|
289
289
|
normalized.should_not include('url')
|
290
290
|
normalized.should include('_links')
|
291
291
|
normalized['_links'].should include('self')
|
292
292
|
normalized['_links'].should_not include('html')
|
293
|
-
normalized['_links']['self']['href'].should be == '
|
293
|
+
normalized['_links']['self']['href'].should be == 'https://api.github.com/foo'
|
294
294
|
end
|
295
295
|
|
296
296
|
it 'passes through true' do
|
297
297
|
normalize 'foo' => true
|
298
298
|
normalized['foo'].should be == true
|
299
299
|
end
|
300
|
+
|
301
|
+
it 'properly detects html links when api is served from same host' do
|
302
|
+
subject.backend.setup("http://localhost/api/v3", {})
|
303
|
+
normalize 'url' => 'http://localhost/foo'
|
304
|
+
normalized.should_not include('url')
|
305
|
+
normalized.should include('_links')
|
306
|
+
normalized['_links'].should include('html')
|
307
|
+
normalized['_links']['html']['href'].should be == 'http://localhost/foo'
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'properly detects self links when api is served from same host' do
|
311
|
+
subject.backend.setup("http://localhost/api/v3", {})
|
312
|
+
normalize 'url' => 'http://localhost/api/v3/foo'
|
313
|
+
normalized.should_not include('url')
|
314
|
+
normalized.should include('_links')
|
315
|
+
normalized['_links'].should include('self')
|
316
|
+
normalized['_links']['self']['href'].should be == 'http://localhost/api/v3/foo'
|
317
|
+
end
|
300
318
|
end
|
301
319
|
end
|