workarea-core 3.5.9 → 3.5.10
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/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 +15 -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: 6b38c044efaff914d6bbbeff43668f4bef87e963f08df785e1afc1b23acb69ec
|
4
|
+
data.tar.gz: '087f5d99ee26408269f723973c8199679b21ce894a66657f98457ebb16bfdf0f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b90cfa898d74c2111b43b5ccc5bbef7dba02393184e6f6e4830ba50407bc32217e8f7df3aef7b69c3e990a1e8a9c7c5a4b060b032fe109591ddb8666bda5567d
|
7
|
+
data.tar.gz: 903fb77fce3abe0e67b553734b3511c03b31a0bc8b9cb73bfd04a2bfbfd72605a5cd711f9e4e0b2d044acf2d0158b3b39dfb2f39fd1951a599afe1b3d20b7b71
|
@@ -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,27 @@ 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
|
+
Workarea.deprecation.deprecate_methods(self.class, apply: :result)
|
23
|
+
apply_to(hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def apply_to(hash)
|
15
29
|
@adds.each do |tuple|
|
16
30
|
key, value = *tuple
|
17
31
|
hash[key] = self.class.parse_values(value)
|
data/lib/workarea/changelog.rake
CHANGED
data/lib/workarea/core.rb
CHANGED
@@ -132,6 +132,7 @@ require 'workarea/ext/freedom_patches/active_support_duration'
|
|
132
132
|
require 'workarea/ext/freedom_patches/premailer'
|
133
133
|
require 'workarea/ext/freedom_patches/referer_parser'
|
134
134
|
require 'workarea/ext/freedom_patches/mongoid_localized_defaults'
|
135
|
+
require 'workarea/ext/freedom_patches/i18n_js'
|
135
136
|
require 'workarea/ext/mongoid/list_field'
|
136
137
|
require 'workarea/ext/mongoid/each_by'
|
137
138
|
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.config.per_page = 30
|
24
33
|
assert_equal(0, Paginate.new(page: 1).from)
|
@@ -427,6 +427,9 @@ module Workarea
|
|
427
427
|
end
|
428
428
|
|
429
429
|
def test_locale
|
430
|
+
# No simple way to run this test without fallbacks or localized fields
|
431
|
+
return unless Workarea.config.localized_active_fields
|
432
|
+
|
430
433
|
set_locales(available: [:en, :es], default: :en, current: :en)
|
431
434
|
Search::Storefront.reset_indexes!
|
432
435
|
|
@@ -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.5.
|
4
|
+
version: 3.5.10
|
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
|
@@ -1919,6 +1919,7 @@ files:
|
|
1919
1919
|
- lib/workarea/ext/freedom_patches/dragonfly_job_fetch_url.rb
|
1920
1920
|
- lib/workarea/ext/freedom_patches/float.rb
|
1921
1921
|
- lib/workarea/ext/freedom_patches/global_id.rb
|
1922
|
+
- lib/workarea/ext/freedom_patches/i18n_js.rb
|
1922
1923
|
- lib/workarea/ext/freedom_patches/money.rb
|
1923
1924
|
- lib/workarea/ext/freedom_patches/mongoid_localized_defaults.rb
|
1924
1925
|
- lib/workarea/ext/freedom_patches/mongoid_simple_tags.rb
|