lhs 12.0.0 → 12.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fc72f0094042042734fdecaec1df8b9c07194a2
4
- data.tar.gz: 33bc6824ba84ac62a79a7c2cc324f61681789847
3
+ metadata.gz: f6dd72496ffd697f998423f63eb040d12da20c75
4
+ data.tar.gz: 087da614313aa4626e2b0671a0071cdbc7c82922
5
5
  SHA512:
6
- metadata.gz: 4f90bef44098ed8a70f00285c48c7627774a1cc00d3a04b5f2030855c7ee5807597cc9e920ea91f9307aca1980fd77927345e70f8826a11b787590e2caba4761
7
- data.tar.gz: 7488e69922acb478161effd760e6ae5224c0d192ed1f4bd7fd78a4bdd578fd945e057af4e058a9183bdc88dc58e81beeaa563b2c50334535c9796886ca37c832
6
+ metadata.gz: 75374cd617e5b67ba372bdefc710e2f305b27e8639a5df27d4f21cd44cd93df14a13ab79d11ae2a333069a3686f16739e0b15298346d0cb860c8944d7a0cd8b5
7
+ data.tar.gz: 566ebd60a00e7e7a68486bd77bc6431678bd42df5abcd680e1e4d775c7b321d88ac33d097576330195ecb97705aa74a68224547c3663051c40717c2fa695459e
@@ -63,8 +63,8 @@ class LHS::Record
63
63
  url
64
64
  end
65
65
 
66
- def compute_url(params)
67
- find_endpoint(params)
66
+ def compute_url(params, url = nil)
67
+ find_endpoint(params, url)
68
68
  .compile(params)
69
69
  end
70
70
 
@@ -68,7 +68,7 @@ class LHS::Record
68
68
  def parse_uri(url, options)
69
69
  URI.parse(
70
70
  if url.match(LHC::Endpoint::PLACEHOLDER)
71
- compute_url(options[:params])
71
+ compute_url(options[:params], url)
72
72
  else
73
73
  url
74
74
  end
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "12.0.0"
2
+ VERSION = "12.0.1"
3
3
  end
@@ -339,4 +339,43 @@ describe LHS::Record do
339
339
  end
340
340
  end
341
341
  end
342
+
343
+ context 'Linked resources' do
344
+ before(:each) do
345
+ stub_request(:get, 'http://datastore/places/1/contracts?offset=0&limit=10')
346
+ .to_return(
347
+ body: {
348
+ href: "http://datastore/v2/places/1/contracts?offset=0&limit=10",
349
+ items: [{ href: "http://datastore/v2/contracts/1" }]
350
+ }.to_json
351
+ )
352
+
353
+ stub_request(:get, "http://datastore/v2/contracts/1")
354
+ .to_return(
355
+ body: {
356
+ customer: { name: 'Swisscom Directories AG' }
357
+ }.to_json
358
+ )
359
+
360
+ stub_request(:get, 'http://datastore/places/1?limit=1')
361
+ .to_return(
362
+ body: { href: 'http://datastore/places/1', contracts: { href: 'http://datastore/places/1/contracts?offset=0&limit=10' } }.to_json
363
+ )
364
+
365
+ class Place < LHS::Record
366
+ endpoint 'http://datastore/places/:id'
367
+ end
368
+
369
+ class Contract < LHS::Record
370
+ endpoint 'http://datastore/places/:place_id/contracts'
371
+ end
372
+ end
373
+
374
+ it 'does not use the root record endpoints when including nested records' do
375
+ place = Place
376
+ .includes_all(:contracts)
377
+ .find_by(id: 1)
378
+ expect(place.contracts.first.customer.name).to eq 'Swisscom Directories AG'
379
+ end
380
+ end
342
381
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0
4
+ version: 12.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-29 00:00:00.000000000 Z
11
+ date: 2017-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc