lhs 3.0.0 → 3.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/.rubocop.localch.yml +190 -0
- data/.rubocop.yml +7 -0
- data/cider-ci.yml +2 -1
- data/cider-ci/jobs/rspec.yml +48 -0
- data/cider-ci/jobs/rubocop.yml +55 -0
- data/cider-ci/scripts/bundle.yml +2 -0
- data/cider-ci/scripts/github_comment.yml +6 -0
- data/cider-ci/scripts/rspec.yml +4 -0
- data/cider-ci/scripts/rubocop.yml +5 -0
- data/cider-ci/scripts/ruby-version.yml +2 -0
- data/cider-ci/scripts/tmp-cache.yml +2 -0
- data/lhs.gemspec +1 -0
- data/lib/lhs/collection.rb +2 -6
- data/lib/lhs/concerns/data/json.rb +1 -1
- data/lib/lhs/concerns/item/save.rb +11 -10
- data/lib/lhs/concerns/item/update.rb +1 -1
- data/lib/lhs/concerns/item/validation.rb +2 -2
- data/lib/lhs/concerns/record/all.rb +1 -2
- data/lib/lhs/concerns/record/batch.rb +2 -3
- data/lib/lhs/concerns/record/create.rb +7 -8
- data/lib/lhs/concerns/record/endpoints.rb +2 -3
- data/lib/lhs/concerns/record/find.rb +6 -6
- data/lib/lhs/concerns/record/find_by.rb +8 -8
- data/lib/lhs/concerns/record/first.rb +0 -1
- data/lib/lhs/concerns/record/includes.rb +0 -1
- data/lib/lhs/concerns/record/mapping.rb +0 -1
- data/lib/lhs/concerns/record/model.rb +0 -1
- data/lib/lhs/concerns/record/request.rb +18 -14
- data/lib/lhs/concerns/record/where.rb +0 -1
- data/lib/lhs/data.rb +3 -4
- data/lib/lhs/endpoint.rb +1 -2
- data/lib/lhs/errors.rb +7 -13
- data/lib/lhs/item.rb +5 -9
- data/lib/lhs/record.rb +12 -8
- data/lib/lhs/version.rb +1 -1
- data/spec/collection/delegate_spec.rb +0 -2
- data/spec/collection/enumerable_spec.rb +2 -4
- data/spec/collection/meta_data_spec.rb +0 -1
- data/spec/collection/respond_to_spec.rb +0 -1
- data/spec/collection/without_object_items_spec.rb +0 -1
- data/spec/data/collection_spec.rb +4 -7
- data/spec/data/item_spec.rb +3 -5
- data/spec/data/merge_spec.rb +7 -9
- data/spec/data/raw_spec.rb +3 -5
- data/spec/data/respond_to_spec.rb +3 -5
- data/spec/data/root_spec.rb +3 -5
- data/spec/data/select_spec.rb +2 -4
- data/spec/data/to_json_spec.rb +5 -7
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/spec/endpoint/for_url_spec.rb +3 -5
- data/spec/item/delegate_spec.rb +0 -2
- data/spec/item/destroy_spec.rb +3 -5
- data/spec/item/errors_spec.rb +20 -23
- data/spec/item/getter_spec.rb +1 -3
- data/spec/item/internal_data_structure_spec.rb +2 -3
- data/spec/item/respond_to_spec.rb +1 -1
- data/spec/item/save_spec.rb +7 -10
- data/spec/item/setter_spec.rb +2 -4
- data/spec/item/update_spec.rb +4 -7
- data/spec/item/validation_spec.rb +7 -9
- data/spec/proxy/load_spec.rb +0 -2
- data/spec/record/all_spec.rb +10 -12
- data/spec/record/build_spec.rb +0 -2
- data/spec/record/create_spec.rb +8 -10
- data/spec/record/creation_failed_spec.rb +4 -6
- data/spec/record/definitions_spec.rb +1 -3
- data/spec/record/endpoint_misconfiguration_spec.rb +2 -4
- data/spec/record/endpoint_options_spec.rb +0 -2
- data/spec/record/endpoints_spec.rb +1 -6
- data/spec/record/find_each_spec.rb +2 -4
- data/spec/record/find_in_batches_spec.rb +4 -6
- data/spec/record/find_spec.rb +10 -13
- data/spec/record/first_spec.rb +0 -3
- data/spec/record/includes_spec.rb +15 -20
- data/spec/record/mapping_spec.rb +13 -15
- data/spec/record/model_name_spec.rb +0 -2
- data/spec/record/new_spec.rb +4 -2
- data/spec/record/request_spec.rb +1 -3
- data/spec/record/where_spec.rb +1 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/support/cleanup_configuration.rb +0 -2
- data/spec/support/cleanup_endpoints.rb +0 -1
- data/spec/support/cleanup_records.rb +0 -2
- metadata +26 -4
- data/cider-ci/contexts/rspec.yml +0 -16
- data/cider-ci/jobs/tests.yml +0 -27
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
context 'endpoints' do
|
6
|
-
|
7
5
|
let(:datastore) { 'http://local.ch/v2' }
|
8
6
|
|
9
7
|
before(:each) do
|
@@ -16,7 +14,7 @@ describe LHS::Record do
|
|
16
14
|
end
|
17
15
|
|
18
16
|
it 'stores all the endpoints by url' do
|
19
|
-
expect(LHS::Record::Endpoints.all[':datastore/entries/:entry_id/content-ads/:campaign_id/feedbacks']).to be
|
17
|
+
expect(LHS::Record::Endpoints.all[':datastore/entries/:entry_id/content-ads/:campaign_id/feedbacks']).to be
|
20
18
|
expect(LHS::Record::Endpoints.all[':datastore/:campaign_id/feedbacks']).to be
|
21
19
|
expect(LHS::Record::Endpoints.all[':datastore/feedbacks']).to be
|
22
20
|
end
|
@@ -44,7 +42,6 @@ describe LHS::Record do
|
|
44
42
|
end
|
45
43
|
|
46
44
|
context 'compute url from endpoint' do
|
47
|
-
|
48
45
|
before(:each) do
|
49
46
|
class Feedback < LHS::Record
|
50
47
|
endpoint ':datastore/feedbacks'
|
@@ -59,7 +56,6 @@ describe LHS::Record do
|
|
59
56
|
end
|
60
57
|
|
61
58
|
context 'unsorted endpoints' do
|
62
|
-
|
63
59
|
before(:each) do
|
64
60
|
class AnotherRecord < LHS::Record
|
65
61
|
endpoint ':datastore/feedbacks'
|
@@ -72,7 +68,6 @@ describe LHS::Record do
|
|
72
68
|
stub_request(:get, "#{datastore}/entries/123/content-ads/123/feedbacks").to_return(status: 200)
|
73
69
|
AnotherRecord.where(campaign_id: 123, entry_id: 123)
|
74
70
|
end
|
75
|
-
|
76
71
|
end
|
77
72
|
end
|
78
73
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Collection do
|
4
|
-
|
5
4
|
let(:total) { 443 }
|
6
5
|
|
7
6
|
let(:limit) { 100 }
|
8
7
|
|
9
8
|
def api_response(ids, offset)
|
10
|
-
records = ids.map{|i| {id: i}}
|
9
|
+
records = ids.map { |i| { id: i } }
|
11
10
|
{
|
12
11
|
items: records,
|
13
12
|
total: total,
|
@@ -27,7 +26,6 @@ describe LHS::Collection do
|
|
27
26
|
end
|
28
27
|
|
29
28
|
context 'find_each' do
|
30
|
-
|
31
29
|
it 'processes each record by fetching records in batches' do
|
32
30
|
stub_request(:get, "#{datastore}/feedbacks?limit=100&offset=1").to_return(status: 200, body: api_response((1..100).to_a, 1))
|
33
31
|
stub_request(:get, "#{datastore}/feedbacks?limit=100&offset=101").to_return(status: 200, body: api_response((101..200).to_a, 101))
|
@@ -42,6 +40,6 @@ describe LHS::Collection do
|
|
42
40
|
expect(record._proxy).to be_kind_of LHS::Item
|
43
41
|
end
|
44
42
|
expect(count).to eq total
|
45
|
-
end
|
43
|
+
end
|
46
44
|
end
|
47
45
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Collection do
|
4
|
-
|
5
4
|
let(:total) { 443 }
|
6
5
|
|
7
6
|
let(:limit) { 100 }
|
8
7
|
|
9
8
|
def api_response(ids, offset)
|
10
|
-
records = ids.map{|i| {id: i}}
|
9
|
+
records = ids.map { |i| { id: i } }
|
11
10
|
{
|
12
11
|
items: records,
|
13
12
|
total: total,
|
@@ -27,7 +26,6 @@ describe LHS::Collection do
|
|
27
26
|
end
|
28
27
|
|
29
28
|
context 'find_batches' do
|
30
|
-
|
31
29
|
it 'processes records in batches' do
|
32
30
|
stub_request(:get, "#{datastore}/feedbacks?limit=100&offset=1").to_return(status: 200, body: api_response((1..100).to_a, 1))
|
33
31
|
stub_request(:get, "#{datastore}/feedbacks?limit=100&offset=101").to_return(status: 200, body: api_response((101..200).to_a, 101))
|
@@ -38,7 +36,7 @@ describe LHS::Collection do
|
|
38
36
|
Record.find_in_batches do |records|
|
39
37
|
count += records.count
|
40
38
|
expect(records).to be_kind_of Record
|
41
|
-
expect(records._proxy).to be_kind_of
|
39
|
+
expect(records._proxy).to be_kind_of described_class
|
42
40
|
end
|
43
41
|
expect(count).to eq total
|
44
42
|
end
|
@@ -53,7 +51,7 @@ describe LHS::Collection do
|
|
53
51
|
Record.find_in_batches(batch_size: 230) do |records|
|
54
52
|
count += records.count
|
55
53
|
expect(records).to be_kind_of Record
|
56
|
-
expect(records._proxy).to be_kind_of
|
54
|
+
expect(records._proxy).to be_kind_of described_class
|
57
55
|
end
|
58
56
|
expect(count).to eq total
|
59
57
|
end
|
@@ -61,7 +59,7 @@ describe LHS::Collection do
|
|
61
59
|
it 'forwards offset' do
|
62
60
|
stub_request(:get, "#{datastore}/feedbacks?limit=100&offset=401").to_return(status: 200, body: api_response((401..total).to_a, 401))
|
63
61
|
Record.find_in_batches(start: 401) do |records|
|
64
|
-
expect(records.count).to eq(total-400)
|
62
|
+
expect(records.count).to eq(total - 400)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
data/spec/record/find_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
let(:datastore) { 'http://local.ch/v2' }
|
6
5
|
|
7
6
|
before(:each) do
|
@@ -15,24 +14,23 @@ describe LHS::Record do
|
|
15
14
|
end
|
16
15
|
|
17
16
|
context 'find' do
|
18
|
-
|
19
17
|
it 'finds a single unique record' do
|
20
|
-
stub_request(:get, "#{datastore}/feedbacks/z12f-3asm3ngals")
|
21
|
-
|
18
|
+
stub_request(:get, "#{datastore}/feedbacks/z12f-3asm3ngals")
|
19
|
+
.to_return(status: 200, body: load_json(:feedback))
|
22
20
|
record = Record.find('z12f-3asm3ngals')
|
23
21
|
expect(record).to be_kind_of Record
|
24
22
|
expect(record.source_id).to be_kind_of String
|
25
23
|
end
|
26
24
|
|
27
25
|
it 'raises if nothing was found' do
|
28
|
-
stub_request(:get, "#{datastore}/feedbacks/not-existing")
|
29
|
-
|
26
|
+
stub_request(:get, "#{datastore}/feedbacks/not-existing")
|
27
|
+
.to_return(status: 404)
|
30
28
|
expect { Record.find('not-existing') }.to raise_error LHC::NotFound
|
31
29
|
end
|
32
30
|
|
33
31
|
it 'finds unique item by providing parameters' do
|
34
32
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks/123")
|
35
|
-
|
33
|
+
.to_return(body: "{}")
|
36
34
|
data = Record.find(campaign_id: '123', id: '123')
|
37
35
|
expect(data._proxy).to be_kind_of LHS::Item
|
38
36
|
end
|
@@ -41,15 +39,15 @@ describe LHS::Record do
|
|
41
39
|
data = JSON.parse(load_json(:feedbacks))
|
42
40
|
data['items'] = [data['items'].first]
|
43
41
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks/123")
|
44
|
-
|
42
|
+
.to_return(body: data.to_json)
|
45
43
|
data = Record.find(campaign_id: '123', id: '123')
|
46
44
|
expect(data._proxy).to be_kind_of LHS::Item
|
47
45
|
end
|
48
46
|
|
49
47
|
it 'fails when multiple items where found by parameters' do
|
50
48
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks/123")
|
51
|
-
|
52
|
-
expect(
|
49
|
+
.to_return(body: load_json(:feedbacks))
|
50
|
+
expect(lambda {
|
53
51
|
Record.find(campaign_id: '123', id: '123')
|
54
52
|
}).to raise_error LHC::NotFound
|
55
53
|
end
|
@@ -58,8 +56,8 @@ describe LHS::Record do
|
|
58
56
|
data = JSON.parse(load_json(:feedbacks))
|
59
57
|
data['items'] = []
|
60
58
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks/123")
|
61
|
-
|
62
|
-
expect(
|
59
|
+
.to_return(body: data.to_json)
|
60
|
+
expect(lambda {
|
63
61
|
Record.find(campaign_id: '123', id: '123')
|
64
62
|
}).to raise_error LHC::NotFound
|
65
63
|
end
|
@@ -69,6 +67,5 @@ describe LHS::Record do
|
|
69
67
|
.to_return(status: 404)
|
70
68
|
expect { Record.find(campaign_id: '123', id: '123') }.to raise_error LHC::NotFound
|
71
69
|
end
|
72
|
-
|
73
70
|
end
|
74
71
|
end
|
data/spec/record/first_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
let(:datastore) { 'http://local.ch/v2' }
|
6
5
|
|
7
6
|
before(:each) do
|
@@ -13,7 +12,6 @@ describe LHS::Record do
|
|
13
12
|
end
|
14
13
|
|
15
14
|
context 'first' do
|
16
|
-
|
17
15
|
it 'finds a single record' do
|
18
16
|
stub_request(:get, "#{datastore}/feedbacks?limit=1")
|
19
17
|
.to_return(status: 200, body: load_json(:feedback))
|
@@ -30,7 +28,6 @@ describe LHS::Record do
|
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'first!' do
|
33
|
-
|
34
31
|
it 'raises if nothing was found with parameters' do
|
35
32
|
stub_request(:get, "#{datastore}/feedbacks?limit=1")
|
36
33
|
.to_return(status: 404)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
let(:datastore) { 'http://local.ch/v2' }
|
6
5
|
before(:each) { LHC.config.placeholder('datastore', datastore) }
|
7
6
|
|
@@ -39,14 +38,14 @@ describe LHS::Record do
|
|
39
38
|
endpoint ':datastore/favorites/:id'
|
40
39
|
end
|
41
40
|
stub_request(:get, "#{datastore}/local-entries/1")
|
42
|
-
.to_return(body: {company_name: 'local.ch'}.to_json)
|
41
|
+
.to_return(body: { company_name: 'local.ch' }.to_json)
|
43
42
|
stub_request(:get, "#{datastore}/users/1")
|
44
|
-
.to_return(body: {name: 'Mario'}.to_json)
|
43
|
+
.to_return(body: { name: 'Mario' }.to_json)
|
45
44
|
stub_request(:get, "#{datastore}/favorites/1")
|
46
45
|
.to_return(body: {
|
47
|
-
local_entry: {href: "#{datastore}/local-entries/1"},
|
48
|
-
user: {href: "#{datastore}/users/1"}
|
49
|
-
|
46
|
+
local_entry: { href: "#{datastore}/local-entries/1" },
|
47
|
+
user: { href: "#{datastore}/users/1" }
|
48
|
+
}.to_json)
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'includes a resource' do
|
@@ -56,6 +55,7 @@ describe LHS::Record do
|
|
56
55
|
|
57
56
|
it 'includes a list of resources' do
|
58
57
|
favorite = Favorite.includes(:local_entry, :user).find(1)
|
58
|
+
expect(favorite.local_entry).to be_kind_of LocalEntry
|
59
59
|
expect(favorite.local_entry.company_name).to eq 'local.ch'
|
60
60
|
expect(favorite.user.name).to eq 'Mario'
|
61
61
|
end
|
@@ -68,7 +68,6 @@ describe LHS::Record do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'multilevel includes' do
|
71
|
-
|
72
71
|
before(:each) do
|
73
72
|
class Feedback < LHS::Record
|
74
73
|
endpoint ':datastore/feedbacks'
|
@@ -80,7 +79,6 @@ describe LHS::Record do
|
|
80
79
|
end
|
81
80
|
|
82
81
|
it 'includes linked resources while fetching multiple resources from one service' do
|
83
|
-
|
84
82
|
stub_request(:get, "#{datastore}/feedbacks?has_reviews=true")
|
85
83
|
.to_return(status: 200, body: {
|
86
84
|
items: [
|
@@ -96,7 +94,6 @@ describe LHS::Record do
|
|
96
94
|
end
|
97
95
|
|
98
96
|
it 'includes linked resources while fetching a single resource from one service' do
|
99
|
-
|
100
97
|
stub_request(:get, "#{datastore}/feedbacks/123")
|
101
98
|
.to_return(status: 200, body: {
|
102
99
|
'href' => "#{datastore}/feedbacks/-Sc4_pYNpqfsudzhtivfkA",
|
@@ -108,7 +105,6 @@ describe LHS::Record do
|
|
108
105
|
end
|
109
106
|
|
110
107
|
it 'includes linked resources with array while fetching a single resource from one service' do
|
111
|
-
|
112
108
|
stub_request(:get, "#{datastore}/feedbacks/123")
|
113
109
|
.to_return(status: 200, body: {
|
114
110
|
'href' => "#{datastore}/feedbacks/-Sc4_pYNpqfsudzhtivfkA",
|
@@ -121,7 +117,6 @@ describe LHS::Record do
|
|
121
117
|
end
|
122
118
|
|
123
119
|
it 'includes list of linked resources while fetching a single resource from one service' do
|
124
|
-
|
125
120
|
stub_request(:get, "#{datastore}/feedbacks/123")
|
126
121
|
.to_return(status: 200, body: {
|
127
122
|
'href' => "#{datastore}/feedbacks/-Sc4_pYNpqfsudzhtivfkA",
|
@@ -136,18 +131,17 @@ describe LHS::Record do
|
|
136
131
|
end
|
137
132
|
|
138
133
|
context 'include objects from known services' do
|
139
|
-
|
140
134
|
let(:stub_feedback_request) do
|
141
135
|
stub_request(:get, "#{datastore}/feedbacks")
|
142
136
|
.to_return(status: 200, body: {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
}
|
137
|
+
items: [
|
138
|
+
{
|
139
|
+
'href' => "#{datastore}/feedbacks/-Sc4_pYNpqfsudzhtivfkA",
|
140
|
+
'entry' => {
|
141
|
+
'href' => "#{datastore}/local-entries/lakj35asdflkj1203va"
|
149
142
|
}
|
150
|
-
|
143
|
+
}
|
144
|
+
]
|
151
145
|
}.to_json)
|
152
146
|
end
|
153
147
|
|
@@ -160,6 +154,7 @@ describe LHS::Record do
|
|
160
154
|
end
|
161
155
|
|
162
156
|
it 'uses interceptors for included links from known services' do
|
157
|
+
# rubocop:disable RSpec/InstanceVariable
|
163
158
|
stub_feedback_request
|
164
159
|
stub_entry_request
|
165
160
|
|
@@ -168,12 +163,12 @@ describe LHS::Record do
|
|
168
163
|
|
169
164
|
expect(Feedback.includes(:entry).where.first.entry.name).to eq 'Casa Ferlin'
|
170
165
|
expect(@called).to eq 2
|
166
|
+
# rubocop:enable RSpec/InstanceVariable
|
171
167
|
end
|
172
168
|
end
|
173
169
|
end
|
174
170
|
|
175
171
|
context 'links pointing to nowhere' do
|
176
|
-
|
177
172
|
it 'sets nil for links that cannot be included' do
|
178
173
|
class Feedback < LHS::Record
|
179
174
|
endpoint ':datastore/feedbacks'
|
data/spec/record/mapping_spec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
context 'mapping' do
|
6
|
-
|
7
5
|
let(:datastore) { 'http://local.ch/v2' }
|
8
6
|
|
9
7
|
before(:each) do
|
@@ -21,7 +19,7 @@ describe LHS::Record do
|
|
21
19
|
end
|
22
20
|
end
|
23
21
|
stub_request(:get, "#{datastore}/local-entries/1")
|
24
|
-
.to_return(status: 200, body: {addresses: [{business: {identities: [{name: 'Löwenzorn'}]}}]}.to_json)
|
22
|
+
.to_return(status: 200, body: { addresses: [{ business: { identities: [{ name: 'Löwenzorn' }] } }] }.to_json)
|
25
23
|
entry = LocalEntry.find(1)
|
26
24
|
expect(entry.name).to eq 'Löwenzorn'
|
27
25
|
end
|
@@ -33,7 +31,7 @@ describe LHS::Record do
|
|
33
31
|
end
|
34
32
|
end
|
35
33
|
stub_request(:get, "#{datastore}/local-entries/1?limit=1")
|
36
|
-
.to_return(status: 200, body: {items: [{addresses: [{business: {identities: [{name: 'Löwenzorn'}]}}]}]}.to_json)
|
34
|
+
.to_return(status: 200, body: { items: [{ addresses: [{ business: { identities: [{ name: 'Löwenzorn' }] } }] }] }.to_json)
|
37
35
|
entry = LocalEntry.find_by(id: 1)
|
38
36
|
expect(entry.name).to eq 'Löwenzorn'
|
39
37
|
end
|
@@ -45,7 +43,7 @@ describe LHS::Record do
|
|
45
43
|
end
|
46
44
|
end
|
47
45
|
stub_request(:get, "#{datastore}/local-entries/1")
|
48
|
-
.to_return(status: 200, body: {addresses: [{business: {identities: [{name: 'Löwenzorn'}]}}]}.to_json)
|
46
|
+
.to_return(status: 200, body: { addresses: [{ business: { identities: [{ name: 'Löwenzorn' }] } }] }.to_json)
|
49
47
|
entry = LocalEntry.find(1)
|
50
48
|
expect(entry.business).to be_kind_of LHS::Data
|
51
49
|
end
|
@@ -60,14 +58,14 @@ describe LHS::Record do
|
|
60
58
|
|
61
59
|
preceding_agb_url = "#{datastore}/agbs/547f0b461c266c4830ea6cea"
|
62
60
|
# initial request
|
63
|
-
stub_request(:get, "#{datastore}/agbs/active?agb_type=CC_TOU&limit=1")
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
61
|
+
stub_request(:get, "#{datastore}/agbs/active?agb_type=CC_TOU&limit=1")
|
62
|
+
.to_return(
|
63
|
+
status: 200,
|
64
|
+
body: {
|
65
|
+
'href' => "#{datastore}/agbs/547f02c61c266c4830ea6ce7",
|
66
|
+
'preceding_agb' => { 'href' => preceding_agb_url },
|
67
|
+
'binary_url_pdf_de' => 'de'
|
68
|
+
}.to_json)
|
71
69
|
|
72
70
|
# includes request
|
73
71
|
stub_request(:get, preceding_agb_url).to_return(
|
@@ -89,9 +87,9 @@ describe LHS::Record do
|
|
89
87
|
endpoint ':datastore/favorites/:id'
|
90
88
|
end
|
91
89
|
stub_request(:get, "#{datastore}/local-entries/1")
|
92
|
-
.to_return(body: {company_name: 'local.ch'}.to_json)
|
90
|
+
.to_return(body: { company_name: 'local.ch' }.to_json)
|
93
91
|
stub_request(:get, "#{datastore}/favorites/1")
|
94
|
-
.to_return(body: {local_entry: {href: "#{datastore}/local-entries/1"}}.to_json)
|
92
|
+
.to_return(body: { local_entry: { href: "#{datastore}/local-entries/1" } }.to_json)
|
95
93
|
|
96
94
|
favorite = Favorite.includes(:local_entry).find(1)
|
97
95
|
expect(favorite.local_entry).to be_kind_of LocalEntry
|
data/spec/record/new_spec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
context 'new' do
|
6
|
-
|
7
5
|
let(:datastore) { 'http://local.ch/v2' }
|
8
6
|
|
9
7
|
before(:each) do
|
@@ -22,5 +20,9 @@ describe LHS::Record do
|
|
22
20
|
.with(body: "{\"recommended\":true}")
|
23
21
|
feedback.save
|
24
22
|
end
|
23
|
+
|
24
|
+
it 'builds new items also with keys containing dashes' do
|
25
|
+
Feedback.new('some-key' => [])
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
data/spec/record/request_spec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe LHS::Record do
|
4
|
-
|
5
4
|
context 'url pattern' do
|
6
|
-
|
7
5
|
let(:datastore) { 'http://local.ch/v2' }
|
8
6
|
|
9
7
|
before(:each) do
|
@@ -16,7 +14,7 @@ describe LHS::Record do
|
|
16
14
|
|
17
15
|
it 'is using params as query params explicitly when provided in params namespace' do
|
18
16
|
stub_request(:get, "#{datastore}/content-ads/123/feedbacks?campaign_id=456").to_return(status: 200)
|
19
|
-
|
17
|
+
Record.where(campaign_id: 123, params: { campaign_id: '456' })
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|