apress-yandex_market 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/apress/yandex_market/readers/model_by_category.rb +2 -1
- data/lib/apress/yandex_market/version.rb +1 -1
- data/spec/apress/yandex_market/readers/model_by_category_spec.rb +26 -7
- data/spec/fixtures/read_models_without_category.yml +29960 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f6def217c9f110df4c22f0b606f7fa25d53a42c
|
4
|
+
data.tar.gz: 3a89225ca053beafc5d34ba50353c5a4240c512d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83f6544a41c4369f75b153484fb674b4e12a2f1d96c1aaa9195ac9fbcb2e42f76b0a65261b982f7d0f2dfcdaa9b11d14b064e1a3a1655a0ddb6f3e11333452c3
|
7
|
+
data.tar.gz: 3c5dfad011d5b954ce12b71e2230bd62431a82eb14f31ab8f240f53f8176858e58d3d110a850074cb592a7490d427943e82df16ada9908f7dde68580048adf06
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.1.1
|
2
|
+
|
3
|
+
* 2019-01-24 [d3d7504](../../commit/d3d7504) - __(Mikhail Nelaev)__ Release 0.1.1
|
4
|
+
* 2019-01-14 [ad33bf3](../../commit/ad33bf3) - __(Mikhail Nelaev)__ fix: яндекс может отдавать модели без категории
|
5
|
+
https://jira.railsc.ru/browse/GOODS-1610
|
6
|
+
|
1
7
|
# v0.1.0
|
2
8
|
|
3
9
|
* 2018-12-24 [b5adb2b](../../commit/b5adb2b) - __(Mikhail Nelaev)__ fix: получаем все корневые категории
|
@@ -109,7 +109,8 @@ module Apress
|
|
109
109
|
models = get_models(category_id, page, sort_direction)
|
110
110
|
|
111
111
|
models.each do |model|
|
112
|
-
next
|
112
|
+
next unless model[:category].is_a? Hash
|
113
|
+
next if category_id != model[:category][:id]
|
113
114
|
return if processed_models.include? model
|
114
115
|
|
115
116
|
processed_models << model
|
@@ -9,21 +9,40 @@ describe Apress::YandexMarket::Readers::ModelByCategory do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#each_row' do
|
12
|
-
let(:rows) { [] }
|
13
|
-
|
14
12
|
before do
|
15
13
|
allow(reader.category_reader.client).to receive(:get).and_call_original
|
16
14
|
allow(reader.category_reader.client).to receive(:get).with('categories/90509/children', anything).
|
17
15
|
and_return(categories: [{id: 8_476_099, childCount: 0}])
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'valid models' do
|
19
|
+
let(:rows) { [] }
|
20
|
+
|
21
|
+
before do
|
22
|
+
VCR.use_cassette 'read_models_from_category' do
|
23
|
+
reader.each_row { |row| rows << row }
|
24
|
+
end
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
27
|
+
it 'reads models of specified categories and their subcategories' do
|
28
|
+
expect(rows).to have(840).items
|
29
|
+
expect(rows.uniq).to have(840).items
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
context 'when some models do not have category' do
|
34
|
+
let(:rows) { [] }
|
35
|
+
|
36
|
+
before do
|
37
|
+
VCR.use_cassette 'read_models_without_category' do
|
38
|
+
reader.each_row { |row| rows << row }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'reads models of specified categories and their subcategories' do
|
43
|
+
expect(rows).to have(838).items
|
44
|
+
expect(rows.uniq).to have(838).items
|
45
|
+
end
|
27
46
|
end
|
28
47
|
end
|
29
48
|
end
|