lhs 14.6.5 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +68 -68
- data/lhs.gemspec +1 -1
- data/lib/lhs/concerns/record/endpoints.rb +1 -1
- data/lib/lhs/concerns/record/request.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/autoloading_spec.rb +2 -2
- data/spec/collection/collection_items_spec.rb +1 -1
- data/spec/collection/configurable_spec.rb +1 -1
- data/spec/collection/meta_data_spec.rb +4 -4
- data/spec/collection/without_object_items_spec.rb +1 -1
- data/spec/data/collection_spec.rb +1 -1
- data/spec/data/inspect_spec.rb +1 -1
- data/spec/data/item_spec.rb +2 -2
- data/spec/data/merge_spec.rb +2 -2
- data/spec/data/raw_spec.rb +3 -3
- data/spec/data/root_spec.rb +3 -3
- data/spec/data/select_spec.rb +1 -1
- data/spec/data/to_json_spec.rb +2 -2
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/endpoint/for_url_spec.rb +6 -6
- data/spec/item/becomes_spec.rb +2 -2
- data/spec/item/delegate_spec.rb +2 -2
- data/spec/item/destroy_spec.rb +3 -3
- data/spec/item/dig_spec.rb +1 -1
- data/spec/item/errors_spec.rb +2 -2
- data/spec/item/fetch_spec.rb +1 -1
- data/spec/item/getter_spec.rb +2 -2
- data/spec/item/internal_data_structure_spec.rb +2 -2
- data/spec/item/map_spec.rb +1 -1
- data/spec/item/partial_update_spec.rb +4 -4
- data/spec/item/save_spec.rb +2 -2
- data/spec/item/setter_spec.rb +2 -2
- data/spec/item/update_spec.rb +2 -2
- data/spec/item/validation_spec.rb +2 -2
- data/spec/pagination/pages_left_spec.rb +1 -1
- data/spec/proxy/create_sub_resource_spec.rb +2 -2
- data/spec/proxy/load_spec.rb +2 -2
- data/spec/proxy/record_identification_spec.rb +1 -1
- data/spec/record/build_spec.rb +2 -2
- data/spec/record/cast_nested_data_spec.rb +6 -6
- data/spec/record/create_spec.rb +2 -2
- data/spec/record/creation_failed_spec.rb +2 -2
- data/spec/record/definitions_spec.rb +2 -2
- data/spec/record/destroy_spec.rb +1 -1
- data/spec/record/endpoint_inheritance_spec.rb +3 -3
- data/spec/record/endpoint_misconfiguration_spec.rb +4 -4
- data/spec/record/endpoint_options_spec.rb +1 -1
- data/spec/record/endpoints_spec.rb +19 -19
- data/spec/record/find_by_spec.rb +4 -4
- data/spec/record/find_each_spec.rb +2 -2
- data/spec/record/find_in_batches_spec.rb +4 -4
- data/spec/record/find_in_parallel_spec.rb +1 -1
- data/spec/record/find_spec.rb +4 -4
- data/spec/record/first_spec.rb +2 -2
- data/spec/record/has_many_spec.rb +1 -1
- data/spec/record/ignore_errors_spec.rb +1 -1
- data/spec/record/includes_all_spec.rb +7 -7
- data/spec/record/includes_spec.rb +28 -28
- data/spec/record/includes_warning_spec.rb +1 -1
- data/spec/record/item_key_spec.rb +1 -1
- data/spec/record/loading_twice_spec.rb +2 -2
- data/spec/record/mapping_spec.rb +5 -5
- data/spec/record/model_name_spec.rb +1 -1
- data/spec/record/new_spec.rb +3 -3
- data/spec/record/options_spec.rb +2 -2
- data/spec/record/paginatable_collection_spec.rb +4 -4
- data/spec/record/pagination_chain_spec.rb +3 -3
- data/spec/record/pagination_spec.rb +1 -1
- data/spec/record/persisted_spec.rb +1 -1
- data/spec/record/references_spec.rb +1 -1
- data/spec/record/reload_by_id_spec.rb +2 -2
- data/spec/record/reload_spec.rb +2 -2
- data/spec/record/request_spec.rb +6 -6
- data/spec/record/save_spec.rb +1 -1
- data/spec/record/scope_chains_spec.rb +1 -1
- data/spec/record/to_json_spec.rb +1 -1
- data/spec/record/where_chains_spec.rb +1 -1
- data/spec/record/where_spec.rb +2 -2
- data/spec/record/where_values_hash_spec.rb +1 -1
- data/spec/request_cycle_cache/main_spec.rb +1 -1
- data/spec/views/form_for_spec.rb +1 -1
- metadata +5 -5
@@ -82,7 +82,7 @@ class LHS::Record
|
|
82
82
|
# The best endpoint is the one where all placeholders are interpolated.
|
83
83
|
def find_best_endpoint(params)
|
84
84
|
sorted_endpoints.find do |endpoint|
|
85
|
-
endpoint.placeholders.all? { |match| endpoint.find_value(match, params) }
|
85
|
+
endpoint.placeholders.all? { |match| endpoint.find_value(match, params).present? }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/lhs/version.rb
CHANGED
data/spec/autoloading_spec.rb
CHANGED
@@ -7,12 +7,12 @@ describe LHS, type: :request do
|
|
7
7
|
cleanup_before: false do
|
8
8
|
all_endpoints = LHS::Record::Endpoints.all
|
9
9
|
expect(all_endpoints['http://datastore/v2/users']).to be
|
10
|
-
expect(all_endpoints['http://datastore/v2/users
|
10
|
+
expect(all_endpoints['http://datastore/v2/users/{id}']).to be
|
11
11
|
expect(
|
12
12
|
User.endpoints.detect { |endpoint| endpoint.url == 'http://datastore/v2/users' }
|
13
13
|
).to be
|
14
14
|
expect(
|
15
|
-
User.endpoints.detect { |endpoint| endpoint.url == 'http://datastore/v2/users
|
15
|
+
User.endpoints.detect { |endpoint| endpoint.url == 'http://datastore/v2/users/{id}' }
|
16
16
|
).to be
|
17
17
|
end
|
18
18
|
end
|
@@ -8,7 +8,7 @@ describe LHS::Collection do
|
|
8
8
|
before(:each) do
|
9
9
|
LHC.config.placeholder('datastore', datastore)
|
10
10
|
class Account < LHS::Record
|
11
|
-
endpoint '
|
11
|
+
endpoint '{+datastore}/accounts'
|
12
12
|
end
|
13
13
|
stub_request(:get, "http://local.ch/v2/accounts")
|
14
14
|
.to_return(body: response_data.to_json)
|
@@ -9,7 +9,7 @@ describe LHS::Collection do
|
|
9
9
|
LHC.config.placeholder('search', search)
|
10
10
|
class Search < LHS::Record
|
11
11
|
configuration items_key: :docs, limit_key: :size, pagination_key: :start, pagination_strategy: :start, total_key: :totalResults
|
12
|
-
endpoint '
|
12
|
+
endpoint '{+search}/{type}'
|
13
13
|
end
|
14
14
|
stub_request(:get, "http://local.ch/search/phonebook?size=10").to_return(
|
15
15
|
body: {
|
@@ -29,12 +29,12 @@ describe LHS::Collection do
|
|
29
29
|
before(:each) do
|
30
30
|
LHC.config.placeholder('datastore', datastore)
|
31
31
|
class Feedback < LHS::Record
|
32
|
-
endpoint '
|
33
|
-
endpoint '
|
32
|
+
endpoint '{+datastore}/feedbacks'
|
33
|
+
endpoint '{+datastore}/feedbacks/{id}'
|
34
34
|
end
|
35
35
|
class User < LHS::Record
|
36
|
-
endpoint '
|
37
|
-
endpoint '
|
36
|
+
endpoint '{+datastore}/users'
|
37
|
+
endpoint '{+datastore}/users/{id}'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/spec/data/inspect_spec.rb
CHANGED
data/spec/data/item_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Data do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/data/merge_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Data do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/data/raw_spec.rb
CHANGED
@@ -3,9 +3,9 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Data do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
8
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/entries/{entry_id}/content-ads/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
8
|
+
endpoint '{+datastore}/v2/feedbacks'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/spec/data/root_spec.rb
CHANGED
@@ -3,9 +3,9 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Data do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
8
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/entries/{entry_id}/content-ads/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
8
|
+
endpoint '{+datastore}/v2/feedbacks'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/spec/data/select_spec.rb
CHANGED
data/spec/data/to_json_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Data do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -4,22 +4,22 @@ describe LHS::Endpoint do
|
|
4
4
|
context 'for url' do
|
5
5
|
before(:each) do
|
6
6
|
class Record < LHS::Record
|
7
|
-
endpoint '
|
8
|
-
endpoint '
|
9
|
-
endpoint '
|
7
|
+
endpoint '{+datastore}/entries/{entry_id}/content-ads/{campaign_id}/feedbacks'
|
8
|
+
endpoint '{+datastore}/{campaign_id}/feedbacks'
|
9
|
+
endpoint '{+datastore}/feedbacks'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'provides the endpoint for a given url' do
|
14
14
|
expect(
|
15
15
|
LHS::Endpoint.for_url('http://local.ch/v2/entries/123/content-ads/456/feedbacks').url
|
16
|
-
).to eq '
|
16
|
+
).to eq '{+datastore}/entries/{entry_id}/content-ads/{campaign_id}/feedbacks'
|
17
17
|
expect(
|
18
18
|
LHS::Endpoint.for_url('http://local.ch/123/feedbacks').url
|
19
|
-
).to eq '
|
19
|
+
).to eq '{+datastore}/{campaign_id}/feedbacks'
|
20
20
|
expect(
|
21
21
|
LHS::Endpoint.for_url('http://local.ch/feedbacks').url
|
22
|
-
).to eq '
|
22
|
+
).to eq '{+datastore}/feedbacks'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/spec/item/becomes_spec.rb
CHANGED
@@ -4,11 +4,11 @@ describe LHS::Item do
|
|
4
4
|
before(:each) do
|
5
5
|
class Location < LHS::Record
|
6
6
|
endpoint 'http://sync/locations'
|
7
|
-
endpoint 'http://sync/locations
|
7
|
+
endpoint 'http://sync/locations/{id}'
|
8
8
|
end
|
9
9
|
|
10
10
|
class Synchronization < LHS::Record
|
11
|
-
endpoint 'http://sync/locations
|
11
|
+
endpoint 'http://sync/locations/{id}/sync'
|
12
12
|
end
|
13
13
|
|
14
14
|
stub_request(:get, "http://sync/locations/1")
|
data/spec/item/delegate_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/item/destroy_spec.rb
CHANGED
@@ -4,8 +4,8 @@ describe LHS::Item do
|
|
4
4
|
before(:each) do
|
5
5
|
LHC.config.placeholder('datastore', datastore)
|
6
6
|
class Record < LHS::Record
|
7
|
-
endpoint '
|
8
|
-
endpoint '
|
7
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
8
|
+
endpoint '{+datastore}/v2/feedbacks'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -42,7 +42,7 @@ describe LHS::Item do
|
|
42
42
|
context 'includes and empty response' do
|
43
43
|
before(:each) do
|
44
44
|
class AnotherRecord < LHS::Record
|
45
|
-
endpoint '
|
45
|
+
endpoint '{+datastore}/v2/:campaign_id/restaurants'
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/spec/item/dig_spec.rb
CHANGED
data/spec/item/errors_spec.rb
CHANGED
@@ -55,8 +55,8 @@ describe LHS::Item do
|
|
55
55
|
I18n.backend.store_translations(:en, {}) if defined? translations
|
56
56
|
LHC.config.placeholder(:datastore, datastore)
|
57
57
|
class Record < LHS::Record
|
58
|
-
endpoint '
|
59
|
-
endpoint '
|
58
|
+
endpoint '{+datastore}/{campaign_id}/feedbacks'
|
59
|
+
endpoint '{+datastore}/feedbacks'
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
data/spec/item/fetch_spec.rb
CHANGED
data/spec/item/getter_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Feedback < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks/{id}'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/item/map_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -65,7 +65,7 @@ describe LHS::Item do
|
|
65
65
|
before(:each) do
|
66
66
|
class Location < LHS::Record
|
67
67
|
endpoint 'http://uberall/locations'
|
68
|
-
endpoint 'http://uberall/locations
|
68
|
+
endpoint 'http://uberall/locations/{id}'
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -83,7 +83,7 @@ describe LHS::Item do
|
|
83
83
|
before(:each) do
|
84
84
|
class Location < LHS::Record
|
85
85
|
endpoint 'http://uberall/locations'
|
86
|
-
endpoint 'http://uberall/locations
|
86
|
+
endpoint 'http://uberall/locations/{id}'
|
87
87
|
configuration item_created_key: [:response, :location], item_key: [:response, :location]
|
88
88
|
end
|
89
89
|
end
|
data/spec/item/save_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/item/setter_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
data/spec/item/update_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
7
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/{campaign_id}/feedbacks'
|
7
|
+
endpoint '{+datastore}/v2/feedbacks'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -100,7 +100,7 @@ describe LHS::Item do
|
|
100
100
|
context 'endpoint does not support validations' do
|
101
101
|
before(:each) do
|
102
102
|
class Favorite < LHS::Record
|
103
|
-
endpoint '
|
103
|
+
endpoint '{+datastore}/v2/favorites'
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -114,7 +114,7 @@ describe LHS::Item do
|
|
114
114
|
context 'generate validation url from locally passed params' do
|
115
115
|
before(:each) do
|
116
116
|
class User < LHS::Record
|
117
|
-
endpoint 'http://datastore/v2/users
|
117
|
+
endpoint 'http://datastore/v2/users/{user_id}', validates: { params: { persist: false } }
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -3,11 +3,11 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Item do
|
4
4
|
before(:each) do
|
5
5
|
class Feedback < LHS::Record
|
6
|
-
endpoint 'http://datastore/v2/feedbacks
|
6
|
+
endpoint 'http://datastore/v2/feedbacks/{id}'
|
7
7
|
end
|
8
8
|
|
9
9
|
class Review < LHS::Record
|
10
|
-
endpoint 'http://datastore/v2/feedbacks
|
10
|
+
endpoint 'http://datastore/v2/feedbacks/{feedback_id}/reviews'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
data/spec/proxy/load_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Proxy do
|
4
4
|
before(:each) do
|
5
5
|
class Record < LHS::Record
|
6
|
-
endpoint '
|
6
|
+
endpoint '{+datastore}/v2/feedbacks'
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -46,7 +46,7 @@ describe LHS::Proxy do
|
|
46
46
|
context 'endpoint options' do
|
47
47
|
before(:each) do
|
48
48
|
class AnotherRecord < LHS::Record
|
49
|
-
endpoint '
|
49
|
+
endpoint '{+datastore}/v2/feedbacks', params: { color: :blue }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|