bookingsync-api 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2cb84342589240cfa192b7d61350efb89297de9
4
- data.tar.gz: 17549658e975c21ff097e3bcbe7b92ce3aec0db8
3
+ metadata.gz: 92433c7543f03518887efc316656768355772c6e
4
+ data.tar.gz: caf9b90d93ebd5b323f12d7f2a3e81d124353c0b
5
5
  SHA512:
6
- metadata.gz: 00db8c9b72935df38730f0288252cddcd85c343e6847b9983e7fe9c410a900cbff84ff2c401e9a88d66245b2dd4686152a7820892fd1cb54f20538f3c0de7b06
7
- data.tar.gz: ad647464027c54595e3703d813447366845487d7031397b4d27f39f8cba15486228edc7097e1b49962bfd0995ff83a2339e229e295a466241dfd797f29d68ae6
6
+ metadata.gz: 06dff22dabc99c0e7de5197340db2b0cf6270ec62c18518262f6faa31a597a9a48374baebf4811b9bc1d0af880ec0b0cdd7335b2b5587c95a002c23248f23473
7
+ data.tar.gz: 640a730f3ee59300645065c3023e3ba4f249e684f35a729acd764f10a348b80f260c134a845853b006ffff3e3dc105e1e781e6fbd4d96022cb9b60c714a34c9d
@@ -41,8 +41,8 @@ module BookingSync::API
41
41
  def method_missing(method, *args)
42
42
  association_key = :"#{@_resources_key}.#{method}"
43
43
  if self[:links] && self[:links].has_key?(method)
44
- ids = self[:links][method]
45
- return [] if !ids or ids.empty?
44
+ ids = Array(self[:links][method])
45
+ return [] if ids.empty?
46
46
  options = {uri: {association_key => ids}}
47
47
  options.merge!(query: args.first) if args.first.is_a?(Hash)
48
48
  @_rels[association_key].get(options).resources
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ describe BookingSync::API::Resource do
14
14
  },
15
15
  {
16
16
  :"foo.photos" => "http://foo.com/photos/{foo.photos}",
17
- :"foo.bars" => "http://foo.com/bars/{foo.bars}"
17
+ :"foo.category" => "http://foo.com/categories/{foo.category}"
18
18
  },
19
19
  "foo"
20
20
  )
@@ -45,10 +45,22 @@ describe BookingSync::API::Resource do
45
45
 
46
46
  describe "associations" do
47
47
  before { VCR.turn_off! }
48
- it "fetches an association based on links" do
49
- stub_request(:get, "http://foo.com/photos/9,10")
50
- .to_return(body: {photos: [{file: 'a.jpg'}]}.to_json)
51
- expect(resource.photos).to eql([{:file => "a.jpg"}])
48
+
49
+ context "has_many (ids given as an array)" do
50
+ it "fetches an association based on links" do
51
+ stub_request(:get, "http://foo.com/photos/9,10")
52
+ .to_return(body: {photos: [{file: 'a.jpg'}]}.to_json)
53
+ expect(resource.photos).to eql([{:file => "a.jpg"}])
54
+ end
55
+ end
56
+
57
+ context "has_one (id given as a single integer)" do
58
+ let(:links) { {category: 15} }
59
+ it "fetches an association based on links" do
60
+ stub_request(:get, "http://foo.com/categories/15")
61
+ .to_return(body: {categories: [{name: "Secret one"}]}.to_json)
62
+ expect(resource.category).to eql([{name: "Secret one"}])
63
+ end
52
64
  end
53
65
 
54
66
  context "when there are not associated ids" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Grosjean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday