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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b62a9a0c7db6767fe9559e3e07cfefd0b1bed4f
4
- data.tar.gz: 712a1629589d5f6db999c62fb6f3b547e49cd705
3
+ metadata.gz: 1f6def217c9f110df4c22f0b606f7fa25d53a42c
4
+ data.tar.gz: 3a89225ca053beafc5d34ba50353c5a4240c512d
5
5
  SHA512:
6
- metadata.gz: 4a0840fceb8743f97872f44240717414b55cf0dc3632dd24c6bc22511375cb98bf267e97cff3bbf2b38157c7feceb515d5cdb8aaad1f966d181b1a7a6d9fa19d
7
- data.tar.gz: 4b605819f184624087a2ff58bf156560ebf84af744df6977250d0589daf5d4c7ab049f9b4c8b9d36445ced72749b9897b7700b290d0c88dfb96ba0c31302473d
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 if category_id != model.fetch(:category).fetch(:id)
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
@@ -1,5 +1,5 @@
1
1
  module Apress
2
2
  module YandexMarket
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -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
- VCR.use_cassette 'read_models_from_category' do
20
- reader.each_row { |row| rows << row }
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
- it 'reads models of specified categories and their subcategories' do
25
- expect(rows).to have(840).items
26
- expect(rows.uniq).to have(840).items
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