ba_spree_loyalty_points 1.0.0 → 1.0.2
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/LICENSE +688 -1
- data/README.md +1 -1
- data/app/controllers/spree/admin/loyalty_points_transactions_controller.rb +5 -1
- data/app/controllers/spree/admin/resource_controller_decorator.rb +4 -0
- data/app/controllers/spree/admin/return_authorizations_controller_decorator.rb +10 -2
- data/app/controllers/spree/loyalty_points_controller.rb +1 -1
- data/app/controllers/{spree → spree_loyalty_points}/checkout_controller_decorator.rb +5 -3
- data/app/models/concerns/spree/loyalty_points.rb +3 -3
- data/app/models/concerns/spree/order/loyalty_points.rb +1 -1
- data/app/models/concerns/spree/payment/loyalty_points.rb +27 -27
- data/app/models/spree/loyalty_points_transaction.rb +12 -1
- data/app/models/{spree → spree_loyalty_points}/order_decorator.rb +2 -2
- data/app/models/{spree → spree_loyalty_points}/payment_decorator.rb +5 -2
- data/app/models/{spree → spree_loyalty_points}/payment_method_decorator.rb +2 -2
- data/app/models/spree_loyalty_points/store_decorator.rb +13 -0
- data/app/overrides/add_loyalty_points_debiting_to_return_authorization_page.rb +6 -6
- data/app/overrides/add_loyalty_points_to_account_nav.rb +13 -0
- data/app/overrides/add_loyalty_points_to_admin_user_show_page.rb +12 -10
- data/app/overrides/add_loyalty_points_to_cart_page.rb +9 -5
- data/app/overrides/add_loyalty_points_to_order_checkout_page.rb +11 -7
- data/app/overrides/add_loyalty_points_to_return_authorization_index_page.rb +24 -10
- data/app/overrides/add_loyalty_points_transaction_table_to_return_authorization_form.rb +13 -3
- data/app/overrides/spree/admin/stores/add_loyalty_points_settings.rb +5 -2
- data/app/views/spree/admin/loyalty_points_transactions/new.html.erb +6 -10
- data/app/views/spree/admin/stores/_loyalty_points_settings.html.erb +21 -21
- data/app/views/spree/checkout/payment/_loyaltypoints.html.erb +3 -3
- data/app/views/spree/loyalty_points/_transaction_table.html.erb +2 -2
- data/db/migrate/20140116090042_add_loyalty_points_balance_to_spree_user.rb +1 -1
- data/db/migrate/20140116110437_create_loyalty_points_transactions.rb +1 -1
- data/db/migrate/20140117062720_add_timestamps_to_loyalty_points_transaction.rb +1 -1
- data/db/migrate/20140117065314_add_fields_to_spree_loyalty_points_transaction.rb +1 -1
- data/db/migrate/20140122084005_add_comment_to_spree_loyalty_points_transaction.rb +1 -1
- data/db/migrate/20140123092709_add_paid_at_to_spree_order.rb +1 -1
- data/db/migrate/20140123120355_add_loyalty_points_to_spree_return_authorization.rb +1 -1
- data/db/migrate/20140124121728_add_loyalty_points_awarded_to_spree_order.rb +1 -1
- data/db/migrate/20140130131957_rename_fields_in_spree_loyalty_points_transaction.rb +1 -1
- data/db/migrate/20140131072702_remove_loyalty_points_awarded_from_spree_order.rb +1 -1
- data/db/migrate/20140203063433_add_indexing_to_spree_loyalty_points_transaction.rb +1 -1
- data/db/migrate/20140205111553_add_transaction_id_to_spree_loyalty_points_transactions.rb +1 -1
- data/db/migrate/20140207055836_add_lock_version_to_spree_user.rb +1 -1
- data/db/migrate/20251210070500_remove_lock_version_from_spree_user.rb +11 -0
- data/lib/ba_spree_loyalty_points.rb +1 -0
- data/lib/spree_loyalty_points/engine.rb +3 -2
- data/lib/spree_loyalty_points/version.rb +1 -1
- metadata +64 -24
- data/app/models/spree/store_decorator.rb +0 -23
- data/app/overrides/add_condition_to_amount_on_return_authorization_page.rb +0 -8
- data/app/overrides/add_loyalty_points_balance_to_account_page.rb +0 -9
- data/lib/spree_loyalty_points/factories.rb +0 -84
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddFieldsToSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[
|
|
1
|
+
class AddFieldsToSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[8.0]
|
|
2
2
|
def change
|
|
3
3
|
add_column :spree_loyalty_points_transactions, :source_type, :string
|
|
4
4
|
rename_column :spree_loyalty_points_transactions, :order_id, :source_id
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddLoyaltyPointsToSpreeReturnAuthorization < ActiveRecord::Migration[
|
|
1
|
+
class AddLoyaltyPointsToSpreeReturnAuthorization < ActiveRecord::Migration[8.0]
|
|
2
2
|
def change
|
|
3
3
|
add_column :spree_return_authorizations, :loyalty_points, :integer, default: 0, null: false
|
|
4
4
|
add_column :spree_return_authorizations, :loyalty_points_transaction_type, :string
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class RenameFieldsInSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[
|
|
1
|
+
class RenameFieldsInSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[8.0]
|
|
2
2
|
def change
|
|
3
3
|
rename_column :spree_loyalty_points_transactions, :updated_balance, :balance
|
|
4
4
|
rename_column :spree_loyalty_points_transactions, :transaction_type, :type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddIndexingToSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[
|
|
1
|
+
class AddIndexingToSpreeLoyaltyPointsTransaction < ActiveRecord::Migration[8.0]
|
|
2
2
|
def change
|
|
3
3
|
add_index :spree_loyalty_points_transactions, [:source_type, :source_id], name: 'by_source'
|
|
4
4
|
add_index :spree_loyalty_points_transactions, :user_id
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class AddLockVersionToSpreeUser < ActiveRecord::Migration[
|
|
1
|
+
class AddLockVersionToSpreeUser < ActiveRecord::Migration[8.0]
|
|
2
2
|
def change
|
|
3
3
|
users_table_name = Spree.user_class.present? ? Spree.user_class.table_name : :spree_users
|
|
4
4
|
add_column users_table_name, :lock_version, :integer, default: 0, null: false unless column_exists?(users_table_name, :lock_version)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class RemoveLockVersionFromSpreeUser < ActiveRecord::Migration[8.0]
|
|
2
|
+
def change
|
|
3
|
+
# Remove lock_version column that was added by 20140207055836_add_lock_version_to_spree_user.rb
|
|
4
|
+
# This column is not actually used by the loyalty points engine and causes
|
|
5
|
+
# ActiveRecord::StaleObjectError when User is touched by related models
|
|
6
|
+
users_table_name = Spree.user_class.present? ? Spree.user_class.table_name : :spree_users
|
|
7
|
+
if table_exists?(users_table_name) && column_exists?(users_table_name, :lock_version)
|
|
8
|
+
remove_column users_table_name, :lock_version, :integer, default: 0, null: false
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -15,6 +15,7 @@ module SpreeLoyaltyPoints
|
|
|
15
15
|
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
|
16
16
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
|
17
17
|
end
|
|
18
|
+
Rails.application.config.paths["app/views"].unshift([Spree::Storefront::Engine.root, 'app/views/themes/default'].join('/'))
|
|
18
19
|
|
|
19
20
|
Spree.user_class.class_eval do
|
|
20
21
|
validates :loyalty_points_balance, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
@@ -26,7 +27,7 @@ module SpreeLoyaltyPoints
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def loyalty_points_balance_sufficient?
|
|
29
|
-
loyalty_points_balance >= Spree::Store.default.
|
|
30
|
+
loyalty_points_balance >= Spree::Store.default.preferred_loyalty_points_redeeming_balance
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def has_sufficient_loyalty_points?(order)
|
|
@@ -34,7 +35,7 @@ module SpreeLoyaltyPoints
|
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def loyalty_points_equivalent_currency
|
|
37
|
-
loyalty_points_balance * Spree::Store.default.
|
|
38
|
+
loyalty_points_balance * Spree::Store.default.preferred_loyalty_points_conversion_rate
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ba_spree_loyalty_points
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- be agile Co., Ltd.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree_core
|
|
@@ -16,42 +16,56 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 5.3.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 5.3.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: spree_admin
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 5.3.6
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 5.3.6
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: spree_storefront
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 5.3.6
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 5.3.6
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: deface
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
59
|
- - ">="
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
61
|
+
version: '0'
|
|
48
62
|
type: :runtime
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
66
|
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
68
|
+
version: '0'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: capybara
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -170,14 +184,14 @@ dependencies:
|
|
|
170
184
|
requirements:
|
|
171
185
|
- - "~>"
|
|
172
186
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: 5.
|
|
187
|
+
version: 5.1.1
|
|
174
188
|
type: :development
|
|
175
189
|
prerelease: false
|
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
191
|
requirements:
|
|
178
192
|
- - "~>"
|
|
179
193
|
- !ruby/object:Gem::Version
|
|
180
|
-
version: 5.
|
|
194
|
+
version: 5.1.1
|
|
181
195
|
- !ruby/object:Gem::Dependency
|
|
182
196
|
name: selenium-webdriver
|
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -220,6 +234,34 @@ dependencies:
|
|
|
220
234
|
- - "~>"
|
|
221
235
|
- !ruby/object:Gem::Version
|
|
222
236
|
version: 1.3.13
|
|
237
|
+
- !ruby/object:Gem::Dependency
|
|
238
|
+
name: rails-controller-testing
|
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
|
240
|
+
requirements:
|
|
241
|
+
- - "~>"
|
|
242
|
+
- !ruby/object:Gem::Version
|
|
243
|
+
version: 1.0.1
|
|
244
|
+
type: :development
|
|
245
|
+
prerelease: false
|
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
247
|
+
requirements:
|
|
248
|
+
- - "~>"
|
|
249
|
+
- !ruby/object:Gem::Version
|
|
250
|
+
version: 1.0.1
|
|
251
|
+
- !ruby/object:Gem::Dependency
|
|
252
|
+
name: gem_override_marker
|
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
|
254
|
+
requirements:
|
|
255
|
+
- - ">="
|
|
256
|
+
- !ruby/object:Gem::Version
|
|
257
|
+
version: '0'
|
|
258
|
+
type: :development
|
|
259
|
+
prerelease: false
|
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
261
|
+
requirements:
|
|
262
|
+
- - ">="
|
|
263
|
+
- !ruby/object:Gem::Version
|
|
264
|
+
version: '0'
|
|
223
265
|
description: To award loyalty points and add loyalty points payment method to spree. Compatible
|
|
224
266
|
with Ruby 3.1, Rails 7.1 and Spree 4.10.
|
|
225
267
|
email: develop@be-agile.jp
|
|
@@ -236,8 +278,8 @@ files:
|
|
|
236
278
|
- app/controllers/spree/admin/loyalty_points_transactions_controller.rb
|
|
237
279
|
- app/controllers/spree/admin/resource_controller_decorator.rb
|
|
238
280
|
- app/controllers/spree/admin/return_authorizations_controller_decorator.rb
|
|
239
|
-
- app/controllers/spree/checkout_controller_decorator.rb
|
|
240
281
|
- app/controllers/spree/loyalty_points_controller.rb
|
|
282
|
+
- app/controllers/spree_loyalty_points/checkout_controller_decorator.rb
|
|
241
283
|
- app/models/concerns/spree/loyalty_points.rb
|
|
242
284
|
- app/models/concerns/spree/order/loyalty_points.rb
|
|
243
285
|
- app/models/concerns/spree/payment/loyalty_points.rb
|
|
@@ -245,15 +287,14 @@ files:
|
|
|
245
287
|
- app/models/spree/loyalty_points_credit_transaction.rb
|
|
246
288
|
- app/models/spree/loyalty_points_debit_transaction.rb
|
|
247
289
|
- app/models/spree/loyalty_points_transaction.rb
|
|
248
|
-
- app/models/spree/order_decorator.rb
|
|
249
|
-
- app/models/spree/payment_decorator.rb
|
|
250
290
|
- app/models/spree/payment_method/loyalty_points.rb
|
|
251
|
-
- app/models/spree/payment_method_decorator.rb
|
|
252
291
|
- app/models/spree/return_authorization_decorator.rb
|
|
253
|
-
- app/models/
|
|
254
|
-
- app/
|
|
255
|
-
- app/
|
|
292
|
+
- app/models/spree_loyalty_points/order_decorator.rb
|
|
293
|
+
- app/models/spree_loyalty_points/payment_decorator.rb
|
|
294
|
+
- app/models/spree_loyalty_points/payment_method_decorator.rb
|
|
295
|
+
- app/models/spree_loyalty_points/store_decorator.rb
|
|
256
296
|
- app/overrides/add_loyalty_points_debiting_to_return_authorization_page.rb
|
|
297
|
+
- app/overrides/add_loyalty_points_to_account_nav.rb
|
|
257
298
|
- app/overrides/add_loyalty_points_to_admin_user_show_page.rb
|
|
258
299
|
- app/overrides/add_loyalty_points_to_cart_page.rb
|
|
259
300
|
- app/overrides/add_loyalty_points_to_order_checkout_page.rb
|
|
@@ -286,16 +327,15 @@ files:
|
|
|
286
327
|
- db/migrate/20140203063433_add_indexing_to_spree_loyalty_points_transaction.rb
|
|
287
328
|
- db/migrate/20140205111553_add_transaction_id_to_spree_loyalty_points_transactions.rb
|
|
288
329
|
- db/migrate/20140207055836_add_lock_version_to_spree_user.rb
|
|
330
|
+
- db/migrate/20251210070500_remove_lock_version_from_spree_user.rb
|
|
289
331
|
- lib/ba_spree_loyalty_points.rb
|
|
290
332
|
- lib/generators/spree_loyalty_points/install/install_generator.rb
|
|
291
333
|
- lib/spree_loyalty_points/engine.rb
|
|
292
|
-
- lib/spree_loyalty_points/factories.rb
|
|
293
334
|
- lib/spree_loyalty_points/version.rb
|
|
294
335
|
- lib/tasks/loyalty_points/award.rake
|
|
295
336
|
homepage: https://github.com/be-agile/ba_spree_loyalty_points
|
|
296
337
|
licenses:
|
|
297
338
|
- AGPL-3.0-or-later
|
|
298
|
-
- BSD-3-Clause
|
|
299
339
|
metadata: {}
|
|
300
340
|
post_install_message:
|
|
301
341
|
rdoc_options: []
|
|
@@ -313,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
313
353
|
version: '0'
|
|
314
354
|
requirements:
|
|
315
355
|
- none
|
|
316
|
-
rubygems_version: 3.
|
|
356
|
+
rubygems_version: 3.4.9
|
|
317
357
|
signing_key:
|
|
318
358
|
specification_version: 4
|
|
319
359
|
summary: Add loyalty points to spree (be agile fork)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Spree
|
|
2
|
-
module StoreDecorator
|
|
3
|
-
def self.prepended(base)
|
|
4
|
-
existing_settings = base.typed_stores[:settings]&.fields || {}
|
|
5
|
-
base.typed_store :settings, coder: ActiveRecord::TypedStore::IdentityCoder do |s|
|
|
6
|
-
existing_settings.each do |name, field|
|
|
7
|
-
s.send(field.type_sym, name, **field.instance_variables.each_with_object({}) { |var, hash|
|
|
8
|
-
hash[var.to_s.delete("@").to_sym] = field.instance_variable_get(var) unless var == :@type
|
|
9
|
-
})
|
|
10
|
-
end
|
|
11
|
-
unless existing_settings.key?(:loyalty_points_awarding_unit)
|
|
12
|
-
s.decimal :loyalty_points_awarding_unit, default: 0.01, null: false
|
|
13
|
-
s.decimal :loyalty_points_redeeming_balance, default: 0.0, null: false
|
|
14
|
-
s.decimal :loyalty_points_conversion_rate, default: 1.0, null: false
|
|
15
|
-
s.integer :loyalty_points_award_period, default: 12, null: false
|
|
16
|
-
s.decimal :min_amount_required_to_get_loyalty_points, default: 0.0, null: false
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
Spree::Store.prepend Spree::StoreDecorator
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Deface::Override.new(virtual_path: 'spree/admin/return_authorizations/_form',
|
|
2
|
-
name: 'surround_amount_with_condition_in_return_authorization_form',
|
|
3
|
-
surround: "erb[loud]:contains('field_container :amount')",
|
|
4
|
-
text: "
|
|
5
|
-
<% if !@return_authorization.order.loyalty_points_used? %>
|
|
6
|
-
<%= render_original %>
|
|
7
|
-
<% end %>
|
|
8
|
-
")
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
Deface::Override.new(virtual_path: 'spree/users/show',
|
|
2
|
-
name: 'add_loyalty_points_balance_to_account_page',
|
|
3
|
-
insert_after: ".account-page-user-info-item-store-credits",
|
|
4
|
-
text: "
|
|
5
|
-
<dl id='loyalty-points-info'>
|
|
6
|
-
<dt><%= Spree.t(:loyalty_points_balance) %></dt>
|
|
7
|
-
<dd><%= @user.loyalty_points_balance %> (<%= link_to Spree.t(:details), spree.loyalty_points_path %>)</dd>
|
|
8
|
-
</dl>
|
|
9
|
-
")
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
FactoryGirl.define do
|
|
2
|
-
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
|
|
3
|
-
#
|
|
4
|
-
# Example adding this to your spec_helper will load these Factories for use:
|
|
5
|
-
# require 'spree_loyalty_points/factories'
|
|
6
|
-
|
|
7
|
-
factory :loyalty_points_transaction, class: Spree::LoyaltyPointsTransaction do
|
|
8
|
-
loyalty_points { (10..99).to_a.sample }
|
|
9
|
-
balance { (100..999).to_a.sample }
|
|
10
|
-
comment { FFaker::Lorem.words(3).join(' ') }
|
|
11
|
-
type "Spree::LoyaltyPointsCreditTransaction"
|
|
12
|
-
|
|
13
|
-
association :user, factory: :user_with_loyalty_points
|
|
14
|
-
|
|
15
|
-
factory :loyalty_points_credit_transaction, class: Spree::LoyaltyPointsCreditTransaction do
|
|
16
|
-
type "Spree::LoyaltyPointsCreditTransaction"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
factory :loyalty_points_debit_transaction, class: Spree::LoyaltyPointsDebitTransaction do
|
|
20
|
-
type "Spree::LoyaltyPointsDebitTransaction"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
factory :user_with_loyalty_points, parent: :user do
|
|
26
|
-
loyalty_points_balance { (100..999).to_a.sample }
|
|
27
|
-
|
|
28
|
-
transient do
|
|
29
|
-
transactions_count 5
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
after(:create) do |user, evaluator|
|
|
33
|
-
create_list(:loyalty_points_transaction, evaluator.transactions_count, user: user)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
factory :order_with_loyalty_points, parent: :order do
|
|
38
|
-
|
|
39
|
-
association :user, factory: :user_with_loyalty_points
|
|
40
|
-
|
|
41
|
-
transient do
|
|
42
|
-
transactions_count 5
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
after(:create) do |order, evaluator|
|
|
46
|
-
create_list(:loyalty_points_transaction, evaluator.transactions_count, source: order)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
factory :shipped_order_with_loyalty_points, parent: :shipped_order do
|
|
50
|
-
transient do
|
|
51
|
-
shipments_count 5
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
after(:create) do |order, evaluator|
|
|
55
|
-
create_list(:shipment, evaluator.shipments_count, order: order, state: "shipped")
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
factory :payment_with_loyalty_points, parent: :payment do
|
|
62
|
-
|
|
63
|
-
association :order, factory: :order_with_loyalty_points
|
|
64
|
-
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
factory :return_authorization_with_loyalty_points, parent: :return_authorization do
|
|
68
|
-
loyalty_points { (50..99).to_a.sample }
|
|
69
|
-
loyalty_points_transaction_type "Debit"
|
|
70
|
-
|
|
71
|
-
association :order, factory: :shipped_order_with_loyalty_points
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
FactoryGirl.modify do
|
|
78
|
-
|
|
79
|
-
factory :return_authorization, class: Spree::ReturnAuthorization do
|
|
80
|
-
loyalty_points { (50..99).to_a.sample }
|
|
81
|
-
loyalty_points_transaction_type "Debit"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|