gds-api-adapters 11.6.0 → 12.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/finder_schema.rb +8 -2
- data/lib/gds_api/response.rb +4 -0
- data/lib/gds_api/version.rb +1 -1
- data/test/finder_schema_test.rb +20 -2
- data/test/response_test.rb +5 -1
- metadata +4 -4
@@ -9,7 +9,7 @@ class GdsApi::FinderSchema
|
|
9
9
|
document_attributes.each_with_object({}) do |(k, v), values|
|
10
10
|
values.store(
|
11
11
|
user_friendly_facet_label(k.to_s),
|
12
|
-
|
12
|
+
user_friendly_facet_value(k.to_s, v),
|
13
13
|
)
|
14
14
|
end
|
15
15
|
end
|
@@ -27,7 +27,13 @@ class GdsApi::FinderSchema
|
|
27
27
|
find_facet(facet_key.to_s).fetch("name")
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def user_friendly_facet_value(facet_key, value)
|
31
|
+
Array(value).map { |value|
|
32
|
+
find_schema_allowed_value_label(facet_key, value)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_schema_allowed_value_label(facet_key, value)
|
31
37
|
value_label_pair = allowed_values_for(facet_key)
|
32
38
|
.find { |schema_value|
|
33
39
|
schema_value.fetch("value") == value
|
data/lib/gds_api/response.rb
CHANGED
data/lib/gds_api/version.rb
CHANGED
data/test/finder_schema_test.rb
CHANGED
@@ -49,8 +49,8 @@ describe GdsApi::FinderSchema do
|
|
49
49
|
|
50
50
|
let(:formatted_attrs) {
|
51
51
|
{
|
52
|
-
"Case type" => "CA98 and civil cartels",
|
53
|
-
"Market sector" => "Aerospace",
|
52
|
+
"Case type" => ["CA98 and civil cartels"],
|
53
|
+
"Market sector" => ["Aerospace"],
|
54
54
|
}
|
55
55
|
}
|
56
56
|
|
@@ -73,5 +73,23 @@ describe GdsApi::FinderSchema do
|
|
73
73
|
"market sector 'does-not-exist' not found in cma-cases schema")
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
describe "when a value is an array of values" do
|
78
|
+
let(:document_attrs) {
|
79
|
+
{
|
80
|
+
market_sector: ["aerospace"],
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
let(:formatted_attrs) {
|
85
|
+
{
|
86
|
+
"Market sector" => ["Aerospace"],
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
it "formats the given keys and values" do
|
91
|
+
schema.user_friendly_values(document_attrs).must_equal(formatted_attrs)
|
92
|
+
end
|
93
|
+
end
|
76
94
|
end
|
77
95
|
end
|
data/test/response_test.rb
CHANGED
@@ -5,7 +5,7 @@ describe GdsApi::Response do
|
|
5
5
|
|
6
6
|
describe "accessing HTTP response details" do
|
7
7
|
before :each do
|
8
|
-
@mock_http_response = stub(:body => "A Response body", :code => 200)
|
8
|
+
@mock_http_response = stub(:body => "A Response body", :code => 200, :headers => {'cache-control' => 'public'})
|
9
9
|
@response = GdsApi::Response.new(@mock_http_response)
|
10
10
|
end
|
11
11
|
|
@@ -16,6 +16,10 @@ describe GdsApi::Response do
|
|
16
16
|
it "should return the status code" do
|
17
17
|
assert_equal 200, @response.code
|
18
18
|
end
|
19
|
+
|
20
|
+
it "should pass-on the response headers" do
|
21
|
+
assert_equal({'cache-control' => 'public'}, @response.headers)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
describe "processing web_urls" do
|
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:
|
4
|
+
version: 12.0.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-07-
|
12
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plek
|
@@ -385,7 +385,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
385
385
|
version: '0'
|
386
386
|
segments:
|
387
387
|
- 0
|
388
|
-
hash:
|
388
|
+
hash: -1023858681611689448
|
389
389
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
390
390
|
none: false
|
391
391
|
requirements:
|
@@ -394,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
394
|
version: '0'
|
395
395
|
segments:
|
396
396
|
- 0
|
397
|
-
hash:
|
397
|
+
hash: -1023858681611689448
|
398
398
|
requirements: []
|
399
399
|
rubyforge_project:
|
400
400
|
rubygems_version: 1.8.23
|