workarea-google_product_feed 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +35 -0
- data/.github/workflows/ci.yml +57 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.stylelintrc.json +8 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -2
- data/README.md +12 -30
- data/Rakefile +4 -5
- data/app/view_models/workarea/storefront/google_product_feed_sku_view_model.rb +36 -2
- data/app/view_models/workarea/storefront/google_product_feed_view_model.rb +1 -28
- data/app/workers/workarea/exporting/google_feed.rb +48 -47
- data/lib/workarea/google_product_feed/version.rb +1 -1
- data/test/view_models/workarea/storefront/google_product_feed_sku_view_model_test.rb +19 -0
- data/test/view_models/workarea/storefront/google_product_feed_view_model_test.rb +0 -17
- data/test/workers/workarea/exporting/google_feed_test.rb +62 -36
- metadata +8 -5
- data/LICENSE.md +0 -3
- data/test/dummy/config/initializers/session_store.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03e26350c3f916f9ae601273c55736f1b4d34373551688b85e017e01d549f637
|
4
|
+
data.tar.gz: f4ca1509a48ab0b2ec333a2216869e884d6803b5206dba89eba4218e1000a2b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9bb325114a15917dc8619f78e8b83403ce95df983fd3d1832f0cc6a8f738f76ba103b2be2351cb40dec6c13aa0206400754d1adc904748d9525062d98df8c0e
|
7
|
+
data.tar.gz: 6a36fc03725b1bd3a20f7901aeaaf1585a7f257a7535480987cb357540c0db107c1874714bea3e249d11e76387aceda4040d87089700ff036c28a5d1c1b42632
|
data/.eslintrc.json
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"extends": "eslint:recommended",
|
3
|
+
"rules": {
|
4
|
+
"semi": ["error", "always"],
|
5
|
+
"eqeqeq": ["error", "always"]
|
6
|
+
},
|
7
|
+
"globals": {
|
8
|
+
"window": true,
|
9
|
+
"document": true,
|
10
|
+
"WORKAREA": true,
|
11
|
+
"$": true,
|
12
|
+
"jQuery": true,
|
13
|
+
"_": true,
|
14
|
+
"feature": true,
|
15
|
+
"JST": true,
|
16
|
+
"Turbolinks": true,
|
17
|
+
"I18n": true,
|
18
|
+
"Chart": true,
|
19
|
+
"Dropzone": true,
|
20
|
+
"strftime": true,
|
21
|
+
"Waypoint": true,
|
22
|
+
"wysihtml": true,
|
23
|
+
"LocalTime": true,
|
24
|
+
"describe": true,
|
25
|
+
"after": true,
|
26
|
+
"afterEach": true,
|
27
|
+
"before": true,
|
28
|
+
"beforeEach": true,
|
29
|
+
"it": true,
|
30
|
+
"expect": true,
|
31
|
+
"sinon": true,
|
32
|
+
"fixture": true,
|
33
|
+
"chai": true
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
static_analysis:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v1
|
9
|
+
- uses: workarea-commerce/ci/bundler-audit@v1
|
10
|
+
- uses: workarea-commerce/ci/rubocop@v1
|
11
|
+
- uses: workarea-commerce/ci/eslint@v1
|
12
|
+
with:
|
13
|
+
args: '**/*.js'
|
14
|
+
|
15
|
+
admin_tests:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v1
|
19
|
+
- uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: 2.6.x
|
22
|
+
- uses: workarea-commerce/ci/test@v1
|
23
|
+
with:
|
24
|
+
command: bin/rails app:workarea:test:admin
|
25
|
+
|
26
|
+
core_tests:
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v1
|
30
|
+
- uses: actions/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: 2.6.x
|
33
|
+
- uses: workarea-commerce/ci/test@v1
|
34
|
+
with:
|
35
|
+
command: bin/rails app:workarea:test:core
|
36
|
+
|
37
|
+
storefront_tests:
|
38
|
+
runs-on: ubuntu-latest
|
39
|
+
steps:
|
40
|
+
- uses: actions/checkout@v1
|
41
|
+
- uses: actions/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
ruby-version: 2.6.x
|
44
|
+
- uses: workarea-commerce/ci/test@v1
|
45
|
+
with:
|
46
|
+
command: bin/rails app:workarea:test:storefront
|
47
|
+
|
48
|
+
plugins_tests:
|
49
|
+
runs-on: ubuntu-latest
|
50
|
+
steps:
|
51
|
+
- uses: actions/checkout@v1
|
52
|
+
- uses: actions/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: 2.6.x
|
55
|
+
- uses: workarea-commerce/ci/test@v1
|
56
|
+
with:
|
57
|
+
command: bin/rails app:workarea:test:plugins
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.stylelintrc.json
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
Workarea Google Product Feed 3.2.0 (2020-06-16)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Use image that matches the SKU
|
5
|
+
|
6
|
+
* now using variant images if one exists
|
7
|
+
|
8
|
+
* memoized image in google_product_feed_sku_view_model
|
9
|
+
|
10
|
+
* Moved methods to private, calling product_view_model primary_image instead of directly going to the ImageCollection
|
11
|
+
|
12
|
+
* Getting variant image the workarea way
|
13
|
+
|
14
|
+
JurgenHahn
|
15
|
+
|
16
|
+
* Added inventory column. Inventory returns 0 if no inventory_sku present.
|
17
|
+
|
18
|
+
|
19
|
+
JurgenHahn
|
20
|
+
|
21
|
+
* Update README
|
22
|
+
|
23
|
+
|
24
|
+
Matt Duffy
|
25
|
+
|
26
|
+
|
27
|
+
|
1
28
|
Workarea Google Product Feed 3.1.4 (2019-08-22)
|
2
29
|
--------------------------------------------------------------------------------
|
3
30
|
|
data/Gemfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
git_source(:github) { |repo| "
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
3
|
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'workarea'
|
6
|
+
gem 'workarea', github: 'workarea-commerce/workarea', branch: 'v3.5-stable'
|
7
7
|
|
8
8
|
group :test do
|
9
9
|
gem 'simplecov', require: false
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
Workarea Google
|
1
|
+
Workarea Google Product Feed
|
2
2
|
================================================================================
|
3
|
-
Google Production Feed for the Workarea Platform
|
4
3
|
|
4
|
+
Google Product Feed for the Workarea Platform
|
5
5
|
|
6
6
|
Google category
|
7
7
|
--------------------------------------------------------------------------------
|
@@ -17,45 +17,27 @@ The workarea platform implements this field by:
|
|
17
17
|
Getting Started
|
18
18
|
--------------------------------------------------------------------------------
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
```bash
|
23
|
-
$ bundle config gems.weblinc.com my_username:my_password
|
24
|
-
```
|
25
|
-
|
26
|
-
Or set the appropriate environment variable in a shell startup file:
|
27
|
-
|
28
|
-
```bash
|
29
|
-
$ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
|
30
|
-
```
|
31
|
-
|
32
|
-
Then add the gem to your application's Gemfile specifying the source:
|
20
|
+
Add the gem to your application's Gemfile:
|
33
21
|
|
34
22
|
```ruby
|
35
23
|
# ...
|
36
|
-
gem 'workarea-google_product_feed'
|
37
|
-
# ...
|
38
|
-
```
|
39
|
-
|
40
|
-
Or use a source block:
|
41
|
-
|
42
|
-
```ruby
|
43
|
-
# ...
|
44
|
-
source 'https://gems.weblinc.com' do
|
45
|
-
gem 'workarea-google_product_feed'
|
46
|
-
end
|
24
|
+
gem 'workarea-google_product_feed'
|
47
25
|
# ...
|
48
26
|
```
|
49
27
|
|
50
28
|
Update your application's bundle.
|
51
29
|
|
52
30
|
```bash
|
53
|
-
|
31
|
+
cd path/to/application
|
32
|
+
bundle
|
54
33
|
```
|
55
34
|
|
56
|
-
|
35
|
+
Workarea Commerce Documentation
|
57
36
|
--------------------------------------------------------------------------------
|
58
37
|
|
59
|
-
|
38
|
+
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
|
39
|
+
|
40
|
+
License
|
41
|
+
--------------------------------------------------------------------------------
|
60
42
|
|
61
|
-
|
43
|
+
Workarea Google Product Feed is released under the [Business Software License](LICENSE)
|
data/Rakefile
CHANGED
@@ -38,13 +38,12 @@ desc "Release version #{Workarea::GoogleProductFeed::VERSION} of the gem"
|
|
38
38
|
task :release do
|
39
39
|
host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#system 'git push origin HEAD'
|
41
|
+
Rake::Task['workarea:changelog'].execute
|
42
|
+
system 'git add CHANGELOG.md'
|
43
|
+
system 'git commit -m "Update CHANGELOG"'
|
45
44
|
|
46
45
|
system "git tag -a v#{Workarea::GoogleProductFeed::VERSION} -m 'Tagging #{Workarea::GoogleProductFeed::VERSION}'"
|
47
|
-
system 'git push --tags'
|
46
|
+
system 'git push origin HEAD --follow-tags'
|
48
47
|
|
49
48
|
system 'gem build workarea-google_product_feed.gemspec'
|
50
49
|
system "gem push workarea-google_product_feed-#{Workarea::GoogleProductFeed::VERSION}.gem"
|
@@ -1,6 +1,18 @@
|
|
1
1
|
module Workarea
|
2
2
|
module Storefront
|
3
3
|
class GoogleProductFeedSkuViewModel < ApplicationViewModel
|
4
|
+
module ProductImageUrl
|
5
|
+
include Workarea::ApplicationHelper
|
6
|
+
include Workarea::I18n::DefaultUrlOptions
|
7
|
+
include ActionView::Helpers::AssetUrlHelper
|
8
|
+
include Core::Engine.routes.url_helpers
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def mounted_core
|
12
|
+
self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
4
16
|
def status
|
5
17
|
model.active? ? 'in stock' : 'out of stock'
|
6
18
|
end
|
@@ -13,14 +25,36 @@ module Workarea
|
|
13
25
|
'new'
|
14
26
|
end
|
15
27
|
|
28
|
+
def image_url
|
29
|
+
return unless image.present?
|
30
|
+
ProductImageUrl.product_image_url(image, GoogleProductFeed.image_size)
|
31
|
+
end
|
32
|
+
|
16
33
|
def size
|
17
34
|
Array.wrap(model.fetch_detail('size')).first
|
18
35
|
end
|
19
36
|
|
37
|
+
def inventory
|
38
|
+
inventory_sku? ? inventory_sku.available_to_sell : 0
|
39
|
+
end
|
40
|
+
|
20
41
|
def displayable?
|
21
|
-
|
22
|
-
options[:inventory_sku].displayable?
|
42
|
+
inventory_sku? ? inventory_sku.displayable? : false
|
23
43
|
end
|
44
|
+
|
45
|
+
def inventory_sku
|
46
|
+
options[:inventory_sku]
|
47
|
+
end
|
48
|
+
|
49
|
+
def inventory_sku?
|
50
|
+
options[:inventory_sku].present?
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def image
|
56
|
+
@image ||= Storefront::ProductViewModel.wrap(product, sku: model.sku).primary_image
|
57
|
+
end
|
24
58
|
end
|
25
59
|
end
|
26
60
|
end
|
@@ -1,17 +1,6 @@
|
|
1
1
|
module Workarea
|
2
2
|
module Storefront
|
3
3
|
class GoogleProductFeedViewModel < ApplicationViewModel
|
4
|
-
module ProductImageUrl
|
5
|
-
include Workarea::ApplicationHelper
|
6
|
-
include Workarea::I18n::DefaultUrlOptions
|
7
|
-
include ActionView::Helpers::AssetUrlHelper
|
8
|
-
include Core::Engine.routes.url_helpers
|
9
|
-
extend self
|
10
|
-
|
11
|
-
def mounted_core
|
12
|
-
self
|
13
|
-
end
|
14
|
-
end
|
15
4
|
include ActionView::Helpers::SanitizeHelper
|
16
5
|
include ActionView::Helpers::TextHelper
|
17
6
|
|
@@ -24,6 +13,7 @@ module Workarea
|
|
24
13
|
'link',
|
25
14
|
'image_link',
|
26
15
|
'availability',
|
16
|
+
'inventory',
|
27
17
|
'condition',
|
28
18
|
'brand',
|
29
19
|
'color',
|
@@ -47,11 +37,6 @@ module Workarea
|
|
47
37
|
Workarea::GoogleProductFeed.default_category
|
48
38
|
end
|
49
39
|
|
50
|
-
# TODO this should be changed to return sku images if present
|
51
|
-
def image
|
52
|
-
ProductImageUrl.product_image_url(images.primary, GoogleProductFeed.image_size)
|
53
|
-
end
|
54
|
-
|
55
40
|
def meta_description
|
56
41
|
if model.meta_description.present?
|
57
42
|
sanitize_description(model.meta_description)
|
@@ -91,14 +76,6 @@ module Workarea
|
|
91
76
|
@categorization ||= Workarea::Categorization.new(model)
|
92
77
|
end
|
93
78
|
|
94
|
-
def host
|
95
|
-
Workarea.config.host
|
96
|
-
end
|
97
|
-
|
98
|
-
def images
|
99
|
-
@images ||= Storefront::ProductViewModel::ImageCollection.new(model, options)
|
100
|
-
end
|
101
|
-
|
102
79
|
def inventory
|
103
80
|
@inventory ||= Inventory::Collection.new(model.variants.map(&:sku))
|
104
81
|
end
|
@@ -107,10 +84,6 @@ module Workarea
|
|
107
84
|
@pricing ||= Pricing::Collection.new(model.variants.map(&:sku))
|
108
85
|
end
|
109
86
|
|
110
|
-
def primary_image
|
111
|
-
model.images.asc(:position).first
|
112
|
-
end
|
113
|
-
|
114
87
|
def sanitize_description(description)
|
115
88
|
return if description.nil?
|
116
89
|
|
@@ -29,62 +29,63 @@ module Workarea
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def ensure_directory
|
33
|
+
directory = File.dirname(GoogleFeed.temp_file)
|
34
|
+
FileUtils.mkdir_p(directory)
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def write_header
|
38
|
+
@feed << Storefront::GoogleProductFeedViewModel.fields
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def write_google_feed
|
42
|
+
Catalog::Product.all.each_by(GoogleFeed.execution_block_size) do |p|
|
43
|
+
product = Storefront::GoogleProductFeedViewModel.wrap(p)
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
45
|
+
product.variants.each do |sku|
|
46
|
+
next unless item_valid(product, sku)
|
47
|
+
@feed << values_array(product, sku)
|
49
48
|
end
|
50
49
|
end
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
def save_google_feed
|
53
|
+
google_feed = Feed::Google.find_first_or_initialize
|
54
|
+
google_feed.feed = @feed
|
55
|
+
google_feed.save!
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def host
|
59
|
+
Workarea.config.host
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
def item_valid(product, sku)
|
63
|
+
sku.active? &&
|
64
|
+
sku.displayable? &&
|
65
|
+
product.active? &&
|
66
|
+
product.sku_price(sku.sku).present? &&
|
67
|
+
product.sku_price(sku.sku).positive?
|
68
|
+
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
70
|
+
def values_array(product, sku)
|
71
|
+
[
|
72
|
+
product.id,
|
73
|
+
sku.sku,
|
74
|
+
product.name,
|
75
|
+
product.meta_description,
|
76
|
+
product_url(product, host: host, sku: sku.sku),
|
77
|
+
sku.image_url,
|
78
|
+
sku.status,
|
79
|
+
sku.inventory,
|
80
|
+
sku.condition,
|
81
|
+
product.brand,
|
82
|
+
sku.color,
|
83
|
+
sku.size,
|
84
|
+
product.category_name,
|
85
|
+
product.product_type,
|
86
|
+
product.sku_price(sku.sku)
|
87
|
+
] + GoogleProductFeed.static_feed_values.values
|
88
|
+
end
|
88
89
|
end
|
89
90
|
end
|
90
91
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Storefront
|
5
|
+
class GoogleProductFeedSkuViewModelTest < TestCase
|
6
|
+
def test_image_uses_asset_host_if_supplied
|
7
|
+
asset_host = Rails.application.config.action_controller.asset_host
|
8
|
+
Rails.application.config.action_controller.asset_host = 'http://www.assethost.com'
|
9
|
+
|
10
|
+
product = create_product
|
11
|
+
view_model = Storefront::GoogleProductFeedSkuViewModel.new(product.variants.first)
|
12
|
+
assert_includes(view_model.image_url, 'www.assethost.com')
|
13
|
+
|
14
|
+
ensure
|
15
|
+
Rails.application.config.action_controller.asset_host = asset_host
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,9 +3,6 @@ require 'test_helper'
|
|
3
3
|
module Workarea
|
4
4
|
module Storefront
|
5
5
|
class GoogleProductFeedViewModelTest < TestCase
|
6
|
-
setup :set_asset_host
|
7
|
-
teardown :reset_asset_host
|
8
|
-
|
9
6
|
def test_can_use_categories_from_rules
|
10
7
|
create_category(google_name: 'Bar', product_ids: [product.id])
|
11
8
|
|
@@ -18,11 +15,6 @@ module Workarea
|
|
18
15
|
assert_equal 'Apparel', subject.category_name
|
19
16
|
end
|
20
17
|
|
21
|
-
def test_image_uses_asset_host_if_supplied
|
22
|
-
Workarea::Catalog::ProductPlaceholderImage.create
|
23
|
-
assert_includes subject.image, 'www.assethost.com'
|
24
|
-
end
|
25
|
-
|
26
18
|
private
|
27
19
|
|
28
20
|
def product
|
@@ -32,15 +24,6 @@ module Workarea
|
|
32
24
|
def subject
|
33
25
|
@subject ||= Storefront::GoogleProductFeedViewModel.new(product)
|
34
26
|
end
|
35
|
-
|
36
|
-
def set_asset_host
|
37
|
-
@_asset_host = Rails.application.config.action_controller.asset_host
|
38
|
-
Rails.application.config.action_controller.asset_host = 'http://www.assethost.com'
|
39
|
-
end
|
40
|
-
|
41
|
-
def reset_asset_host
|
42
|
-
Rails.application.config.action_controller.asset_host = @_asset_host
|
43
|
-
end
|
44
27
|
end
|
45
28
|
end
|
46
29
|
end
|
@@ -8,8 +8,8 @@ module Workarea
|
|
8
8
|
def test_first_row_is_header
|
9
9
|
assert_equal(rows.first, [
|
10
10
|
'item_group_id', 'id', 'title', 'description',
|
11
|
-
'link', 'image_link', 'availability', '
|
12
|
-
'brand', 'color', 'size',
|
11
|
+
'link', 'image_link', 'availability', 'inventory',
|
12
|
+
'condition', 'brand', 'color', 'size',
|
13
13
|
'google_product_category', 'product_type', 'price'
|
14
14
|
])
|
15
15
|
end
|
@@ -46,13 +46,14 @@ module Workarea
|
|
46
46
|
assert_equal('http://www.example.com/products/test-product?sku=' + product.skus.first.to_s, row[4])
|
47
47
|
assert_equal("http://www.assethost.com/product_images/test-product/#{product.images.first.id}/detail.jpg?c=0", row[5])
|
48
48
|
assert_equal('in stock', row[6])
|
49
|
-
assert_equal('
|
50
|
-
assert_equal('
|
51
|
-
assert_equal('
|
52
|
-
assert_equal('
|
53
|
-
assert_equal('
|
54
|
-
assert_equal('
|
55
|
-
assert_equal(
|
49
|
+
assert_equal('99999', row[7])
|
50
|
+
assert_equal('new', row[8])
|
51
|
+
assert_equal('Workarea', row[9])
|
52
|
+
assert_equal('Red', row[10])
|
53
|
+
assert_equal('Large', row[11])
|
54
|
+
assert_equal('Google Category', row[12])
|
55
|
+
assert_equal('Test', row[13])
|
56
|
+
assert_equal(1.to_m.to_s, row[14])
|
56
57
|
end
|
57
58
|
|
58
59
|
rows.third.tap do |row|
|
@@ -63,13 +64,14 @@ module Workarea
|
|
63
64
|
assert_equal('http://www.example.com/products/test-product?sku=' + product.skus.second.to_s, row[4])
|
64
65
|
assert_equal("http://www.assethost.com/product_images/test-product/#{product.images.first.id}/detail.jpg?c=0", row[5])
|
65
66
|
assert_equal('in stock', row[6])
|
66
|
-
assert_equal('
|
67
|
-
assert_equal('
|
68
|
-
assert_equal('
|
69
|
-
assert_equal('
|
70
|
-
assert_equal('
|
71
|
-
assert_equal('
|
72
|
-
assert_equal(
|
67
|
+
assert_equal('99999', row[7])
|
68
|
+
assert_equal('new', row[8])
|
69
|
+
assert_equal('Workarea', row[9])
|
70
|
+
assert_equal('Blue', row[10])
|
71
|
+
assert_equal('Small', row[11])
|
72
|
+
assert_equal('Google Category', row[12])
|
73
|
+
assert_equal('Test', row[13])
|
74
|
+
assert_equal(2.to_m.to_s, row[14])
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
@@ -83,7 +85,7 @@ module Workarea
|
|
83
85
|
product_ids: [product.id]
|
84
86
|
)
|
85
87
|
|
86
|
-
assert_equal('Product Google Category', rows.second[
|
88
|
+
assert_equal('Product Google Category', rows.second[12])
|
87
89
|
end
|
88
90
|
|
89
91
|
def test_uses_second_category_if_first_category_does_not_have_a_google_name
|
@@ -97,7 +99,7 @@ module Workarea
|
|
97
99
|
product_ids: [product.id]
|
98
100
|
)
|
99
101
|
|
100
|
-
assert_equal('Google Category', rows.second[
|
102
|
+
assert_equal('Google Category', rows.second[12])
|
101
103
|
end
|
102
104
|
|
103
105
|
def test_uses_default_category_name_if_google_name_is_blank
|
@@ -109,7 +111,7 @@ module Workarea
|
|
109
111
|
product_ids: [product.id]
|
110
112
|
)
|
111
113
|
|
112
|
-
assert_equal('Apparel & Accessories', rows.second[
|
114
|
+
assert_equal('Apparel & Accessories', rows.second[12])
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
@@ -130,6 +132,30 @@ module Workarea
|
|
130
132
|
assert(rows.third.nil?)
|
131
133
|
end
|
132
134
|
|
135
|
+
def test_export_skus_inventory_with_inventory_skus
|
136
|
+
create_category(
|
137
|
+
name: 'Test Category',
|
138
|
+
google_name: 'Google Category',
|
139
|
+
product_ids: [product.id]
|
140
|
+
)
|
141
|
+
|
142
|
+
create_inventory(id: product.variants.first.sku, available: 1)
|
143
|
+
create_inventory(id: product.variants.second.sku, available: 2)
|
144
|
+
|
145
|
+
assert_equal('1', rows.second[7])
|
146
|
+
assert_equal('2', rows.third[7])
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_export_skus_inventory_with_no_inventory_skus
|
150
|
+
create_category(
|
151
|
+
name: 'Test Category',
|
152
|
+
google_name: 'Google Category',
|
153
|
+
product_ids: [product.id]
|
154
|
+
)
|
155
|
+
|
156
|
+
assert_equal('99999', rows.second[7])
|
157
|
+
end
|
158
|
+
|
133
159
|
def test_does_not_export_inactive_products
|
134
160
|
create_category(
|
135
161
|
name: 'Test Category',
|
@@ -156,26 +182,26 @@ module Workarea
|
|
156
182
|
|
157
183
|
private
|
158
184
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
185
|
+
def set_asset_host
|
186
|
+
@_asset_host = Rails.application.config.action_controller.asset_host
|
187
|
+
Rails.application.config.action_controller.asset_host = 'http://www.assethost.com'
|
188
|
+
end
|
163
189
|
|
164
|
-
|
165
|
-
|
166
|
-
|
190
|
+
def reset_asset_host
|
191
|
+
Rails.application.config.action_controller.asset_host = @_asset_host
|
192
|
+
end
|
167
193
|
|
168
|
-
|
169
|
-
|
170
|
-
|
194
|
+
def google_feed
|
195
|
+
@google_feed ||= Exporting::GoogleFeed.new
|
196
|
+
end
|
171
197
|
|
172
|
-
|
173
|
-
|
174
|
-
|
198
|
+
def filename
|
199
|
+
@filename ||= Workarea::Exporting::GoogleFeed.temp_file
|
200
|
+
end
|
175
201
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
202
|
+
def rows
|
203
|
+
google_feed.generate_csv
|
204
|
+
File.open(filename).read.split("\n").map { |line| line.split("\t") }
|
205
|
+
end
|
180
206
|
end
|
181
207
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-google_product_feed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curt Howard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -38,16 +38,19 @@ extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- ".editorconfig"
|
41
|
+
- ".eslintrc.json"
|
41
42
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
42
43
|
- ".github/ISSUE_TEMPLATE/documentation-request.md"
|
43
44
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
45
|
+
- ".github/workflows/ci.yml"
|
44
46
|
- ".gitignore"
|
47
|
+
- ".rubocop.yml"
|
48
|
+
- ".stylelintrc.json"
|
45
49
|
- CHANGELOG.md
|
46
50
|
- CODE_OF_CONDUCT.md
|
47
51
|
- CONTRIBUTING.md
|
48
52
|
- Gemfile
|
49
53
|
- LICENSE
|
50
|
-
- LICENSE.md
|
51
54
|
- README.md
|
52
55
|
- Rakefile
|
53
56
|
- app/models/workarea/catalog/category.decorator
|
@@ -98,7 +101,6 @@ files:
|
|
98
101
|
- test/dummy/config/initializers/inflections.rb
|
99
102
|
- test/dummy/config/initializers/mime_types.rb
|
100
103
|
- test/dummy/config/initializers/new_framework_defaults.rb
|
101
|
-
- test/dummy/config/initializers/session_store.rb
|
102
104
|
- test/dummy/config/initializers/workarea.rb
|
103
105
|
- test/dummy/config/initializers/wrap_parameters.rb
|
104
106
|
- test/dummy/config/locales/en.yml
|
@@ -115,6 +117,7 @@ files:
|
|
115
117
|
- test/dummy/public/apple-touch-icon.png
|
116
118
|
- test/dummy/public/favicon.ico
|
117
119
|
- test/test_helper.rb
|
120
|
+
- test/view_models/workarea/storefront/google_product_feed_sku_view_model_test.rb
|
118
121
|
- test/view_models/workarea/storefront/google_product_feed_view_model_test.rb
|
119
122
|
- test/workers/workarea/exporting/google_feed_test.rb
|
120
123
|
- workarea-google_product_feed.gemspec
|
@@ -137,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
140
|
- !ruby/object:Gem::Version
|
138
141
|
version: '0'
|
139
142
|
requirements: []
|
140
|
-
rubygems_version: 3.0.
|
143
|
+
rubygems_version: 3.0.3
|
141
144
|
signing_key:
|
142
145
|
specification_version: 4
|
143
146
|
summary: Google Product Feed for the Workarea commerce platform
|
data/LICENSE.md
DELETED