workarea-core 3.5.12 → 3.5.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/workarea/order.rb +3 -3
- data/app/models/workarea/releasable.rb +3 -1
- data/app/models/workarea/release/changeset.rb +1 -0
- data/app/models/workarea/search/admin/pricing_discount.rb +1 -1
- data/app/models/workarea/search/storefront.rb +9 -1
- data/app/models/workarea/search/storefront/product.rb +11 -2
- data/app/queries/workarea/product_releases.rb +6 -0
- data/app/services/workarea/direct_upload.rb +6 -1
- data/app/workers/workarea/index_category_changes.rb +16 -3
- data/app/workers/workarea/reindex_release.rb +42 -0
- data/lib/tasks/search.rake +10 -4
- data/lib/workarea/core.rb +1 -0
- data/lib/workarea/queues_pauser.rb +26 -0
- data/lib/workarea/version.rb +1 -1
- data/test/models/workarea/releasable_test.rb +13 -0
- data/test/models/workarea/search/storefront/product_releases_test.rb +60 -0
- data/test/models/workarea/search/storefront_test.rb +13 -0
- data/test/queries/workarea/search/category_browse_test.rb +23 -0
- data/test/services/workarea/direct_upload_test.rb +20 -0
- data/test/workers/workarea/reindex_release_test.rb +81 -0
- data/workarea-core.gemspec +4 -3
- metadata +26 -9
- data/test/queries/workarea/product_releases_test.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15a5824ab2746ddff9941773fefcaec1829d2a721a65893b3dac3a2fc7aad8a
|
4
|
+
data.tar.gz: 90b49ae058315ad91c7427c0b94c39a86016ed1898bb44d4bad99c9377053d53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee0b818334a756cbeceacf3be95347e8fa0d46090c0fd3729073c67a04e4c2e17530adc50e772e3bc4f759fdc5d62d7d775e5e2cb0281a5541e063d82fe7526
|
7
|
+
data.tar.gz: bd4eb10892770ef2b332a25203f54e703940cec8d45fce3f13a3316636b4ec3c78c0ce4088e504845e7f017ebf75eaa8a0036251f37ed9207d90f3fe6a86be5e
|
@@ -47,13 +47,13 @@ module Workarea
|
|
47
47
|
{
|
48
48
|
placed_at: 1,
|
49
49
|
reminded_at: 1,
|
50
|
+
fraud_suspected_at: 1,
|
50
51
|
checkout_started_at: 1,
|
51
52
|
email: 1,
|
52
|
-
"items[0]._id": 1
|
53
|
-
fraud_suspected_at: 1
|
53
|
+
"items[0]._id": 1
|
54
54
|
},
|
55
55
|
{
|
56
|
-
name: '
|
56
|
+
name: 'abandoned_order_email_with_fraud_index_v2',
|
57
57
|
background: true
|
58
58
|
}
|
59
59
|
)
|
@@ -72,7 +72,9 @@ module Workarea
|
|
72
72
|
release.preview.changesets_for(self).each { |cs| cs.apply_to(result) }
|
73
73
|
result
|
74
74
|
else
|
75
|
-
Release.with_current(release)
|
75
|
+
Release.with_current(release) do
|
76
|
+
Mongoid::QueryCache.uncached { self.class.find(id) }
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
@@ -18,6 +18,7 @@ module Workarea
|
|
18
18
|
index({ 'document_path.type' => 1, 'document_path.document_id' => 1 })
|
19
19
|
index('changeset.product_ids' => 1)
|
20
20
|
index('original.product_ids' => 1)
|
21
|
+
index('releasable_type' => 1, 'releasable_id' => 1)
|
21
22
|
|
22
23
|
# Finds changeset by whether the passed document is in the document
|
23
24
|
# path of the changeset. Useful for showing embedded changes in the
|
@@ -82,6 +82,14 @@ module Workarea
|
|
82
82
|
@changesets ||= Array.wrap(model.try(:changesets_with_children))
|
83
83
|
end
|
84
84
|
|
85
|
+
def releases
|
86
|
+
changesets
|
87
|
+
.uniq(&:release)
|
88
|
+
.reject { |cs| cs.release.blank? }
|
89
|
+
.flat_map { |cs| [cs.release] + cs.release.scheduled_after }
|
90
|
+
.uniq
|
91
|
+
end
|
92
|
+
|
85
93
|
def as_document
|
86
94
|
Release.with_current(release_id) do
|
87
95
|
{
|
@@ -91,7 +99,7 @@ module Workarea
|
|
91
99
|
active: active,
|
92
100
|
active_segment_ids: active_segment_ids,
|
93
101
|
release_id: release_id,
|
94
|
-
changeset_release_ids:
|
102
|
+
changeset_release_ids: releases.map(&:id),
|
95
103
|
suggestion_content: suggestion_content,
|
96
104
|
created_at: model.created_at,
|
97
105
|
updated_at: model.updated_at,
|
@@ -122,12 +122,21 @@ module Workarea
|
|
122
122
|
ProductPrimaryImageUrl.new(model).path
|
123
123
|
end
|
124
124
|
|
125
|
-
#
|
125
|
+
# All {Releasable}s that could affect the product's Elasticsearch document
|
126
|
+
# should add their changesets to this method.
|
127
|
+
#
|
128
|
+
# @example Add to the changesets affecting a product in a decorator
|
129
|
+
# def changesets
|
130
|
+
# super.merge(SomeReleasable.for_product(product.id).changesets_with_children)
|
131
|
+
# end
|
126
132
|
#
|
127
133
|
# @return [Mongoid::Criteria]
|
128
134
|
#
|
129
135
|
def changesets
|
130
|
-
|
136
|
+
criteria = model.changesets_with_children
|
137
|
+
pricing.each { |ps| criteria.merge!(ps.changesets_with_children) }
|
138
|
+
criteria.merge!(FeaturedProducts.changesets(model.id))
|
139
|
+
criteria.includes(:release)
|
131
140
|
end
|
132
141
|
|
133
142
|
private
|
@@ -8,7 +8,12 @@ module Workarea
|
|
8
8
|
url += ":#{uri.port}" unless uri.port.in? [80, 443]
|
9
9
|
id = "direct_upload_#{url}"
|
10
10
|
|
11
|
-
response =
|
11
|
+
response = begin
|
12
|
+
Workarea.s3.get_bucket_cors(Configuration::S3.bucket)
|
13
|
+
rescue Excon::Error::NotFound
|
14
|
+
Excon::Response.new(body: { 'CORSConfiguration' => [] })
|
15
|
+
end
|
16
|
+
|
12
17
|
cors = response.data[:body]
|
13
18
|
|
14
19
|
unless cors['CORSConfiguration'].pluck('ID').include?(id)
|
@@ -4,16 +4,29 @@ module Workarea
|
|
4
4
|
include Sidekiq::CallbacksWorker
|
5
5
|
|
6
6
|
sidekiq_options(
|
7
|
-
enqueue_on: {
|
7
|
+
enqueue_on: {
|
8
|
+
Catalog::Category => [:save, :save_release_changes],
|
9
|
+
with: -> { [changes, Release.current.present?] }
|
10
|
+
},
|
8
11
|
ignore_if: -> { changes['product_ids'].blank? },
|
9
12
|
lock: :until_executing,
|
10
13
|
query_cache: true
|
11
14
|
)
|
12
15
|
|
13
|
-
def perform(changes)
|
16
|
+
def perform(changes, for_release = false)
|
14
17
|
return unless changes['product_ids'].present?
|
15
18
|
|
16
|
-
ids =
|
19
|
+
ids = if for_release
|
20
|
+
# This is a shortcut because if you're resorting products within a release,
|
21
|
+
# the `changes` hash doesn't reflect the repositioning within the release,
|
22
|
+
# only the difference between what's live and what's in the release.
|
23
|
+
#
|
24
|
+
# Reindexing all of them is a shortcut to having to manually build a diff
|
25
|
+
# between the changesets in the possible affected releases.
|
26
|
+
changes['product_ids'].flatten.uniq
|
27
|
+
else
|
28
|
+
require_index_ids(*changes['product_ids'])
|
29
|
+
end
|
17
30
|
|
18
31
|
if ids.size > max_count
|
19
32
|
ids.each { |id| IndexProduct.perform_async(id) }
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Workarea
|
2
|
+
class ReindexRelease
|
3
|
+
include Sidekiq::Worker
|
4
|
+
include Sidekiq::CallbacksWorker
|
5
|
+
|
6
|
+
sidekiq_options(
|
7
|
+
enqueue_on: {
|
8
|
+
Release => :save,
|
9
|
+
only_if: -> { publish_at_changed? },
|
10
|
+
with: -> { [id, publish_at_was, publish_at] }
|
11
|
+
},
|
12
|
+
queue: 'high'
|
13
|
+
)
|
14
|
+
|
15
|
+
def perform(id, previous_publish_at, new_publish_at)
|
16
|
+
rescheduled_release = Release.find(id)
|
17
|
+
earlier, later = if previous_publish_at.present? && new_publish_at.present?
|
18
|
+
[previous_publish_at, new_publish_at].sort
|
19
|
+
elsif previous_publish_at.present?
|
20
|
+
[previous_publish_at, nil]
|
21
|
+
else
|
22
|
+
[new_publish_at, nil]
|
23
|
+
end
|
24
|
+
|
25
|
+
affected_releases = Release.scheduled(after: earlier, before: later).includes(:changesets).to_a
|
26
|
+
affected_releases += [rescheduled_release]
|
27
|
+
affected_releases.uniq!
|
28
|
+
|
29
|
+
affected_models = affected_releases.flat_map(&:changesets).flat_map(&:releasable)
|
30
|
+
|
31
|
+
affected_releases.each do |release|
|
32
|
+
affected_models.each do |releasable|
|
33
|
+
Search::Storefront.new(releasable.in_release(release)).destroy
|
34
|
+
|
35
|
+
# Different models have different indexing workers, running callbacks
|
36
|
+
# ensures the appropriate worker is triggered
|
37
|
+
releasable.run_callbacks(:save_release_changes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/tasks/search.rake
CHANGED
@@ -16,7 +16,9 @@ namespace :workarea do
|
|
16
16
|
task admin: :environment do
|
17
17
|
setup
|
18
18
|
puts 'Indexing admin...'
|
19
|
-
Workarea::
|
19
|
+
Workarea::QueuesPauser.with_paused_queues do
|
20
|
+
Workarea::Search::Admin.reset_indexes!
|
21
|
+
end
|
20
22
|
|
21
23
|
Mongoid.models.each do |klass|
|
22
24
|
next unless Workarea::Search::Admin.for(klass.first).present?
|
@@ -36,8 +38,10 @@ namespace :workarea do
|
|
36
38
|
setup
|
37
39
|
puts 'Indexing storefront...'
|
38
40
|
|
39
|
-
Workarea::
|
40
|
-
|
41
|
+
Workarea::QueuesPauser.with_paused_queues do
|
42
|
+
Workarea::Search::Storefront.reset_indexes!
|
43
|
+
Workarea::Search::Storefront.ensure_dynamic_mappings
|
44
|
+
end
|
41
45
|
|
42
46
|
# This code finds all unique filters for products so we can index a sample
|
43
47
|
# product for each to ensure the dynamic mappings get created.
|
@@ -83,7 +87,9 @@ namespace :workarea do
|
|
83
87
|
setup
|
84
88
|
puts 'Indexing help...'
|
85
89
|
|
86
|
-
Workarea::
|
90
|
+
Workarea::QueuesPauser.with_paused_queues do
|
91
|
+
Workarea::Search::Help.reset_indexes!
|
92
|
+
end
|
87
93
|
|
88
94
|
Workarea::Help::Article.all.each_by(Workarea.config.bulk_index_batch_size) do |help_article|
|
89
95
|
Workarea::Search::Help.new(help_article).save
|
data/lib/workarea/core.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Workarea
|
2
|
+
module QueuesPauser
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def pause_queues!
|
6
|
+
pauser = Sidekiq::Throttled::QueuesPauser.instance
|
7
|
+
queues.each { |queue| pauser.pause!(queue) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def resume_queues!
|
11
|
+
pauser = Sidekiq::Throttled::QueuesPauser.instance
|
12
|
+
queues.each { |queue| pauser.resume!(queue) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_paused_queues(&block)
|
16
|
+
pause_queues!
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
resume_queues!
|
20
|
+
end
|
21
|
+
|
22
|
+
def queues
|
23
|
+
Configuration::Sidekiq.queues
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/workarea/version.rb
CHANGED
@@ -375,6 +375,19 @@ module Workarea
|
|
375
375
|
in_release = model.in_release(nil)
|
376
376
|
assert_equal('Foo', in_release.name)
|
377
377
|
refute_equal(in_release.object_id, model.object_id)
|
378
|
+
|
379
|
+
Mongoid::QueryCache.cache do
|
380
|
+
cached = Foo.find(model.id) # a find to ensure it's in the cache table
|
381
|
+
cached.name = 'Bar' # so the cache table's instance has a change
|
382
|
+
|
383
|
+
in_release = model.in_release(nil)
|
384
|
+
assert_equal('Foo', in_release.name)
|
385
|
+
refute_equal(in_release.object_id, model.object_id)
|
386
|
+
refute_equal(cached.object_id, model.object_id)
|
387
|
+
end
|
388
|
+
|
389
|
+
ensure
|
390
|
+
Mongoid::QueryCache.clear_cache
|
378
391
|
end
|
379
392
|
|
380
393
|
def test_skip_changeset
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Search
|
5
|
+
class Storefront
|
6
|
+
class ProductReleasesTest < TestCase
|
7
|
+
def test_product_changes
|
8
|
+
product = create_product(name: 'Foo')
|
9
|
+
release_one = create_release
|
10
|
+
release_one.as_current { product.update!(name: 'Bar') }
|
11
|
+
|
12
|
+
assert_equal([release_one], Product.new(product).releases)
|
13
|
+
|
14
|
+
release_one.update!(publish_at: 1.day.from_now)
|
15
|
+
release_two = create_release(publish_at: 3.days.from_now)
|
16
|
+
assert_equal([release_one, release_two], Product.new(product).releases)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_featured_product_changes
|
20
|
+
product = create_product
|
21
|
+
category = create_category
|
22
|
+
|
23
|
+
release_one = create_release
|
24
|
+
release_one.as_current { category.update!(product_ids: [product.id]) }
|
25
|
+
assert_equal([release_one], Product.new(product).releases)
|
26
|
+
|
27
|
+
release_one.update!(publish_at: 1.day.from_now)
|
28
|
+
release_two = create_release(publish_at: 3.days.from_now)
|
29
|
+
assert_equal([release_one, release_two], Product.new(product).releases)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_variant_changes
|
33
|
+
product = create_product(variants: [{ sku: 'SKU' }])
|
34
|
+
release = create_release
|
35
|
+
release.as_current { product.variants.first.update!(details: { color: 'Red' }) }
|
36
|
+
assert_equal([release], Product.new(product).releases)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_pricing_changes
|
40
|
+
product = create_product(variants: [{ sku: 'SKU' }])
|
41
|
+
pricing = Pricing::Sku.find('SKU')
|
42
|
+
|
43
|
+
release = create_release
|
44
|
+
release.as_current { pricing.prices.first.update!(regular: 10_000) }
|
45
|
+
assert_equal([release], Product.new(product).releases)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_changesets_with_missing_releases
|
49
|
+
product = create_product(name: 'Foo')
|
50
|
+
release = create_release
|
51
|
+
release.as_current { product.update!(name: 'Bar') }
|
52
|
+
release.delete
|
53
|
+
|
54
|
+
assert_nil(product.reload.changesets.first.release)
|
55
|
+
assert_equal([], Product.new(product).releases)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -25,6 +25,19 @@ module Workarea
|
|
25
25
|
release.as_current { category.product_rules.first.update!(value: 'bar') }
|
26
26
|
assert_equal(2, Storefront.new(category).changesets.size)
|
27
27
|
end
|
28
|
+
|
29
|
+
def test_releases
|
30
|
+
category = create_category(name: 'Foo')
|
31
|
+
assert_empty(Storefront.new(category).as_document[:changeset_release_ids])
|
32
|
+
|
33
|
+
a = create_release(publish_at: 1.week.from_now)
|
34
|
+
a.as_current { category.update!(name: 'Bar') }
|
35
|
+
assert_equal([a.id], Storefront.new(category).as_document[:changeset_release_ids])
|
36
|
+
|
37
|
+
b = create_release(publish_at: 2.weeks.from_now)
|
38
|
+
assert_includes(Storefront.new(category).as_document[:changeset_release_ids], a.id)
|
39
|
+
assert_includes(Storefront.new(category).as_document[:changeset_release_ids], b.id)
|
40
|
+
end
|
28
41
|
end
|
29
42
|
end
|
30
43
|
end
|
@@ -382,6 +382,29 @@ module Workarea
|
|
382
382
|
refute_includes(result_ids, product_five.id)
|
383
383
|
end
|
384
384
|
end
|
385
|
+
|
386
|
+
def test_featured_product_changes_in_a_release
|
387
|
+
one = create_product
|
388
|
+
two = create_product
|
389
|
+
three = create_product(name: 'Foo', active: false)
|
390
|
+
category = create_category(product_ids: [one.id, two.id], product_rules: [])
|
391
|
+
release = create_release(publish_at: 1.week.from_now)
|
392
|
+
|
393
|
+
release.as_current do
|
394
|
+
three.update!(name: 'Bar', active: true, default_category_id: category.id)
|
395
|
+
category.update!(product_ids: [three.id, one.id, two.id])
|
396
|
+
search = CategoryBrowse.new(sort: %w(featured), category_ids: [category.id])
|
397
|
+
sorts = search.results.pluck(:raw).pluck('_source').pluck('sorts').pluck(category.id.to_s)
|
398
|
+
assert_equal([0, 1, 2], sorts)
|
399
|
+
end
|
400
|
+
|
401
|
+
release.as_current do
|
402
|
+
category.update!(product_ids: [one.id, two.id, three.id])
|
403
|
+
search = CategoryBrowse.new(sort: %w(featured), category_ids: [category.id])
|
404
|
+
sorts = search.results.pluck(:raw).pluck('_source').pluck('sorts').pluck(category.id.to_s)
|
405
|
+
assert_equal([0, 1, 2], sorts)
|
406
|
+
end
|
407
|
+
end
|
385
408
|
end
|
386
409
|
end
|
387
410
|
end
|
@@ -112,6 +112,26 @@ module Workarea
|
|
112
112
|
assert(DirectUpload.ensure_cors!('https://example.com/admin/direct_uploads'))
|
113
113
|
end
|
114
114
|
|
115
|
+
def test_ensure_cors_with_no_existing_configuration
|
116
|
+
Workarea.s3.expects(:get_bucket_cors)
|
117
|
+
.raises(Excon::Errors::NotFound.new('CORS configuration does not exist'))
|
118
|
+
|
119
|
+
|
120
|
+
Workarea.s3.expects(:put_bucket_cors).with(
|
121
|
+
Configuration::S3.bucket,
|
122
|
+
'CORSConfiguration' => [
|
123
|
+
{
|
124
|
+
'ID' => "direct_upload_http://test.host",
|
125
|
+
'AllowedMethod' => 'PUT',
|
126
|
+
'AllowedOrigin' => 'http://test.host',
|
127
|
+
'AllowedHeader' => '*'
|
128
|
+
}
|
129
|
+
]
|
130
|
+
).returns(true)
|
131
|
+
|
132
|
+
assert(DirectUpload.ensure_cors!('http://test.host/admin/content_assets'))
|
133
|
+
end
|
134
|
+
|
115
135
|
private
|
116
136
|
|
117
137
|
def upload_file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
class ReindexReleaseTest < TestCase
|
5
|
+
include TestCase::SearchIndexing
|
6
|
+
|
7
|
+
setup :set_product
|
8
|
+
|
9
|
+
def set_product
|
10
|
+
@product = create_product(name: 'Foo')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_reschedule
|
14
|
+
a = create_release(name: 'A', publish_at: 1.week.from_now)
|
15
|
+
b = create_release(name: 'B', publish_at: 2.weeks.from_now)
|
16
|
+
c = create_release(name: 'C', publish_at: 4.weeks.from_now)
|
17
|
+
|
18
|
+
b.as_current { @product.update!(name: 'Bar') }
|
19
|
+
IndexProduct.perform(@product)
|
20
|
+
|
21
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
22
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
23
|
+
c.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
24
|
+
|
25
|
+
# Changing publish_at via `update` causes the release to publish due to Sidekiq inline
|
26
|
+
previous_publish_at = b.publish_at
|
27
|
+
b.set(publish_at: 5.weeks.from_now)
|
28
|
+
|
29
|
+
Sidekiq::Callbacks.enable(IndexProduct) { ReindexRelease.new.perform(b.id, previous_publish_at, b.publish_at) }
|
30
|
+
|
31
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
32
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
33
|
+
c.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_removing_from_schedule
|
37
|
+
a = create_release(name: 'A', publish_at: 1.week.from_now)
|
38
|
+
b = create_release(name: 'B', publish_at: 2.weeks.from_now)
|
39
|
+
c = create_release(name: 'C', publish_at: 4.weeks.from_now)
|
40
|
+
|
41
|
+
b.as_current { @product.update!(name: 'Bar') }
|
42
|
+
IndexProduct.perform(@product)
|
43
|
+
|
44
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
45
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
46
|
+
c.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
47
|
+
|
48
|
+
# Changing publish_at via `update` causes the release to publish due to Sidekiq inline
|
49
|
+
previous_publish_at = b.publish_at
|
50
|
+
b.set(publish_at: nil)
|
51
|
+
|
52
|
+
Sidekiq::Callbacks.enable(IndexProduct) { ReindexRelease.new.perform(b.id, previous_publish_at, nil) }
|
53
|
+
|
54
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
55
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
56
|
+
c.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_adding_to_schedule
|
60
|
+
a = create_release(name: 'A', publish_at: 1.week.from_now)
|
61
|
+
b = create_release(name: 'B')
|
62
|
+
c = create_release(name: 'C', publish_at: 4.weeks.from_now)
|
63
|
+
|
64
|
+
b.as_current { @product.update!(name: 'Bar') }
|
65
|
+
IndexProduct.perform(@product)
|
66
|
+
|
67
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
68
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
69
|
+
c.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
70
|
+
|
71
|
+
# Changing publish_at via `update` causes the release to publish due to Sidekiq inline
|
72
|
+
b.set(publish_at: 2.weeks.from_now)
|
73
|
+
|
74
|
+
Sidekiq::Callbacks.enable(IndexProduct) { ReindexRelease.new.perform(b.id, nil, b.publish_at) }
|
75
|
+
|
76
|
+
a.as_current { assert_empty(Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
77
|
+
b.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
78
|
+
c.as_current { assert_equal([@product], Search::ProductSearch.new(q: 'bar').results.pluck(:model)) }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/workarea-core.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_dependency 'mongoid-sample', '~> 0.1.0'
|
26
26
|
s.add_dependency 'mongoid-encrypted', '~> 1.0.0'
|
27
27
|
s.add_dependency 'elasticsearch', '~> 5.0.1'
|
28
|
-
s.add_dependency 'kaminari', '~>
|
28
|
+
s.add_dependency 'kaminari', '~> 1.2.1'
|
29
29
|
s.add_dependency 'kaminari-mongoid', '~> 0.1.2'
|
30
30
|
s.add_dependency 'activemerchant', '~> 1.52'
|
31
31
|
s.add_dependency 'dragonfly', '~> 1.1.2'
|
@@ -33,7 +33,8 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_dependency 'sidekiq-cron', '~> 0.6.3'
|
34
34
|
s.add_dependency 'sidekiq-unique-jobs', '~> 6.0.6'
|
35
35
|
s.add_dependency 'sidekiq-throttled', '~> 0.8.2'
|
36
|
-
s.add_dependency 'geocoder', '~> 1.
|
36
|
+
s.add_dependency 'geocoder', '~> 1.6.3'
|
37
|
+
s.add_dependency 'redis-rails', '~> 5.0.0'
|
37
38
|
s.add_dependency 'redis-rack-cache', '~> 2.2.0'
|
38
39
|
s.add_dependency 'easymon', '~> 1.4.0'
|
39
40
|
s.add_dependency 'image_optim', '~> 0.26.0'
|
@@ -65,7 +66,7 @@ Gem::Specification.new do |s|
|
|
65
66
|
s.add_dependency 'chart-horizontalbar-rails', '~> 1.0.4' # TODO remove v4
|
66
67
|
s.add_dependency 'select2-rails', '~> 4.0.3'
|
67
68
|
s.add_dependency 'wysihtml-rails', '~> 0.6.0.beta2'
|
68
|
-
s.add_dependency 'rack-attack', '~>
|
69
|
+
s.add_dependency 'rack-attack', '~> 6.3.1'
|
69
70
|
s.add_dependency 'jquery-livetype-rails', '~> 0.1.0' # TODO remove v4
|
70
71
|
s.add_dependency 'redcarpet', '~> 3.4.0'
|
71
72
|
s.add_dependency 'jquery-unique-clone-rails', '~> 1.0.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Crouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 1.2.1
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 1.2.1
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: kaminari-mongoid
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,14 +282,28 @@ dependencies:
|
|
282
282
|
requirements:
|
283
283
|
- - "~>"
|
284
284
|
- !ruby/object:Gem::Version
|
285
|
-
version: 1.
|
285
|
+
version: 1.6.3
|
286
286
|
type: :runtime
|
287
287
|
prerelease: false
|
288
288
|
version_requirements: !ruby/object:Gem::Requirement
|
289
289
|
requirements:
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
|
-
version: 1.
|
292
|
+
version: 1.6.3
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: redis-rails
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "~>"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: 5.0.0
|
300
|
+
type: :runtime
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "~>"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: 5.0.0
|
293
307
|
- !ruby/object:Gem::Dependency
|
294
308
|
name: redis-rack-cache
|
295
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -730,14 +744,14 @@ dependencies:
|
|
730
744
|
requirements:
|
731
745
|
- - "~>"
|
732
746
|
- !ruby/object:Gem::Version
|
733
|
-
version:
|
747
|
+
version: 6.3.1
|
734
748
|
type: :runtime
|
735
749
|
prerelease: false
|
736
750
|
version_requirements: !ruby/object:Gem::Requirement
|
737
751
|
requirements:
|
738
752
|
- - "~>"
|
739
753
|
- !ruby/object:Gem::Version
|
740
|
-
version:
|
754
|
+
version: 6.3.1
|
741
755
|
- !ruby/object:Gem::Dependency
|
742
756
|
name: jquery-livetype-rails
|
743
757
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1771,6 +1785,7 @@ files:
|
|
1771
1785
|
- app/workers/workarea/publish_bulk_action.rb
|
1772
1786
|
- app/workers/workarea/publish_release.rb
|
1773
1787
|
- app/workers/workarea/redirect_navigable_slugs.rb
|
1788
|
+
- app/workers/workarea/reindex_release.rb
|
1774
1789
|
- app/workers/workarea/save_metrics.rb
|
1775
1790
|
- app/workers/workarea/save_order_cancellation_metrics.rb
|
1776
1791
|
- app/workers/workarea/save_order_metrics.rb
|
@@ -1964,6 +1979,7 @@ files:
|
|
1964
1979
|
- lib/workarea/ping_home_base.rb
|
1965
1980
|
- lib/workarea/plugin.rb
|
1966
1981
|
- lib/workarea/plugin/asset_appends_helper.rb
|
1982
|
+
- lib/workarea/queues_pauser.rb
|
1967
1983
|
- lib/workarea/routes_constraints/redirect.rb
|
1968
1984
|
- lib/workarea/routes_constraints/super_admin.rb
|
1969
1985
|
- lib/workarea/scheduled_jobs.rb
|
@@ -2314,6 +2330,7 @@ files:
|
|
2314
2330
|
- test/models/workarea/search/storefront/product/inventory_test.rb
|
2315
2331
|
- test/models/workarea/search/storefront/product/pricing_test.rb
|
2316
2332
|
- test/models/workarea/search/storefront/product/text_test.rb
|
2333
|
+
- test/models/workarea/search/storefront/product_releases_test.rb
|
2317
2334
|
- test/models/workarea/search/storefront/product_test.rb
|
2318
2335
|
- test/models/workarea/search/storefront_test.rb
|
2319
2336
|
- test/models/workarea/segment/life_cycle_test.rb
|
@@ -2365,7 +2382,6 @@ files:
|
|
2365
2382
|
- test/queries/workarea/pricing_override_params_test.rb
|
2366
2383
|
- test/queries/workarea/product_primary_image_url_test.rb
|
2367
2384
|
- test/queries/workarea/product_primary_navigation_test.rb
|
2368
|
-
- test/queries/workarea/product_releases_test.rb
|
2369
2385
|
- test/queries/workarea/recommendation/order_based_test.rb
|
2370
2386
|
- test/queries/workarea/recommendation/product_based_test.rb
|
2371
2387
|
- test/queries/workarea/recommendation/searches_test.rb
|
@@ -2468,6 +2484,7 @@ files:
|
|
2468
2484
|
- test/workers/workarea/publish_bulk_action_test.rb
|
2469
2485
|
- test/workers/workarea/publish_release_test.rb
|
2470
2486
|
- test/workers/workarea/redirect_navigable_slugs_test.rb
|
2487
|
+
- test/workers/workarea/reindex_release_test.rb
|
2471
2488
|
- test/workers/workarea/save_order_metrics_test.rb
|
2472
2489
|
- test/workers/workarea/save_user_order_details_test.rb
|
2473
2490
|
- test/workers/workarea/send_refund_email_test.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Workarea
|
4
|
-
class ProductReleasesTest < TestCase
|
5
|
-
def test_product_changes
|
6
|
-
product = create_product(name: 'Foo')
|
7
|
-
release_one = create_release
|
8
|
-
release_one.as_current { product.update!(name: 'Bar') }
|
9
|
-
|
10
|
-
assert_equal([release_one], ProductReleases.new(product).releases)
|
11
|
-
|
12
|
-
release_one.update!(publish_at: 1.day.from_now)
|
13
|
-
release_two = create_release(publish_at: 3.days.from_now)
|
14
|
-
assert_equal([release_one, release_two], ProductReleases.new(product).releases)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_featured_product_changes
|
18
|
-
product = create_product
|
19
|
-
category = create_category
|
20
|
-
|
21
|
-
release_one = create_release
|
22
|
-
release_one.as_current { category.update!(product_ids: [product.id]) }
|
23
|
-
assert_equal([release_one], ProductReleases.new(product).releases)
|
24
|
-
|
25
|
-
release_one.update!(publish_at: 1.day.from_now)
|
26
|
-
release_two = create_release(publish_at: 3.days.from_now)
|
27
|
-
assert_equal([release_one, release_two], ProductReleases.new(product).releases)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_variant_changes
|
31
|
-
product = create_product(variants: [{ sku: 'SKU' }])
|
32
|
-
release = create_release
|
33
|
-
release.as_current { product.variants.first.update!(details: { color: 'Red' }) }
|
34
|
-
assert_equal([release], ProductReleases.new(product).releases)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_pricing_changes
|
38
|
-
product = create_product(variants: [{ sku: 'SKU' }])
|
39
|
-
pricing = Pricing::Sku.find('SKU')
|
40
|
-
|
41
|
-
release = create_release
|
42
|
-
release.as_current { pricing.prices.first.update!(regular: 10_000) }
|
43
|
-
assert_equal([release], ProductReleases.new(product).releases)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_changesets_with_missing_releases
|
47
|
-
product = create_product(name: 'Foo')
|
48
|
-
release = create_release
|
49
|
-
release.as_current { product.update!(name: 'Bar') }
|
50
|
-
release.delete
|
51
|
-
|
52
|
-
assert_nil(product.reload.changesets.first.release)
|
53
|
-
assert_equal([], ProductReleases.new(product).releases)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|