lhs 1.2.2 → 1.2.3
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 +4 -4
- data/lib/lhs/collection.rb +1 -4
- data/lib/lhs/concerns/service/request.rb +1 -0
- data/lib/lhs/item.rb +2 -0
- data/lib/lhs/version.rb +1 -1
- data/spec/collection/delegate_spec.rb +21 -0
- data/spec/item/delegate_spec.rb +32 -0
- data/spec/item/destroy_spec.rb +28 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d19aca4a6fcb6ae3919253eb5dfc56dd15b9dee
|
4
|
+
data.tar.gz: 923b15da62737dd1dd0b1f1fa9b326eba4401da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96cc284a37e9107fbb5eb86ca6baae8fa97cf23cef4db5dea91b78331d5ee145d03d2d27c8da555eb231ecb6b12595630bf9c10884b768f0c6a3a778db4818c2
|
7
|
+
data.tar.gz: e99b4c5f0d0f49b99e852e7439515b361c7d566d2bc8a1991d0f96d7fae3aeacd9c5883e180f57e12ad5ac6f6533c8827b56e11f59817502715a00e5debc4d0d
|
data/lib/lhs/collection.rb
CHANGED
@@ -55,6 +55,7 @@ class LHS::Collection < LHS::Proxy
|
|
55
55
|
include Enumerable
|
56
56
|
|
57
57
|
attr_accessor :raw
|
58
|
+
delegate :last, :sample, :[], :present?, :blank?, :empty?, to: :raw
|
58
59
|
|
59
60
|
def initialize(raw, parent, service)
|
60
61
|
self.raw = raw
|
@@ -71,9 +72,5 @@ class LHS::Collection < LHS::Proxy
|
|
71
72
|
end
|
72
73
|
end
|
73
74
|
end
|
74
|
-
|
75
|
-
delegate :last, to: :raw
|
76
|
-
delegate :sample, to: :raw
|
77
|
-
delegate :[], to: :raw
|
78
75
|
end
|
79
76
|
end
|
data/lib/lhs/item.rb
CHANGED
data/lib/lhs/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHS::Collection do
|
4
|
+
|
5
|
+
let(:data) {
|
6
|
+
['ROLE_USER', 'ROLE_LOCALCH_ACCOUNT']
|
7
|
+
}
|
8
|
+
|
9
|
+
let(:collection){
|
10
|
+
described_class.new(LHS::Data.new(data))
|
11
|
+
}
|
12
|
+
|
13
|
+
context 'delegates methods to raw' do
|
14
|
+
|
15
|
+
%w(present? blank? empty?).each do |method|
|
16
|
+
it "delegates #{method} to raw" do
|
17
|
+
expect(collection.send(method.to_sym)).not_to be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHS::Item do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
class SomeService < LHS::Service
|
7
|
+
endpoint ':datastore/v2/:campaign_id/feedbacks'
|
8
|
+
endpoint ':datastore/v2/feedbacks'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:json) do
|
13
|
+
load_json(:feedbacks)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:data) do
|
17
|
+
LHS::Data.new(json, nil, SomeService)
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:item) do
|
21
|
+
data[0]
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'delegates methods to raw' do
|
25
|
+
|
26
|
+
%w(present? blank? empty?).each do |method|
|
27
|
+
it "delegates #{method} to raw" do
|
28
|
+
expect(item.send(method.to_sym)).not_to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/item/destroy_spec.rb
CHANGED
@@ -3,12 +3,17 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
+
LHC.config.placeholder('datastore', datastore)
|
6
7
|
class SomeService < LHS::Service
|
7
8
|
endpoint ':datastore/v2/:campaign_id/feedbacks'
|
8
9
|
endpoint ':datastore/v2/feedbacks'
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
13
|
+
let(:datastore) do
|
14
|
+
'http://datastore-stg.lb-service.sunrise.intra.local.ch'
|
15
|
+
end
|
16
|
+
|
12
17
|
let(:json) do
|
13
18
|
load_json(:feedbacks)
|
14
19
|
end
|
@@ -24,16 +29,36 @@ describe LHS::Item do
|
|
24
29
|
context 'destroy' do
|
25
30
|
|
26
31
|
it 'destroys the item on the backend' do
|
27
|
-
stub_request(:delete,
|
32
|
+
stub_request(:delete, "#{datastore}/v2/feedbacks/0sdaetZ-OWVg4oBiBJ-7IQ")
|
28
33
|
.to_return(status: 200)
|
29
34
|
expect(item.destroy._raw).to eq item._raw
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'updates the request information on the item' do
|
33
38
|
no_content = 204
|
34
|
-
stub_request(:delete,
|
35
|
-
|
39
|
+
stub_request(:delete, "#{datastore}/v2/feedbacks/0sdaetZ-OWVg4oBiBJ-7IQ")
|
40
|
+
.to_return(status: no_content)
|
36
41
|
expect(item.destroy._request.response.code).to eq no_content
|
37
42
|
end
|
43
|
+
|
44
|
+
context 'includes and empty response' do
|
45
|
+
before(:each) do
|
46
|
+
class AnotherService < LHS::Service
|
47
|
+
endpoint ':datastore/v2/:campaign_id/restaurants'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'destroys an item even though it includes additonal services and an empty response body' do
|
52
|
+
stub_request(:delete, "#{datastore}/v2/feedbacks/1")
|
53
|
+
.to_return(status: 204, body: '')
|
54
|
+
data = { href: "#{datastore}/v2/feedbacks/1", restaurant: {href: "#{datastore}/v2/restaurants/1"} }
|
55
|
+
stub_request(:get, "#{datastore}/v2/feedbacks?id=1")
|
56
|
+
.to_return(status: 200, body: data.to_json)
|
57
|
+
stub_request(:get, "#{datastore}/v2/restaurants/1")
|
58
|
+
.to_return(status: 200, body: {name: 'Casa Ferlin'}.to_json)
|
59
|
+
item = SomeService.includes(:restaurant).find(1)
|
60
|
+
item.destroy
|
61
|
+
end
|
62
|
+
end
|
38
63
|
end
|
39
64
|
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: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/lhs/version.rb
|
157
157
|
- script/ci/build.sh
|
158
158
|
- spec/.DS_Store
|
159
|
+
- spec/collection/delegate_spec.rb
|
159
160
|
- spec/collection/meta_data_spec.rb
|
160
161
|
- spec/collection/respond_to_spec.rb
|
161
162
|
- spec/collection/without_object_items_spec.rb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- spec/dummy/public/500.html
|
207
208
|
- spec/dummy/public/favicon.ico
|
208
209
|
- spec/endpoint/for_url_spec.rb
|
210
|
+
- spec/item/delegate_spec.rb
|
209
211
|
- spec/item/destroy_spec.rb
|
210
212
|
- spec/item/getter_spec.rb
|
211
213
|
- spec/item/respond_to_spec.rb
|
@@ -265,6 +267,7 @@ signing_key:
|
|
265
267
|
specification_version: 4
|
266
268
|
summary: LocalHttpServices
|
267
269
|
test_files:
|
270
|
+
- spec/collection/delegate_spec.rb
|
268
271
|
- spec/collection/meta_data_spec.rb
|
269
272
|
- spec/collection/respond_to_spec.rb
|
270
273
|
- spec/collection/without_object_items_spec.rb
|
@@ -315,6 +318,7 @@ test_files:
|
|
315
318
|
- spec/dummy/public/500.html
|
316
319
|
- spec/dummy/public/favicon.ico
|
317
320
|
- spec/endpoint/for_url_spec.rb
|
321
|
+
- spec/item/delegate_spec.rb
|
318
322
|
- spec/item/destroy_spec.rb
|
319
323
|
- spec/item/getter_spec.rb
|
320
324
|
- spec/item/respond_to_spec.rb
|