workarea-core 3.4.31 → 3.4.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/workarea/bulk_action/product_edit.rb +6 -6
- data/app/queries/workarea/search/pagination.rb +4 -1
- data/app/queries/workarea/search/storefront_search.rb +1 -1
- data/app/services/workarea/hash_update.rb +18 -1
- data/lib/workarea/changelog.rake +1 -1
- data/lib/workarea/core.rb +1 -0
- data/lib/workarea/ext/freedom_patches/i18n_js.rb +27 -0
- data/lib/workarea/version.rb +1 -1
- data/test/queries/workarea/search/pagination_test.rb +9 -0
- data/test/queries/workarea/search/product_search_test.rb +3 -0
- data/test/services/workarea/hash_update_test.rb +12 -12
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4efeb3ece9613f3cfad48795bd81db270c1c28a95c5c219f84f24d7416cdc111
|
4
|
+
data.tar.gz: 0e397d42f281689cf24607fa58b53a1abf0dd5f3118320d2b01764ae336aa7f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d5d1be53ba4ab30d7e1ff3e25d4eb47081c3e97bb5e21686a18872f05c0e9894ec53b2803612e7887fa0da66ebc8a2c11cf1805ba14d5532c634e646d6e8cf8
|
7
|
+
data.tar.gz: 90e07d7eca3d3a7d9daa8064c0e85841d134098f436b7be7bcf1e599b06d7ba42504a3e314a2fe3058b37dda084745eb6c56fd206a885b3e57d906fbdb5dcaf5
|
@@ -36,15 +36,15 @@ module Workarea
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def apply_details!(product)
|
39
|
-
HashUpdate
|
40
|
-
.new(adds: add_details, removes: remove_details)
|
41
|
-
.
|
39
|
+
product.details = HashUpdate
|
40
|
+
.new(original: product.details, adds: add_details, removes: remove_details)
|
41
|
+
.result
|
42
42
|
end
|
43
43
|
|
44
44
|
def apply_filters!(product)
|
45
|
-
HashUpdate
|
46
|
-
.new(adds: add_filters, removes: remove_filters)
|
47
|
-
.
|
45
|
+
product.filters = HashUpdate
|
46
|
+
.new(original: product.filters, adds: add_filters, removes: remove_filters)
|
47
|
+
.result
|
48
48
|
end
|
49
49
|
|
50
50
|
def apply_pricing!(product)
|
@@ -7,7 +7,10 @@ module Workarea
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def per_page
|
10
|
-
params[:per_page].
|
10
|
+
return Workarea.config.per_page if params[:per_page].blank?
|
11
|
+
|
12
|
+
tmp = params[:per_page].to_i
|
13
|
+
tmp > 0 ? tmp : Workarea.config.per_page
|
11
14
|
end
|
12
15
|
|
13
16
|
def size
|
@@ -5,13 +5,30 @@ module Workarea
|
|
5
5
|
parsed.map(&:to_s).map(&:strip).reject(&:blank?) if parsed.present?
|
6
6
|
end
|
7
7
|
|
8
|
-
def initialize(adds: [], updates: [], removes: [])
|
8
|
+
def initialize(original: {}, adds: [], updates: [], removes: [])
|
9
|
+
@original = original
|
9
10
|
@adds = Array(adds).flatten.each_slice(2).to_a
|
10
11
|
@updates = Array(updates).flatten.each_slice(2).to_a
|
11
12
|
@removes = Array(removes).flatten
|
12
13
|
end
|
13
14
|
|
15
|
+
def result
|
16
|
+
apply_to(@original.deep_dup)
|
17
|
+
end
|
18
|
+
|
19
|
+
# TODO v3.6 remove this method, doesn't work when the field is localized
|
20
|
+
# @deprecated
|
14
21
|
def apply(hash)
|
22
|
+
warn <<~eos
|
23
|
+
[DEPRECATION] `HashUpdate#apply` is deprecated and will be removed in
|
24
|
+
version 3.6.0. Please use `HashUpdate#result` instead.
|
25
|
+
eos
|
26
|
+
apply_to(hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def apply_to(hash)
|
15
32
|
@adds.each do |tuple|
|
16
33
|
key, value = *tuple
|
17
34
|
hash[key] = self.class.parse_values(value)
|
data/lib/workarea/changelog.rake
CHANGED
data/lib/workarea/core.rb
CHANGED
@@ -127,6 +127,7 @@ require 'workarea/ext/freedom_patches/net_http_ssl_connection'
|
|
127
127
|
require 'workarea/ext/freedom_patches/dragonfly_job_fetch_url'
|
128
128
|
require 'workarea/ext/freedom_patches/dragonfly_callable_url_host'
|
129
129
|
require 'workarea/ext/freedom_patches/mongoid_localized_defaults'
|
130
|
+
require 'workarea/ext/freedom_patches/i18n_js'
|
130
131
|
require 'workarea/ext/mongoid/list_field'
|
131
132
|
require 'workarea/ext/mongoid/each_by'
|
132
133
|
require 'workarea/ext/mongoid/except'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module I18n
|
2
|
+
module JS
|
3
|
+
class FallbackLocales
|
4
|
+
# i18n-js uses just the second part of this check out-of-the-box. This
|
5
|
+
# causes the I18n fallbacks to get autoloaded without the developer
|
6
|
+
# knowing.
|
7
|
+
#
|
8
|
+
# This surfaces in tests. System or integration tests will do this check
|
9
|
+
# for compiling assets, then I18n fallbacks get autoloaded. So this shows
|
10
|
+
# as some tests not having fallbacks if they run before one of those tests
|
11
|
+
# or magically having fallbacks if they run after one of those types of
|
12
|
+
# tests.
|
13
|
+
#
|
14
|
+
# Adding the `respond_to?` check doesn't cause autoload, but will return
|
15
|
+
# `true` if fallbacks are enabled. Retain the original check because we
|
16
|
+
# want the current I18n::JS backend to be checked, once fallbacks are
|
17
|
+
# `require`d `I18n.respond_to?(:fallbacks)` will always return `true`.
|
18
|
+
#
|
19
|
+
# See also: https://github.com/fnando/i18n-js/blob/master/lib/i18n/js/fallback_locales.rb#L49-L58
|
20
|
+
#
|
21
|
+
def using_i18n_fallbacks_module?
|
22
|
+
I18n.respond_to?(:fallbacks) &&
|
23
|
+
I18n::JS.backend.class.included_modules.include?(I18n::Backend::Fallbacks)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/workarea/version.rb
CHANGED
@@ -19,6 +19,15 @@ module Workarea
|
|
19
19
|
assert_equal(1, Paginate.new(page: 'asdf').page)
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_per_page
|
23
|
+
assert_equal(Workarea.config.per_page, Paginate.new.per_page)
|
24
|
+
assert_equal(2, Paginate.new(per_page: 2).per_page)
|
25
|
+
assert_equal(Workarea.config.per_page, Paginate.new(per_page: -1).per_page)
|
26
|
+
assert_equal(Workarea.config.per_page, Paginate.new(per_page: 0).per_page)
|
27
|
+
assert_equal(3, Paginate.new(per_page: '3').per_page)
|
28
|
+
assert_equal(Workarea.config.per_page, Paginate.new(per_page: 'asdf').per_page)
|
29
|
+
end
|
30
|
+
|
22
31
|
def test_from
|
23
32
|
Workarea.with_config do |config|
|
24
33
|
config.per_page = 30
|
@@ -410,6 +410,9 @@ module Workarea
|
|
410
410
|
end
|
411
411
|
|
412
412
|
def test_locale
|
413
|
+
# No simple way to run this test without fallbacks or localized fields
|
414
|
+
return unless Workarea.config.localized_active_fields
|
415
|
+
|
413
416
|
set_locales(available: [:en, :es], default: :en, current: :en)
|
414
417
|
Search::Storefront.reset_indexes!
|
415
418
|
|
@@ -2,23 +2,23 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Workarea
|
4
4
|
class HashUpdateTest < TestCase
|
5
|
-
def
|
6
|
-
|
5
|
+
def test_result
|
6
|
+
original = { 'foo' => 'bar' }
|
7
7
|
|
8
|
-
HashUpdate.new(adds: %w(key value)).
|
9
|
-
assert_equal(%w(value),
|
8
|
+
result = HashUpdate.new(original: original, adds: %w(key value)).result
|
9
|
+
assert_equal(%w(value), result['key'])
|
10
10
|
|
11
|
-
HashUpdate.new(updates: %w(foo baz)).
|
12
|
-
assert_equal(%w(baz),
|
11
|
+
result = HashUpdate.new(original: original, updates: %w(foo baz)).result
|
12
|
+
assert_equal(%w(baz), result['foo'])
|
13
13
|
|
14
|
-
HashUpdate.new(removes: %w(foo)).
|
15
|
-
refute_includes(
|
14
|
+
result = HashUpdate.new(original: original, removes: %w(foo)).result
|
15
|
+
refute_includes(result.keys, 'foo')
|
16
16
|
|
17
|
-
HashUpdate.new(adds: ['key', 'one, two ']).
|
18
|
-
assert_equal(%w(one two),
|
17
|
+
result = HashUpdate.new(original: original, adds: ['key', 'one, two ']).result
|
18
|
+
assert_equal(%w(one two), result['key'])
|
19
19
|
|
20
|
-
HashUpdate.new(updates: ['key', 'one, two, three ']).
|
21
|
-
assert_equal(%w(one two three),
|
20
|
+
result = HashUpdate.new(original: original, updates: ['key', 'one, two, three ']).result
|
21
|
+
assert_equal(%w(one two three), result['key'])
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
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.4.
|
4
|
+
version: 3.4.32
|
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-04-
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -1855,6 +1855,7 @@ files:
|
|
1855
1855
|
- lib/workarea/ext/freedom_patches/dragonfly_job_fetch_url.rb
|
1856
1856
|
- lib/workarea/ext/freedom_patches/float.rb
|
1857
1857
|
- lib/workarea/ext/freedom_patches/global_id.rb
|
1858
|
+
- lib/workarea/ext/freedom_patches/i18n_js.rb
|
1858
1859
|
- lib/workarea/ext/freedom_patches/money.rb
|
1859
1860
|
- lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb
|
1860
1861
|
- lib/workarea/ext/freedom_patches/mongoid_simple_tags.rb
|