gds-api-adapters 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/panopticon/registerer.rb +4 -2
- data/lib/gds_api/version.rb +1 -1
- data/test/panopticon_api_test.rb +25 -0
- metadata +4 -4
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'plek'
|
2
|
+
|
1
3
|
module GdsApi
|
2
4
|
class Panopticon < GdsApi::Base
|
3
5
|
class Registerer
|
@@ -9,7 +11,7 @@ module GdsApi
|
|
9
11
|
@rendering_app = options[:rendering_app]
|
10
12
|
@kind = options[:kind] || 'custom-application'
|
11
13
|
@panopticon = options[:panopticon]
|
12
|
-
@platform = options[:platform] ||
|
14
|
+
@platform = options[:platform] || Plek.current.environment
|
13
15
|
end
|
14
16
|
|
15
17
|
def record_to_artefact(record)
|
@@ -67,4 +69,4 @@ module GdsApi
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
70
|
-
end
|
72
|
+
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/panopticon_api_test.rb
CHANGED
@@ -137,6 +137,31 @@ class PanopticonApiTest < MiniTest::Unit::TestCase
|
|
137
137
|
r.register(record)
|
138
138
|
end
|
139
139
|
|
140
|
+
def test_registerer_should_use_plek_env_by_default
|
141
|
+
# Plek.current returns a different object each time it's called.
|
142
|
+
plek_current = Plek.current
|
143
|
+
plek_current.stubs(:environment).returns("foo")
|
144
|
+
Plek.stubs(:current).returns(plek_current)
|
145
|
+
|
146
|
+
expected_endpoint = PANOPTICON_ENDPOINT.sub(/\.test\./, '.foo.')
|
147
|
+
|
148
|
+
r = GdsApi::Panopticon::Registerer.new(owning_app: 'my-app')
|
149
|
+
artefact = registerable_artefact()
|
150
|
+
panopticon_has_no_metadata_for('foo')
|
151
|
+
|
152
|
+
stub_request(:put, "#{expected_endpoint}/artefacts/foo.json")
|
153
|
+
.with(body: artefact.to_json)
|
154
|
+
.to_return(body: artefact.merge(id: 1).to_json)
|
155
|
+
|
156
|
+
url = "#{expected_endpoint}/artefacts.json"
|
157
|
+
stub_request(:post, url)
|
158
|
+
.with(body: artefact.to_json)
|
159
|
+
.to_return(body: artefact.merge(id: 1).to_json)
|
160
|
+
|
161
|
+
record = OpenStruct.new(artefact.merge(title: artefact[:name]))
|
162
|
+
r.register(record)
|
163
|
+
end
|
164
|
+
|
140
165
|
def test_should_be_able_to_fetch_curated_lists
|
141
166
|
stub_request(:get, "#{PANOPTICON_ENDPOINT}/curated_lists.json").
|
142
167
|
with(:headers => GdsApi::JsonClient::REQUEST_HEADERS).
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Stewart
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-23 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: plek
|
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
requirements:
|
186
186
|
- - ">="
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
hash:
|
188
|
+
hash: 3276666182600664028
|
189
189
|
segments:
|
190
190
|
- 0
|
191
191
|
version: "0"
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
requirements:
|
195
195
|
- - ">="
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
hash:
|
197
|
+
hash: 3276666182600664028
|
198
198
|
segments:
|
199
199
|
- 0
|
200
200
|
version: "0"
|