gds-api-adapters 10.3.0 → 10.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,10 @@ module GdsApi
6
6
  get_json(documents_url(finder_slug, options))
7
7
  end
8
8
 
9
+ def get_schema(finder_slug, options = {})
10
+ get_json(finder_url(finder_slug, 'schema', options))
11
+ end
12
+
9
13
  private
10
14
  def documents_url(finder_slug, options = {})
11
15
  finder_url(finder_slug, 'documents', options)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '10.3.0'
2
+ VERSION = '10.4.0'
3
3
  end
@@ -58,4 +58,43 @@ describe GdsApi::FinderApi do
58
58
  assert_requested(req)
59
59
  end
60
60
  end
61
+
62
+ describe "get_schema" do
63
+ let(:schema_hash) {
64
+ {'it is' => 'a schema'}
65
+ }
66
+
67
+ let(:schema_json) {
68
+ schema_hash.to_json
69
+ }
70
+
71
+ let(:schema_url) {
72
+ "#{@base_api_url}/finders/some-finder-slug/schema.json"
73
+ }
74
+
75
+ it "should return the finder's schema" do
76
+ req = WebMock.stub_request(:get, schema_url).
77
+ to_return(:body => schema_json,
78
+ :headers => {"Content-type" => "application/json"})
79
+
80
+ response = @api.get_schema("some-finder-slug")
81
+ assert_equal 200, response.code
82
+ assert_equal schema_hash, response.to_hash
83
+
84
+ assert_requested(req)
85
+ end
86
+
87
+ it "should forward query parameters" do
88
+ req = WebMock.stub_request(:get, "#{@base_api_url}/finders/some-finder-slug/schema.json").
89
+ with(query: {locale: 'fr-FR'}).
90
+ to_return(:body => schema_json,
91
+ :headers => {"Content-type" => "application/json"})
92
+
93
+ response = @api.get_schema("some-finder-slug", locale: 'fr-FR')
94
+ assert_equal 200, response.code
95
+ assert_equal schema_hash, response.to_hash
96
+
97
+ assert_requested(req)
98
+ end
99
+ end
61
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.3.0
4
+ version: 10.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-28 00:00:00.000000000 Z
12
+ date: 2014-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -372,7 +372,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
372
372
  version: '0'
373
373
  segments:
374
374
  - 0
375
- hash: 988974832367169730
375
+ hash: 227919718345110221
376
376
  required_rubygems_version: !ruby/object:Gem::Requirement
377
377
  none: false
378
378
  requirements:
@@ -381,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
381
381
  version: '0'
382
382
  segments:
383
383
  - 0
384
- hash: 988974832367169730
384
+ hash: 227919718345110221
385
385
  requirements: []
386
386
  rubyforge_project:
387
387
  rubygems_version: 1.8.23