lhs 7.0.0 → 7.0.1
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/concerns/item/save.rb +30 -5
- data/lib/lhs/version.rb +1 -1
- data/spec/record/save_spec.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e11e78d3dd76e163a20dd38f8873322ff71ff81
|
4
|
+
data.tar.gz: 763cb822c37ca6e938cfd8f9a7f7014a1f47dc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970ba3f98020e099502f5dcf768d0efc0e40bb147be2f334cd5429dbec35543fd0b6157459f45a7c293e7ecd08a2ffae951e06aba758eabae61d15baf2fe220a
|
7
|
+
data.tar.gz: 00d4680483a466f6ae84487c3ed1d6c014e493ee2c120f47cef1a35c4a1e8ad5a5ea6c2d0f58a741715db146ee14d141771ef0688234e9395ac2fd88f12bd283
|
@@ -14,15 +14,15 @@ class LHS::Item < LHS::Proxy
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def save!(options = {})
|
17
|
-
options
|
18
|
-
record = _data.class
|
17
|
+
options = options.present? ? options.dup : {}
|
19
18
|
data = _data._raw.dup
|
20
19
|
if href.present?
|
21
20
|
url = href
|
22
21
|
else
|
23
|
-
endpoint =
|
24
|
-
url = endpoint
|
22
|
+
endpoint = endpoint_for_persistance(data, options)
|
23
|
+
url = url_for_persistance(endpoint, data, options)
|
25
24
|
endpoint.remove_interpolated_params!(data)
|
25
|
+
endpoint.remove_interpolated_params!(options.fetch(:params, {}))
|
26
26
|
options.merge!(endpoint.options.merge(options)) if endpoint.options
|
27
27
|
end
|
28
28
|
|
@@ -30,9 +30,34 @@ class LHS::Item < LHS::Proxy
|
|
30
30
|
options[:headers] ||= {}
|
31
31
|
options[:headers].merge!('Content-Type' => 'application/json')
|
32
32
|
|
33
|
-
data =
|
33
|
+
data = record_for_persistance.request(options)
|
34
34
|
_data.merge_raw!(data)
|
35
35
|
true
|
36
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def endpoint_for_persistance(data, options)
|
41
|
+
record_for_persistance
|
42
|
+
.find_endpoint(merge_data_with_options(data, options))
|
43
|
+
end
|
44
|
+
|
45
|
+
def merge_data_with_options(data, options)
|
46
|
+
if options && options[:params]
|
47
|
+
data.merge(options[:params])
|
48
|
+
else
|
49
|
+
data
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def record_for_persistance
|
54
|
+
_data.class
|
55
|
+
end
|
56
|
+
|
57
|
+
def url_for_persistance(endpoint, data, options)
|
58
|
+
endpoint.compile(
|
59
|
+
merge_data_with_options(data, options)
|
60
|
+
)
|
61
|
+
end
|
37
62
|
end
|
38
63
|
end
|
data/lib/lhs/version.rb
CHANGED
data/spec/record/save_spec.rb
CHANGED
@@ -14,14 +14,24 @@ describe LHS::Record do
|
|
14
14
|
let(:campaign_id) { 12345 }
|
15
15
|
let(:object) { { recommended: true } }
|
16
16
|
let(:item) { Feedback.new(object.merge(campaign_id: campaign_id)) }
|
17
|
-
|
18
|
-
|
19
|
-
datastore_request = stub_request(:post, "#{datastore}/content-ads/#{campaign_id}/feedbacks")
|
17
|
+
let!(:request) do
|
18
|
+
stub_request(:post, "#{datastore}/content-ads/#{campaign_id}/feedbacks")
|
20
19
|
.with(body: object.to_json)
|
21
20
|
.to_return(status: 200, body: object.to_json)
|
21
|
+
end
|
22
22
|
|
23
|
+
it 'removes params used to compute url from send data' do
|
23
24
|
item.save!
|
24
|
-
expect(
|
25
|
+
expect(request).to have_been_made.once
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'item without data' do
|
29
|
+
let(:item) { Feedback.new(object) }
|
30
|
+
|
31
|
+
it 'takes params to find endpoint also from the options' do
|
32
|
+
item.save!(params: { campaign_id: campaign_id })
|
33
|
+
expect(request).to have_been_made.once
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
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: 7.0.
|
4
|
+
version: 7.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|