workarea-core 3.5.3 → 3.5.4

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: 2ac90c6435c7d45c3c61ac035b3c3cb5b21877ac8349911ef40f43e62ec6069f
4
- data.tar.gz: 793f17140668bc9abb8d7ac5a5b7acda6d5c555cdf07f5e32dab777bcbf680e1
3
+ metadata.gz: 8490f36459db38d3440f85a679bbc51aec0fe302563068a715fc51e78e130ab0
4
+ data.tar.gz: ba46602137e05b884f87a0169a75a896b9e7c7cb2601ce25130fac421dbd5a27
5
5
  SHA512:
6
- metadata.gz: 50996a6fec1bc6b0ad0c8f2272334784255299d87d5f4bbfd4493c69126c9ef56e2a6cb80f74f1968f6f33494ccdaa02ecc5e62df59e78e4d8cf3fdfc8effdcc
7
- data.tar.gz: 37997260c6d65ba8693cde1ef356eb2b0b962d2ecae6b732ccb6d6d644fe46427acff206bb50fcedf2a73b66771e2316b8f8b6f6f5c87afb6553b1bb13ccde64
6
+ metadata.gz: c4188e1edfb091422a9a871dfcd4819d7732e110bf45262d00c59ef532ebce574a64b8ab0e2c097c9a1442432de90b11dbf6acb3d419ca8b9e43da4e46e4b726
7
+ data.tar.gz: 24700c5024b1bbde51a34eca0108ddf71a2caa8cf8edaed22fd5041a51a109b5e7854f8c7a323b103b20ee99536f5b67fb697cdcb1685d50a09d13ff47134cae
@@ -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; }
@@ -186,7 +186,8 @@ module Workarea
186
186
  self.publish_at = nil
187
187
  save!
188
188
 
189
- changesets.each(&:publish!)
189
+ ordered_changesets.each(&:publish!)
190
+ touch_releasables
190
191
  end
191
192
 
192
193
  def set_publish_job
@@ -207,6 +208,18 @@ module Workarea
207
208
  StatusCalculator.new(calculators, self).results
208
209
  end
209
210
 
211
+ # Get changesets ordered based on publish priority set by configuration.
212
+ #
213
+ # @return [Array<Workarea::Release::Changeset>]
214
+ #
215
+ def ordered_changesets
216
+ ordering = Workarea.config.release_changeset_ordering
217
+
218
+ changesets.sort_by do |changeset|
219
+ ordering[changeset.releasable_type].presence || 999
220
+ end
221
+ end
222
+
210
223
  private
211
224
 
212
225
  def publish_at_status
@@ -225,5 +238,15 @@ module Workarea
225
238
  Scheduler.delete(publish_job_id)
226
239
  self.publish_job_id = nil
227
240
  end
241
+
242
+ def touch_releasables
243
+ Sidekiq::Callbacks.disable do
244
+ changesets
245
+ .map(&:releasable_from_document_path)
246
+ .compact
247
+ .uniq
248
+ .each(&:touch)
249
+ end
250
+ end
228
251
  end
229
252
  end
@@ -106,15 +106,6 @@ module Workarea
106
106
  releasable_from_document_path.reload
107
107
  end
108
108
 
109
- private
110
-
111
- def apply_changeset(model, changeset)
112
- changeset.each do |field, new_value|
113
- model.send(:attribute_will_change!, field) # required for correct dirty tracking
114
- model.attributes[field] = new_value
115
- end
116
- end
117
-
118
109
  def releasable_from_document_path
119
110
  return @releasable_from_document_path if defined?(@releasable_from_document_path)
120
111
 
@@ -125,6 +116,15 @@ module Workarea
125
116
  nil
126
117
  end
127
118
  end
119
+
120
+ private
121
+
122
+ def apply_changeset(model, changeset)
123
+ changeset.each do |field, new_value|
124
+ model.send(:attribute_will_change!, field) # required for correct dirty tracking
125
+ model.attributes[field] = new_value
126
+ end
127
+ end
128
128
  end
129
129
  end
130
130
  end
@@ -1276,6 +1276,21 @@ module Workarea
1276
1276
 
1277
1277
  # How long a password reset URL stays valid
1278
1278
  config.password_reset_timeout = 2.hours
1279
+
1280
+ # Define the priority order that releasable models' changesets get
1281
+ # published in. Workarea::Navigation::Menu should always be last. Any
1282
+ # model without a defined position will automatically set as 999.
1283
+ config.release_changeset_ordering = {
1284
+ 'Workarea::Pricing::Price' => 0,
1285
+ 'Workarea::Pricing::Sku' => 1,
1286
+ 'Workarea::Catalog::Variant' => 2,
1287
+ 'Workarea::Catalog::Product' => 3,
1288
+ 'Workarea::Content::Block' => 4,
1289
+ 'Workarea::Content' => 5,
1290
+ 'Workarea::Content::Page' => 6,
1291
+ 'Workarea::Catalog::Category' => 7,
1292
+ 'Workarea::Navigation::Menu' => 1_000
1293
+ }
1279
1294
  end
1280
1295
  end
1281
1296
  end
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 5
5
- PATCH = 3
5
+ PATCH = 4
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
8
8
 
@@ -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: '' }
@@ -160,62 +160,32 @@ module Workarea
160
160
  assert(release.published?)
161
161
  end
162
162
 
163
- def test_scheduled_before
164
- one_week_from_now = 1.week.from_now
165
-
166
- one = create_release(publish_at: one_week_from_now)
167
- two = create_release(publish_at: nil)
168
- three = create_release(publish_at: 8.days.from_now)
169
- four = create_release(publish_at: 6.days.from_now)
170
- five = create_release(publish_at: one_week_from_now)
171
- six = create_release(publish_at: 4.days.from_now)
172
-
173
- assert_equal([six, four, five], one.scheduled_before)
174
- assert_equal([], two.scheduled_before)
175
- assert_equal([six, four, one, five], three.scheduled_before)
176
- assert_equal([six], four.scheduled_before)
177
- assert_equal([six, four, one], five.scheduled_before)
178
- assert_equal([], six.scheduled_before)
179
- end
180
-
181
- def test_scheduled_after
182
- one_week_from_now = 1.week.from_now
183
-
184
- one = create_release(name: '1', publish_at: one_week_from_now)
185
- two = create_release(name: '2', publish_at: nil)
186
- three = create_release(name: '3', publish_at: 8.days.from_now)
187
- four = create_release(name: '4', publish_at: 6.days.from_now)
188
- five = create_release(name: '5', publish_at: one_week_from_now)
189
- six = create_release(name: '6', publish_at: 4.days.from_now)
190
-
191
- assert_equal([five, three], one.scheduled_after)
192
- assert_equal([], two.scheduled_after)
193
- assert_equal([], three.scheduled_after)
194
- assert_equal([one, five, three], four.scheduled_after)
195
- assert_equal([one, three], five.scheduled_after)
196
- assert_equal([four, one, five, three], six.scheduled_after)
197
- end
198
-
199
- def test_previous
163
+ def test_ordered_changesets
200
164
  release = create_release
201
- assert_nil(release.previous)
202
-
203
- release.update_attributes!(publish_at: 1.week.from_now)
204
- assert_nil(release.previous)
205
-
206
- first = create_release(publish_at: 1.day.from_now)
207
- assert_equal(first, release.previous)
208
-
209
- third = create_release(publish_at: 2.days.from_now)
210
- assert_equal(third, release.previous)
211
- end
212
-
213
- def test_build_undo
214
- release = create_release
215
- undo = release.build_undo
216
- assert(undo.name.present?)
217
- assert_equal(undo, release.undo)
218
- assert_equal(release, undo.undoes)
165
+ [
166
+ { releasable_type: 'Workarea::Catalog::Category', releasable_id: '123' },
167
+ { releasable_type: 'Workarea::Catalog::Product', releasable_id: 'PROD1' },
168
+ { releasable_type: 'Workarea::Catalog::Variant', releasable_id: 'VAR1' },
169
+ { releasable_type: 'Workarea::Content::Page', releasable_id: 'PAGE1' },
170
+ { releasable_type: 'Workarea::Navigation::Menu', releasable_id: 'NAV1' },
171
+ { releasable_type: 'Workarea::Content', releasable_id: 'CON1' },
172
+ { releasable_type: 'Workarea::Search::Customization', releasable_id: 'CUS1' },
173
+ { releasable_type: 'Workarea::Content::Block', releasable_id: 'BLC1' }
174
+ ].each { |changeset| release.changesets.build(changeset) }
175
+
176
+ assert_equal(
177
+ %w(
178
+ Workarea::Catalog::Variant
179
+ Workarea::Catalog::Product
180
+ Workarea::Content::Block
181
+ Workarea::Content
182
+ Workarea::Content::Page
183
+ Workarea::Catalog::Category
184
+ Workarea::Search::Customization
185
+ Workarea::Navigation::Menu
186
+ ),
187
+ release.ordered_changesets.map(&:releasable_type)
188
+ )
219
189
  end
220
190
  end
221
191
  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.3
4
+ version: 3.5.4
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
@@ -896,22 +896,22 @@ dependencies:
896
896
  name: minitest
897
897
  requirement: !ruby/object:Gem::Requirement
898
898
  requirements:
899
- - - ">="
900
- - !ruby/object:Gem::Version
901
- version: 5.10.1
902
899
  - - "~>"
903
900
  - !ruby/object:Gem::Version
904
901
  version: 5.10.3
902
+ - - ">="
903
+ - !ruby/object:Gem::Version
904
+ version: 5.10.1
905
905
  type: :runtime
906
906
  prerelease: false
907
907
  version_requirements: !ruby/object:Gem::Requirement
908
908
  requirements:
909
- - - ">="
910
- - !ruby/object:Gem::Version
911
- version: 5.10.1
912
909
  - - "~>"
913
910
  - !ruby/object:Gem::Version
914
911
  version: 5.10.3
912
+ - - ">="
913
+ - !ruby/object:Gem::Version
914
+ version: 5.10.1
915
915
  - !ruby/object:Gem::Dependency
916
916
  name: countries
917
917
  requirement: !ruby/object:Gem::Requirement
@@ -2056,7 +2056,8 @@ files:
2056
2056
  - test/javascripts/deletion_forms_spec.js
2057
2057
  - test/javascripts/duplicate_id_spec.js
2058
2058
  - test/javascripts/fixtures/deletion_forms.html.haml
2059
- - test/javascripts/fixtures/duplicate_id.html.haml
2059
+ - test/javascripts/fixtures/duplicate_id_fail.html.haml
2060
+ - test/javascripts/fixtures/duplicate_id_pass.html.haml
2060
2061
  - test/javascripts/fixtures/form_submitting_controls.html.haml
2061
2062
  - test/javascripts/fixtures/reveal_password.html.haml
2062
2063
  - test/javascripts/fixtures/workarea_scope.html.haml
@@ -2717,7 +2718,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2717
2718
  - !ruby/object:Gem::Version
2718
2719
  version: '0'
2719
2720
  requirements: []
2720
- rubygems_version: 3.0.6
2721
+ rubygems_version: 3.1.2
2721
2722
  signing_key:
2722
2723
  specification_version: 4
2723
2724
  summary: Core of the Workarea Commerce Platform