workarea-core 3.4.25 → 3.4.26

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
  SHA256:
3
- metadata.gz: 2118c9b5b0ade92acd9c13b30653e284ba0c023604b5b7772e7096ea910dde8f
4
- data.tar.gz: fa1e82be47c368fe38b01d4b240684bbfc1adac6f04004aba3f2adf7752e38b5
3
+ metadata.gz: 565180173a33822af9ccf9869c938b7a279aa4af98d302d5eb294ae92a64ddcd
4
+ data.tar.gz: 7e8a3f3affcb68255b2015abbc0215b07e074d4678f4ac5e949fd790f78a8497
5
5
  SHA512:
6
- metadata.gz: d7a37a60631f30c2ba201887d08e7caa7e810b3e3d4fc161958b8475b52b73a87cdc4f463ceffcde04d5a664c3799a48638e660e1f1167a0bfbd12dd9d9e6a2f
7
- data.tar.gz: 8e298ac7fb22d77a5ad7f6aceecec00bb16bce30b6fd4943d020d7c2985734b49c4569bb2d10bd625fd81c8caf5c1ae9a0c9b4b89c924b1e4ab6a4ddb8718c8f
6
+ metadata.gz: 233b6a7ea863877f716e809c348c921155fbf868db0a462bbcc57fe540aebe0008f44dc1a58d9fface1d04deb5bc0450938c8f53941a393246e5b9fffc3373a7
7
+ data.tar.gz: db0b7774e57ef6c9f59e3c171c998a53400fc316500fd246ab1aadffc604bb473292edcc3371b7a06a42fa087a1bd5f0fddd50b8c974e50f55b7a48903116582
@@ -54,13 +54,17 @@ WORKAREA.registerModule('duplicateId', (function () {
54
54
  }).toArray();
55
55
  },
56
56
 
57
+ hasIdValue = function (_, element) {
58
+ return element.id !== '';
59
+ },
60
+
57
61
  /**
58
62
  * @method
59
63
  * @name init
60
64
  * @memberof WORKAREA.duplicateId
61
65
  */
62
66
  init = function () {
63
- var $elements = $('[id]'),
67
+ var $elements = $('[id]').filter(hasIdValue),
64
68
  ids = getIdValues($elements);
65
69
 
66
70
  if (_.isEmpty($elements) || noDuplicateIds(ids)) { return; }
@@ -155,7 +155,8 @@ module Workarea
155
155
  self.publish_at = nil
156
156
  save!
157
157
 
158
- changesets.each(&:publish!)
158
+ ordered_changesets.each(&:publish!)
159
+ touch_releasables
159
160
  end
160
161
 
161
162
  def undo!
@@ -163,7 +164,8 @@ module Workarea
163
164
  self.undone_at = Time.current
164
165
  save!
165
166
 
166
- changesets.each(&:undo!)
167
+ ordered_changesets.each(&:undo!)
168
+ touch_releasables
167
169
  end
168
170
 
169
171
  def set_publish_job
@@ -193,6 +195,18 @@ module Workarea
193
195
  StatusCalculator.new(calculators, self).results
194
196
  end
195
197
 
198
+ # Get changesets ordered based on publish priority set by configuration.
199
+ #
200
+ # @return [Array<Workarea::Release::Changeset>]
201
+ #
202
+ def ordered_changesets
203
+ ordering = Workarea.config.release_changeset_ordering
204
+
205
+ changesets.sort_by do |changeset|
206
+ ordering[changeset.releasable_type].presence || 999
207
+ end
208
+ end
209
+
196
210
  private
197
211
 
198
212
  def publish_at_status
@@ -228,5 +242,15 @@ module Workarea
228
242
  errors.add(:undo_at, I18n.t('workarea.errors.messages.undo_unpublished_release'))
229
243
  end
230
244
  end
245
+
246
+ def touch_releasables
247
+ Sidekiq::Callbacks.disable do
248
+ changesets
249
+ .map(&:releasable_from_document_path)
250
+ .compact
251
+ .uniq
252
+ .each(&:touch)
253
+ end
254
+ end
231
255
  end
232
256
  end
@@ -100,15 +100,6 @@ module Workarea
100
100
  end
101
101
  end
102
102
 
103
- private
104
-
105
- def apply_changeset(model, changeset)
106
- changeset.each do |field, new_value|
107
- model.send(:attribute_will_change!, field) # required for correct dirty tracking
108
- model.attributes[field] = new_value
109
- end
110
- end
111
-
112
103
  def releasable_from_document_path
113
104
  return @releasable_from_document_path if defined?(@releasable_from_document_path)
114
105
 
@@ -120,6 +111,15 @@ module Workarea
120
111
  end
121
112
  end
122
113
 
114
+ private
115
+
116
+ def apply_changeset(model, changeset)
117
+ changeset.each do |field, new_value|
118
+ model.send(:attribute_will_change!, field) # required for correct dirty tracking
119
+ model.attributes[field] = new_value
120
+ end
121
+ end
122
+
123
123
  def build_undo(model = releasable_from_document_path)
124
124
  self.undo = changeset.keys.inject({}) do |memo, key|
125
125
  old_value = model.attributes[key]
@@ -1268,6 +1268,21 @@ module Workarea
1268
1268
  # if your CSV files are failing to import with a UTF-8 encoding
1269
1269
  # error.
1270
1270
  config.csv_import_options = { encoding: 'bom|utf-8' }
1271
+
1272
+ # Define the priority order that releasable models' changesets get
1273
+ # published in. Workarea::Navigation::Menu should always be last. Any
1274
+ # model without a defined position will automatically set as 999.
1275
+ config.release_changeset_ordering = {
1276
+ 'Workarea::Pricing::Price' => 0,
1277
+ 'Workarea::Pricing::Sku' => 1,
1278
+ 'Workarea::Catalog::Variant' => 2,
1279
+ 'Workarea::Catalog::Product' => 3,
1280
+ 'Workarea::Content::Block' => 4,
1281
+ 'Workarea::Content' => 5,
1282
+ 'Workarea::Content::Page' => 6,
1283
+ 'Workarea::Catalog::Category' => 7,
1284
+ 'Workarea::Navigation::Menu' => 1_000
1285
+ }
1271
1286
  end
1272
1287
  end
1273
1288
  end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 25
5
+ PATCH = 26
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
@@ -1,4 +1,5 @@
1
1
  //= require workarea/core/modules/environment
2
+ //= require workarea/core/modules/string
2
3
  //= require workarea/core/modules/duplicate_id
3
4
 
4
5
  (function () {
@@ -7,9 +8,14 @@
7
8
  describe('WORKAREA.duplicateId', function () {
8
9
  describe('init', function () {
9
10
  it('throws error on duplicate ids', function () {
10
- this.fixtures = fixture.load('duplicate_id.html');
11
+ this.fixtures = fixture.load('duplicate_id_fail.html');
11
12
  expect(WORKAREA.duplicateId.init).to.throw(Error, /foo|bar/);
12
13
  });
14
+
15
+ it('should allow for empty ID values', function () {
16
+ this.fixtures = fixture.load('duplicate_id_pass.html');
17
+ expect(WORKAREA.duplicateId.init).to.not.throw(Error);
18
+ });
13
19
  });
14
20
  });
15
21
  }());
@@ -0,0 +1,2 @@
1
+ %div{ id: '' }
2
+ %div{ id: '' }
@@ -204,6 +204,34 @@ module Workarea
204
204
  refute(release.valid?)
205
205
  assert_includes(release.errors.full_messages.to_sentence, I18n.t('workarea.errors.messages.undo_unpublished_release'))
206
206
  end
207
+
208
+ def test_ordered_changesets
209
+ release = create_release
210
+ [
211
+ { releasable_type: 'Workarea::Catalog::Category', releasable_id: '123' },
212
+ { releasable_type: 'Workarea::Catalog::Product', releasable_id: 'PROD1' },
213
+ { releasable_type: 'Workarea::Catalog::Variant', releasable_id: 'VAR1' },
214
+ { releasable_type: 'Workarea::Content::Page', releasable_id: 'PAGE1' },
215
+ { releasable_type: 'Workarea::Navigation::Menu', releasable_id: 'NAV1' },
216
+ { releasable_type: 'Workarea::Content', releasable_id: 'CON1' },
217
+ { releasable_type: 'Workarea::Search::Customization', releasable_id: 'CUS1' },
218
+ { releasable_type: 'Workarea::Content::Block', releasable_id: 'BLC1' }
219
+ ].each { |changeset| release.changesets.build(changeset) }
220
+
221
+ assert_equal(
222
+ %w(
223
+ Workarea::Catalog::Variant
224
+ Workarea::Catalog::Product
225
+ Workarea::Content::Block
226
+ Workarea::Content
227
+ Workarea::Content::Page
228
+ Workarea::Catalog::Category
229
+ Workarea::Search::Customization
230
+ Workarea::Navigation::Menu
231
+ ),
232
+ release.ordered_changesets.map(&:releasable_type)
233
+ )
234
+ end
207
235
  end
208
236
 
209
237
  class ReleaseJobsTest < TestCase
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.25
4
+ version: 3.4.26
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-01-07 00:00:00.000000000 Z
11
+ date: 2020-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -882,22 +882,22 @@ dependencies:
882
882
  name: minitest
883
883
  requirement: !ruby/object:Gem::Requirement
884
884
  requirements:
885
- - - ">="
886
- - !ruby/object:Gem::Version
887
- version: 5.10.1
888
885
  - - "~>"
889
886
  - !ruby/object:Gem::Version
890
887
  version: 5.10.3
888
+ - - ">="
889
+ - !ruby/object:Gem::Version
890
+ version: 5.10.1
891
891
  type: :runtime
892
892
  prerelease: false
893
893
  version_requirements: !ruby/object:Gem::Requirement
894
894
  requirements:
895
- - - ">="
896
- - !ruby/object:Gem::Version
897
- version: 5.10.1
898
895
  - - "~>"
899
896
  - !ruby/object:Gem::Version
900
897
  version: 5.10.3
898
+ - - ">="
899
+ - !ruby/object:Gem::Version
900
+ version: 5.10.1
901
901
  - !ruby/object:Gem::Dependency
902
902
  name: countries
903
903
  requirement: !ruby/object:Gem::Requirement
@@ -1987,7 +1987,8 @@ files:
1987
1987
  - test/javascripts/deletion_forms_spec.js
1988
1988
  - test/javascripts/duplicate_id_spec.js
1989
1989
  - test/javascripts/fixtures/deletion_forms.html.haml
1990
- - test/javascripts/fixtures/duplicate_id.html.haml
1990
+ - test/javascripts/fixtures/duplicate_id_fail.html.haml
1991
+ - test/javascripts/fixtures/duplicate_id_pass.html.haml
1991
1992
  - test/javascripts/fixtures/form_submitting_controls.html.haml
1992
1993
  - test/javascripts/fixtures/reveal_password.html.haml
1993
1994
  - test/javascripts/fixtures/workarea_scope.html.haml
@@ -2608,7 +2609,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2608
2609
  - !ruby/object:Gem::Version
2609
2610
  version: '0'
2610
2611
  requirements: []
2611
- rubygems_version: 3.0.6
2612
+ rubygems_version: 3.1.2
2612
2613
  signing_key:
2613
2614
  specification_version: 4
2614
2615
  summary: Core of the Workarea Commerce Platform