solidus_core 2.1.1 → 2.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/app/assets/config/solidus_core_manifest.js +1 -0
- data/app/assets/javascripts/spree.js.erb +72 -0
- data/app/helpers/spree/store_helper.rb +5 -0
- data/app/jobs/spree/promotion_code_batch_job.rb +24 -0
- data/app/mailers/spree/promotion_code_batch_mailer.rb +13 -0
- data/app/models/concerns/spree/calculated_adjustments.rb +1 -1
- data/app/models/concerns/spree/ordered_property_value_list.rb +2 -2
- data/app/models/concerns/spree/user_address_book.rb +4 -4
- data/app/models/concerns/spree/user_methods.rb +7 -0
- data/app/models/concerns/spree/user_payment_source.rb +12 -5
- data/app/models/spree/address.rb +14 -3
- data/app/models/spree/adjustment.rb +13 -1
- data/app/models/spree/app_configuration.rb +0 -19
- data/app/models/spree/base.rb +2 -0
- data/app/models/spree/credit_card.rb +34 -43
- data/app/models/spree/gateway/bogus.rb +1 -1
- data/app/models/spree/gateway.rb +6 -4
- data/app/models/spree/inventory_unit.rb +3 -2
- data/app/models/spree/order/checkout.rb +187 -273
- data/app/models/spree/order.rb +137 -71
- data/app/models/spree/order_contents.rb +1 -1
- data/app/models/spree/order_inventory.rb +11 -11
- data/app/models/spree/order_promotion.rb +2 -0
- data/app/models/spree/order_update_attributes.rb +1 -8
- data/app/models/spree/order_updater.rb +67 -63
- data/app/models/spree/payment.rb +0 -1
- data/app/models/spree/payment_create.rb +27 -7
- data/app/models/spree/payment_method/store_credit.rb +3 -3
- data/app/models/spree/payment_method.rb +4 -1
- data/app/models/spree/payment_source.rb +45 -0
- data/app/models/spree/product/scopes.rb +24 -24
- data/app/models/spree/product.rb +4 -4
- data/app/models/spree/promotion.rb +2 -0
- data/app/models/spree/promotion_code/batch_builder.rb +63 -0
- data/app/models/spree/promotion_code.rb +1 -0
- data/app/models/spree/promotion_code_batch.rb +25 -0
- data/app/models/spree/promotion_handler/cart.rb +2 -2
- data/app/models/spree/promotion_handler/coupon.rb +1 -2
- data/app/models/spree/promotion_handler/free_shipping.rb +32 -21
- data/app/models/spree/promotion_handler/page.rb +1 -1
- data/app/models/spree/reimbursement.rb +1 -1
- data/app/models/spree/return_authorization.rb +0 -28
- data/app/models/spree/return_item.rb +1 -1
- data/app/models/spree/shipment.rb +4 -4
- data/app/models/spree/shipping_method.rb +2 -2
- data/app/models/spree/shipping_rate.rb +1 -1
- data/app/models/spree/stock/availability_validator.rb +16 -17
- data/app/models/spree/stock/coordinator.rb +3 -3
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +5 -4
- data/app/models/spree/stock_location.rb +2 -2
- data/app/models/spree/store.rb +2 -2
- data/app/models/spree/store_credit.rb +1 -1
- data/app/models/spree/tax/tax_helpers.rb +3 -3
- data/app/models/spree/tax_rate.rb +7 -1
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant/scopes.rb +5 -5
- data/app/models/spree/variant/vat_price_generator.rb +8 -5
- data/app/models/spree/variant.rb +1 -0
- data/app/models/spree/wallet/add_payment_sources_to_wallet.rb +19 -10
- data/app/models/spree/wallet/default_payment_builder.rb +6 -6
- data/app/models/spree/wallet.rb +71 -0
- data/app/models/spree/wallet_payment_source.rb +17 -0
- data/app/models/spree/zone.rb +1 -1
- data/app/views/spree/carton_mailer/shipped_email.text.erb +1 -1
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb +2 -0
- data/app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb +2 -0
- data/app/views/spree/reimbursement_mailer/reimbursement_email.html.erb +0 -7
- data/app/views/spree/reimbursement_mailer/reimbursement_email.text.erb +0 -5
- data/app/views/spree/shared/_error_messages.html.erb +1 -1
- data/app/views/spree/shipment_mailer/shipped_email.html.erb +1 -1
- data/config/initializers/assets.rb +1 -1
- data/config/initializers/friendly_id.rb +1 -1
- data/config/locales/en.yml +50 -12
- data/db/default/spree/store_credit.rb +2 -1
- data/db/migrate/20130826062534_add_depth_to_spree_taxons.rb +4 -6
- data/db/migrate/20160420044191_create_spree_wallet_payment_sources.rb +23 -0
- data/db/migrate/20160420181916_migrate_credit_cards_to_wallet_payment_sources.rb +26 -0
- data/db/migrate/20161017102621_create_spree_promotion_code_batch.rb +36 -0
- data/db/migrate/20161129035810_add_index_to_spree_payments_number.rb +5 -0
- data/db/migrate/20170223235001_remove_spree_store_credits_column.rb +5 -0
- data/lib/generators/spree/dummy/templates/rails/application.rb +1 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
- data/lib/generators/spree/install/install_generator.rb +6 -5
- data/lib/spree/core/controller_helpers/payment_parameters.rb +54 -0
- data/lib/spree/core/engine.rb +6 -9
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +0 -1
- data/lib/spree/money.rb +18 -0
- data/lib/spree/permission_sets/default_customer.rb +1 -1
- data/lib/spree/permitted_attributes.rb +1 -1
- data/lib/spree/testing_support/authorization_helpers.rb +1 -0
- data/lib/spree/testing_support/capybara_ext.rb +13 -0
- data/lib/spree/testing_support/factories/order_factory.rb +5 -1
- data/lib/spree/testing_support/factories/payment_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +0 -1
- data/solidus_core.gemspec +3 -3
- data/spec/jobs/promotion_code_batch_job_spec.rb +65 -0
- data/spec/lib/calculated_adjustments_spec.rb +105 -1
- data/spec/lib/spree/core/testing_support/factories/order_factory_spec.rb +4 -1
- data/spec/lib/spree/core/testing_support/factories/payment_factory_spec.rb +8 -0
- data/spec/lib/spree/money_spec.rb +32 -0
- data/spec/lib/spree/permission_sets/default_customer_spec.rb +20 -0
- data/spec/mailers/promotion_code_batch_mailer_spec.rb +45 -0
- data/spec/models/spree/credit_card_spec.rb +86 -86
- data/spec/models/spree/gateway_spec.rb +3 -1
- data/spec/models/spree/inventory_unit_spec.rb +12 -4
- data/spec/models/spree/order/checkout_spec.rb +11 -32
- data/spec/models/spree/order/tax_spec.rb +2 -2
- data/spec/models/spree/order_contents_spec.rb +24 -1
- data/spec/models/spree/order_inventory_spec.rb +130 -83
- data/spec/models/spree/order_spec.rb +15 -117
- data/spec/models/spree/order_update_attributes_spec.rb +1 -44
- data/spec/models/spree/order_updater_spec.rb +10 -13
- data/spec/models/spree/payment_create_spec.rb +5 -1
- data/spec/models/spree/payment_method_spec.rb +16 -0
- data/spec/models/spree/payment_spec.rb +14 -8
- data/spec/models/spree/promotion_code/batch_builder_spec.rb +61 -0
- data/spec/models/spree/promotion_code_batch_spec.rb +58 -0
- data/spec/models/spree/promotion_code_spec.rb +4 -0
- data/spec/models/spree/promotion_spec.rb +3 -6
- data/spec/models/spree/return_authorization_spec.rb +0 -59
- data/spec/models/spree/shipment_spec.rb +4 -4
- data/spec/models/spree/stock/availability_validator_spec.rb +64 -9
- data/spec/models/spree/tax/item_adjuster_spec.rb +1 -2
- data/spec/models/spree/unit_cancel_spec.rb +0 -85
- data/spec/models/spree/user_spec.rb +3 -1
- data/spec/models/spree/variant/vat_price_generator_spec.rb +8 -2
- data/spec/models/spree/variant_spec.rb +16 -4
- data/spec/models/spree/wallet_payment_source_spec.rb +46 -0
- data/spec/models/spree/wallet_spec.rb +128 -0
- data/spec/support/concerns/payment_source.rb +64 -0
- metadata +51 -25
- data/app/assets/javascripts/spree.js.coffee.erb +0 -64
- data/app/models/spree/promotion_builder.rb +0 -55
- data/app/models/spree/promotion_code/code_builder.rb +0 -62
- data/config/initializers/premailer_assets.rb +0 -1
- data/lib/spree/core/unreturned_item_charger.rb +0 -106
- data/lib/tasks/exchanges.rake +0 -47
- data/spec/lib/spree/core/unreturned_item_charger_spec.rb +0 -126
- data/spec/lib/tasks/exchanges_spec.rb +0 -220
- data/spec/models/spree/promotion_builder_spec.rb +0 -120
- data/spec/models/spree/promotion_code/code_builder_spec.rb +0 -77
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::WalletPaymentSource, type: :model do
|
4
|
+
subject { Spree::WalletPaymentSource }
|
5
|
+
|
6
|
+
describe "validation" do
|
7
|
+
context 'with a non-PaymentSource model' do
|
8
|
+
with_model 'NonPaymentSource', scope: :all do
|
9
|
+
model do
|
10
|
+
# We have to set this up or else `inverse_of` prevents us from testing our code
|
11
|
+
has_many :wallet_payment_sources, class_name: 'Spree::WalletPaymentSource', as: :payment_source, inverse_of: :payment_source
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:payment_source) { NonPaymentSource.create! }
|
16
|
+
|
17
|
+
it "errors when `payment_source` is not a `Spree::PaymentSource`" do
|
18
|
+
wallet_payment_source = Spree::WalletPaymentSource.new(
|
19
|
+
payment_source: payment_source,
|
20
|
+
user: create(:user)
|
21
|
+
)
|
22
|
+
|
23
|
+
expect(wallet_payment_source).not_to be_valid
|
24
|
+
expect(wallet_payment_source.errors.messages).to eq(
|
25
|
+
{ payment_source: ["has to be a Spree::PaymentSource"] }
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "is valid with a `credit_card` as `payment_source`" do
|
31
|
+
valid_attrs = {
|
32
|
+
payment_source: create(:credit_card),
|
33
|
+
user: create(:user)
|
34
|
+
}
|
35
|
+
expect(subject.new(valid_attrs)).to be_valid
|
36
|
+
end
|
37
|
+
|
38
|
+
it "is valid with `store_credit` as `payment_source`" do
|
39
|
+
valid_attrs = {
|
40
|
+
payment_source: create(:store_credit),
|
41
|
+
user: create(:user)
|
42
|
+
}
|
43
|
+
expect(subject.new(valid_attrs)).to be_valid
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Wallet, type: :model do
|
4
|
+
let(:user) { create(:user) }
|
5
|
+
let(:credit_card) { create(:credit_card, user_id: user.id) }
|
6
|
+
let(:store_credit) { create(:store_credit, user_id: user.id) }
|
7
|
+
subject(:wallet) { Spree::Wallet.new(user) }
|
8
|
+
|
9
|
+
describe "#add" do
|
10
|
+
context "with valid payment source" do
|
11
|
+
it "creates a wallet_payment_source for this user's wallet" do
|
12
|
+
expect { subject.add(credit_card) }.to change(Spree::WalletPaymentSource, :count).by(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "only creates the payment source once" do
|
16
|
+
subject.add(credit_card)
|
17
|
+
expect { subject.add(credit_card) }.to_not change(Spree::WalletPaymentSource, :count)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#remove" do
|
23
|
+
context "with payment_source not in the wallet" do
|
24
|
+
it "will raise a RecordNotFound exception" do
|
25
|
+
expect { subject.remove(credit_card) }.to raise_error(ActiveRecord::RecordNotFound)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "with the payment_source in the wallet" do
|
30
|
+
before { subject.add(credit_card) }
|
31
|
+
it "will remove the payment source from the wallet" do
|
32
|
+
expect { subject.remove(credit_card) }.to change(Spree::WalletPaymentSource, :count).by(-1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#wallet_payment_sources" do
|
38
|
+
context "with no payment sources" do
|
39
|
+
it "returns an empty Array" do
|
40
|
+
expect(subject.wallet_payment_sources).to eql []
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with payment sources" do
|
45
|
+
let!(:wallet_credit_card) { subject.add(credit_card) }
|
46
|
+
let!(:wallet_store_credit) { subject.add(store_credit) }
|
47
|
+
|
48
|
+
it "returns all the payment sources" do
|
49
|
+
expect(subject.wallet_payment_sources).to include(wallet_credit_card, wallet_store_credit)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#find" do
|
55
|
+
context "with no payment sources in the wallet" do
|
56
|
+
it "returns nil" do
|
57
|
+
expect(subject.find(1)).to be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "with payment sources in the wallet" do
|
62
|
+
let(:wallet_credit_card) { subject.add(credit_card) }
|
63
|
+
|
64
|
+
it "finds the wallet payment source by id" do
|
65
|
+
expect(subject.find(wallet_credit_card.id)).to eql wallet_credit_card
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#default_wallet_payment_source=" do
|
71
|
+
context "with no current default" do
|
72
|
+
let!(:wallet_credit_card) { subject.add(credit_card) }
|
73
|
+
|
74
|
+
it "marks the passed in payment source as default" do
|
75
|
+
expect { subject.default_wallet_payment_source = wallet_credit_card }.to(
|
76
|
+
change(subject, :default_wallet_payment_source).
|
77
|
+
from(nil).
|
78
|
+
to(wallet_credit_card)
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with other payment source already default" do
|
84
|
+
let!(:wallet_credit_card) { subject.add(credit_card) }
|
85
|
+
let!(:wallet_store_credit) { subject.add(store_credit) }
|
86
|
+
|
87
|
+
before { subject.default_wallet_payment_source = wallet_credit_card }
|
88
|
+
|
89
|
+
it "sets the new payment source as the default" do
|
90
|
+
expect { subject.default_wallet_payment_source = wallet_store_credit }.to(
|
91
|
+
change(subject, :default_wallet_payment_source).
|
92
|
+
from(wallet_credit_card).
|
93
|
+
to(wallet_store_credit)
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with a wallet payment source that does not belong to the wallet' do
|
99
|
+
let(:other_wallet_credit_card) { other_wallet.add(credit_card) }
|
100
|
+
let(:other_wallet) { Spree::Wallet.new(other_user) }
|
101
|
+
let(:other_credit_card) { create(:credit_card, user_id: other_user.id) }
|
102
|
+
let(:other_user) { create(:user) }
|
103
|
+
|
104
|
+
it 'raises an error' do
|
105
|
+
expect {
|
106
|
+
wallet.default_wallet_payment_source = other_wallet_credit_card
|
107
|
+
}.to raise_error(Spree::Wallet::Unauthorized)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#default_wallet_payment_source" do
|
113
|
+
context "with no default payment source present" do
|
114
|
+
it "will return nil" do
|
115
|
+
expect(subject.default_wallet_payment_source).to be_nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "with a default payment source" do
|
120
|
+
let!(:wallet_credit_card) { subject.add(credit_card) }
|
121
|
+
before { subject.default_wallet_payment_source = wallet_credit_card }
|
122
|
+
|
123
|
+
it "will return the wallet payment source" do
|
124
|
+
expect(subject.default_wallet_payment_source).to eql wallet_credit_card
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
RSpec.shared_examples "a payment source" do
|
2
|
+
subject(:payment_source) { described_class.new }
|
3
|
+
|
4
|
+
describe 'attributes' do
|
5
|
+
it { is_expected.to respond_to(:imported) }
|
6
|
+
it { is_expected.to respond_to(:name) }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#associations" do
|
10
|
+
it { is_expected.to respond_to(:payments) }
|
11
|
+
it { is_expected.to respond_to(:user) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#can_capture?" do
|
15
|
+
it "should be true if payment is pending" do
|
16
|
+
payment = mock_model(Spree::Payment, pending?: true, created_at: Time.current)
|
17
|
+
expect(payment_source.can_capture?(payment)).to be true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be true if payment is checkout" do
|
21
|
+
payment = mock_model(Spree::Payment, pending?: false, checkout?: true, created_at: Time.current)
|
22
|
+
expect(payment_source.can_capture?(payment)).to be true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#can_void?" do
|
27
|
+
it "should be true if payment is not void" do
|
28
|
+
payment = mock_model(Spree::Payment, failed?: false, void?: false)
|
29
|
+
expect(payment_source.can_void?(payment)).to be true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#can_credit?" do
|
34
|
+
it "should be false if payment is not completed" do
|
35
|
+
payment = mock_model(Spree::Payment, completed?: false)
|
36
|
+
expect(payment_source.can_credit?(payment)).to be false
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be false when credit_allowed is zero" do
|
40
|
+
payment = mock_model(Spree::Payment, completed?: true, credit_allowed: 0, order: mock_model(Spree::Order, payment_state: 'credit_owed'))
|
41
|
+
expect(payment_source.can_credit?(payment)).to be false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#first_name" do
|
46
|
+
before do
|
47
|
+
payment_source.name = "Ludwig van Beethoven"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "extracts the first name" do
|
51
|
+
expect(payment_source.first_name).to eq "Ludwig"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#last_name" do
|
56
|
+
before do
|
57
|
+
payment_source.name = "Ludwig van Beethoven"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "extracts the last name" do
|
61
|
+
expect(payment_source.last_name).to eq "van Beethoven"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemerchant
|
@@ -132,22 +132,22 @@ dependencies:
|
|
132
132
|
name: kaminari
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0.15'
|
138
135
|
- - ">="
|
139
136
|
- !ruby/object:Gem::Version
|
140
|
-
version: 0.
|
137
|
+
version: '0.17'
|
138
|
+
- - "<"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '2.0'
|
141
141
|
type: :runtime
|
142
142
|
prerelease: false
|
143
143
|
version_requirements: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '0.15'
|
148
145
|
- - ">="
|
149
146
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.
|
147
|
+
version: '0.17'
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '2.0'
|
151
151
|
- !ruby/object:Gem::Dependency
|
152
152
|
name: monetize
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,16 +166,22 @@ dependencies:
|
|
166
166
|
name: paperclip
|
167
167
|
requirement: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
|
-
- - "
|
169
|
+
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '4.2'
|
172
|
+
- - "<"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '6'
|
172
175
|
type: :runtime
|
173
176
|
prerelease: false
|
174
177
|
version_requirements: !ruby/object:Gem::Requirement
|
175
178
|
requirements:
|
176
|
-
- - "
|
179
|
+
- - ">="
|
177
180
|
- !ruby/object:Gem::Version
|
178
181
|
version: '4.2'
|
182
|
+
- - "<"
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '6'
|
179
185
|
- !ruby/object:Gem::Dependency
|
180
186
|
name: paranoia
|
181
187
|
requirement: !ruby/object:Gem::Requirement
|
@@ -298,16 +304,22 @@ dependencies:
|
|
298
304
|
name: twitter_cldr
|
299
305
|
requirement: !ruby/object:Gem::Requirement
|
300
306
|
requirements:
|
301
|
-
- - "
|
307
|
+
- - ">="
|
302
308
|
- !ruby/object:Gem::Version
|
303
309
|
version: '3.0'
|
310
|
+
- - "<"
|
311
|
+
- !ruby/object:Gem::Version
|
312
|
+
version: '5'
|
304
313
|
type: :runtime
|
305
314
|
prerelease: false
|
306
315
|
version_requirements: !ruby/object:Gem::Requirement
|
307
316
|
requirements:
|
308
|
-
- - "
|
317
|
+
- - ">="
|
309
318
|
- !ruby/object:Gem::Version
|
310
319
|
version: '3.0'
|
320
|
+
- - "<"
|
321
|
+
- !ruby/object:Gem::Version
|
322
|
+
version: '5'
|
311
323
|
- !ruby/object:Gem::Dependency
|
312
324
|
name: email_spec
|
313
325
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,12 +344,13 @@ files:
|
|
332
344
|
- LICENSE
|
333
345
|
- README.md
|
334
346
|
- Rakefile
|
347
|
+
- app/assets/config/solidus_core_manifest.js
|
335
348
|
- app/assets/images/logo/solidus_logo.png
|
336
349
|
- app/assets/images/noimage/large.png
|
337
350
|
- app/assets/images/noimage/mini.png
|
338
351
|
- app/assets/images/noimage/product.png
|
339
352
|
- app/assets/images/noimage/small.png
|
340
|
-
- app/assets/javascripts/spree.js.
|
353
|
+
- app/assets/javascripts/spree.js.erb
|
341
354
|
- app/controllers/spree/base_controller.rb
|
342
355
|
- app/helpers/spree/base_helper.rb
|
343
356
|
- app/helpers/spree/checkout_helper.rb
|
@@ -345,9 +358,11 @@ files:
|
|
345
358
|
- app/helpers/spree/products_helper.rb
|
346
359
|
- app/helpers/spree/store_helper.rb
|
347
360
|
- app/helpers/spree/taxons_helper.rb
|
361
|
+
- app/jobs/spree/promotion_code_batch_job.rb
|
348
362
|
- app/mailers/spree/base_mailer.rb
|
349
363
|
- app/mailers/spree/carton_mailer.rb
|
350
364
|
- app/mailers/spree/order_mailer.rb
|
365
|
+
- app/mailers/spree/promotion_code_batch_mailer.rb
|
351
366
|
- app/mailers/spree/reimbursement_mailer.rb
|
352
367
|
- app/mailers/spree/test_mailer.rb
|
353
368
|
- app/models/concerns/spree/adjustment_source.rb
|
@@ -426,6 +441,7 @@ files:
|
|
426
441
|
- app/models/spree/payment_method.rb
|
427
442
|
- app/models/spree/payment_method/check.rb
|
428
443
|
- app/models/spree/payment_method/store_credit.rb
|
444
|
+
- app/models/spree/payment_source.rb
|
429
445
|
- app/models/spree/preference.rb
|
430
446
|
- app/models/spree/preferences/configuration.rb
|
431
447
|
- app/models/spree/preferences/preferable.rb
|
@@ -457,11 +473,11 @@ files:
|
|
457
473
|
- app/models/spree/promotion/rules/user_logged_in.rb
|
458
474
|
- app/models/spree/promotion/rules/user_role.rb
|
459
475
|
- app/models/spree/promotion_action.rb
|
460
|
-
- app/models/spree/promotion_builder.rb
|
461
476
|
- app/models/spree/promotion_category.rb
|
462
477
|
- app/models/spree/promotion_chooser.rb
|
463
478
|
- app/models/spree/promotion_code.rb
|
464
|
-
- app/models/spree/promotion_code/
|
479
|
+
- app/models/spree/promotion_code/batch_builder.rb
|
480
|
+
- app/models/spree/promotion_code_batch.rb
|
465
481
|
- app/models/spree/promotion_handler/cart.rb
|
466
482
|
- app/models/spree/promotion_handler/coupon.rb
|
467
483
|
- app/models/spree/promotion_handler/free_shipping.rb
|
@@ -564,8 +580,10 @@ files:
|
|
564
580
|
- app/models/spree/variant_property_rule.rb
|
565
581
|
- app/models/spree/variant_property_rule_condition.rb
|
566
582
|
- app/models/spree/variant_property_rule_value.rb
|
583
|
+
- app/models/spree/wallet.rb
|
567
584
|
- app/models/spree/wallet/add_payment_sources_to_wallet.rb
|
568
585
|
- app/models/spree/wallet/default_payment_builder.rb
|
586
|
+
- app/models/spree/wallet_payment_source.rb
|
569
587
|
- app/models/spree/zone.rb
|
570
588
|
- app/models/spree/zone_member.rb
|
571
589
|
- app/views/layouts/spree/base_mailer.html.erb
|
@@ -575,6 +593,8 @@ files:
|
|
575
593
|
- app/views/spree/order_mailer/confirm_email.html.erb
|
576
594
|
- app/views/spree/order_mailer/confirm_email.text.erb
|
577
595
|
- app/views/spree/order_mailer/inventory_cancellation_email.text.erb
|
596
|
+
- app/views/spree/promotion_code_batch_mailer/promotion_code_batch_errored.text.erb
|
597
|
+
- app/views/spree/promotion_code_batch_mailer/promotion_code_batch_finished.text.erb
|
578
598
|
- app/views/spree/reimbursement_mailer/reimbursement_email.html.erb
|
579
599
|
- app/views/spree/reimbursement_mailer/reimbursement_email.text.erb
|
580
600
|
- app/views/spree/shared/_base_mailer_footer.html.erb
|
@@ -585,7 +605,6 @@ files:
|
|
585
605
|
- app/views/spree/test_mailer/test_email.text.erb
|
586
606
|
- config/initializers/assets.rb
|
587
607
|
- config/initializers/friendly_id.rb
|
588
|
-
- config/initializers/premailer_assets.rb
|
589
608
|
- config/locales/en.yml
|
590
609
|
- db/default/spree/countries.rb
|
591
610
|
- db/default/spree/return_reasons.rb
|
@@ -883,6 +902,8 @@ files:
|
|
883
902
|
- db/migrate/20160308000300_disallow_adjustment_finalized_nulls.rb
|
884
903
|
- db/migrate/20160318145302_add_timestamps_to_prices.rb
|
885
904
|
- db/migrate/20160330204846_add_missing_timestamp_columns.rb
|
905
|
+
- db/migrate/20160420044191_create_spree_wallet_payment_sources.rb
|
906
|
+
- db/migrate/20160420181916_migrate_credit_cards_to_wallet_payment_sources.rb
|
886
907
|
- db/migrate/20160509181311_add_country_iso_to_prices.rb
|
887
908
|
- db/migrate/20160527070401_rename_shipment_address_field.rb
|
888
909
|
- db/migrate/20160608162651_ensure_default_store.rb
|
@@ -893,7 +914,10 @@ files:
|
|
893
914
|
- db/migrate/20160924135758_remove_is_default_from_prices.rb
|
894
915
|
- db/migrate/20161009141333_remove_currency_from_line_items.rb
|
895
916
|
- db/migrate/20161014221052_add_available_to_columns_and_remove_display_on_from_payment_methods.rb
|
917
|
+
- db/migrate/20161017102621_create_spree_promotion_code_batch.rb
|
896
918
|
- db/migrate/20161123154034_add_available_to_users_and_remove_display_on_from_shipping_methods.rb
|
919
|
+
- db/migrate/20161129035810_add_index_to_spree_payments_number.rb
|
920
|
+
- db/migrate/20170223235001_remove_spree_store_credits_column.rb
|
897
921
|
- db/seeds.rb
|
898
922
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
899
923
|
- lib/generators/spree/custom_user/templates/authentication_helpers.rb.tt
|
@@ -940,7 +964,6 @@ files:
|
|
940
964
|
- lib/spree/core/search/base.rb
|
941
965
|
- lib/spree/core/search/variant.rb
|
942
966
|
- lib/spree/core/stock_configuration.rb
|
943
|
-
- lib/spree/core/unreturned_item_charger.rb
|
944
967
|
- lib/spree/core/validators/email.rb
|
945
968
|
- lib/spree/core/version.rb
|
946
969
|
- lib/spree/deprecation.rb
|
@@ -1057,7 +1080,6 @@ files:
|
|
1057
1080
|
- lib/spree_core.rb
|
1058
1081
|
- lib/tasks/core.rake
|
1059
1082
|
- lib/tasks/email.rake
|
1060
|
-
- lib/tasks/exchanges.rake
|
1061
1083
|
- lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake
|
1062
1084
|
- lib/tasks/migrations/copy_shipped_shipments_to_cartons.rake
|
1063
1085
|
- lib/tasks/migrations/create_vat_prices.rake
|
@@ -1072,6 +1094,7 @@ files:
|
|
1072
1094
|
- spec/helpers/order_helper_spec.rb
|
1073
1095
|
- spec/helpers/products_helper_spec.rb
|
1074
1096
|
- spec/helpers/taxons_helper_spec.rb
|
1097
|
+
- spec/jobs/promotion_code_batch_job_spec.rb
|
1075
1098
|
- spec/lib/calculated_adjustments_spec.rb
|
1076
1099
|
- spec/lib/i18n_spec.rb
|
1077
1100
|
- spec/lib/search/base_spec.rb
|
@@ -1151,15 +1174,14 @@ files:
|
|
1151
1174
|
- spec/lib/spree/core/testing_support/factories/variant_property_rule_value_factory_spec.rb
|
1152
1175
|
- spec/lib/spree/core/testing_support/factories/zone_factory_spec.rb
|
1153
1176
|
- spec/lib/spree/core/testing_support/preferences_spec.rb
|
1154
|
-
- spec/lib/spree/core/unreturned_item_charger_spec.rb
|
1155
1177
|
- spec/lib/spree/core/validators/email_spec.rb
|
1156
1178
|
- spec/lib/spree/core/version_spec.rb
|
1157
1179
|
- spec/lib/spree/localized_number_spec.rb
|
1158
1180
|
- spec/lib/spree/migrations_spec.rb
|
1159
1181
|
- spec/lib/spree/money_spec.rb
|
1182
|
+
- spec/lib/spree/permission_sets/default_customer_spec.rb
|
1160
1183
|
- spec/lib/tasks/dummy_task.rake
|
1161
1184
|
- spec/lib/tasks/dummy_task_spec.rb
|
1162
|
-
- spec/lib/tasks/exchanges_spec.rb
|
1163
1185
|
- spec/lib/tasks/migrations/copy_shipped_shipments_to_cartons_spec.rb
|
1164
1186
|
- spec/lib/tasks/migrations/create_vat_prices_spec.rb
|
1165
1187
|
- spec/lib/tasks/migrations/migrate_shipping_rate_taxes_spec.rb
|
@@ -1167,6 +1189,7 @@ files:
|
|
1167
1189
|
- spec/lib/tasks/upgrade_spec.rb
|
1168
1190
|
- spec/mailers/carton_mailer_spec.rb
|
1169
1191
|
- spec/mailers/order_mailer_spec.rb
|
1192
|
+
- spec/mailers/promotion_code_batch_mailer_spec.rb
|
1170
1193
|
- spec/mailers/reimbursement_mailer_spec.rb
|
1171
1194
|
- spec/mailers/test_mailer_spec.rb
|
1172
1195
|
- spec/models/spree/ability_spec.rb
|
@@ -1287,9 +1310,9 @@ files:
|
|
1287
1310
|
- spec/models/spree/promotion/rules/user_role_spec.rb
|
1288
1311
|
- spec/models/spree/promotion/rules/user_spec.rb
|
1289
1312
|
- spec/models/spree/promotion_action_spec.rb
|
1290
|
-
- spec/models/spree/promotion_builder_spec.rb
|
1291
1313
|
- spec/models/spree/promotion_category_spec.rb
|
1292
|
-
- spec/models/spree/promotion_code/
|
1314
|
+
- spec/models/spree/promotion_code/batch_builder_spec.rb
|
1315
|
+
- spec/models/spree/promotion_code_batch_spec.rb
|
1293
1316
|
- spec/models/spree/promotion_code_spec.rb
|
1294
1317
|
- spec/models/spree/promotion_handler/cart_spec.rb
|
1295
1318
|
- spec/models/spree/promotion_handler/coupon_spec.rb
|
@@ -1370,11 +1393,14 @@ files:
|
|
1370
1393
|
- spec/models/spree/variant_property_rule_spec.rb
|
1371
1394
|
- spec/models/spree/variant_property_rule_value_spec.rb
|
1372
1395
|
- spec/models/spree/variant_spec.rb
|
1396
|
+
- spec/models/spree/wallet_payment_source_spec.rb
|
1397
|
+
- spec/models/spree/wallet_spec.rb
|
1373
1398
|
- spec/models/spree/zone_spec.rb
|
1374
1399
|
- spec/shared_examples/calculator_shared_examples.rb
|
1375
1400
|
- spec/spec_helper.rb
|
1376
1401
|
- spec/support/big_decimal.rb
|
1377
1402
|
- spec/support/concerns/default_price.rb
|
1403
|
+
- spec/support/concerns/payment_source.rb
|
1378
1404
|
- spec/support/concerns/working_factories.rb
|
1379
1405
|
- spec/support/dummy_ability.rb
|
1380
1406
|
- spec/support/shared_contexts/rake.rb
|
@@ -1402,7 +1428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1402
1428
|
version: 1.8.23
|
1403
1429
|
requirements: []
|
1404
1430
|
rubyforge_project:
|
1405
|
-
rubygems_version: 2.6.
|
1431
|
+
rubygems_version: 2.6.10
|
1406
1432
|
signing_key:
|
1407
1433
|
specification_version: 4
|
1408
1434
|
summary: Essential models, mailers, and classes for the Solidus e-commerce project.
|
@@ -1,64 +0,0 @@
|
|
1
|
-
#= require jsuri
|
2
|
-
class window.Spree
|
3
|
-
@ready: (callback) ->
|
4
|
-
if typeof Turbolinks isnt 'undefined' and Turbolinks.supported
|
5
|
-
jQuery(document).on 'turbolinks:load', -> callback(jQuery)
|
6
|
-
else
|
7
|
-
jQuery(document).ready(callback)
|
8
|
-
|
9
|
-
@mountedAt: ->
|
10
|
-
"<%= Rails.application.routes.url_helpers.spree_path(trailing_slash: true) %>"
|
11
|
-
|
12
|
-
@pathFor: (path) ->
|
13
|
-
locationOrigin = "#{window.location.protocol}//#{window.location.hostname}" + (if window.location.port then ":#{window.location.port}" else "")
|
14
|
-
"#{locationOrigin}#{@mountedAt()}#{path}"
|
15
|
-
|
16
|
-
# Helper function to take a URL and add query parameters to it
|
17
|
-
# Uses the JSUri library from here: https://github.com/derek-watson/jsUri
|
18
|
-
# Thanks to Jake Moffat for the suggestion: https://twitter.com/jakeonrails/statuses/321776992221544449
|
19
|
-
@url: (uri, query) ->
|
20
|
-
if Spree.env == 'development' || Spree.env == 'test'
|
21
|
-
console.warn 'Spree.url is deprecated, please use Spree.ajax for your request instead.'
|
22
|
-
if uri.path == undefined
|
23
|
-
uri = new Uri(uri)
|
24
|
-
if query
|
25
|
-
$.each query, (key, value) ->
|
26
|
-
uri.addQueryParam(key, value)
|
27
|
-
return uri
|
28
|
-
|
29
|
-
# This function automatically appends the API token
|
30
|
-
# for the user to the end of any URL.
|
31
|
-
# Immediately after, this string is then passed to jQuery.ajax.
|
32
|
-
#
|
33
|
-
# Spree.ajax works in two ways to support common jQuery syntax:
|
34
|
-
#
|
35
|
-
# Spree.ajax("url", {settings: 'go here'})
|
36
|
-
# or:
|
37
|
-
# Spree.ajax({url: "url", settings: 'go here'})
|
38
|
-
#
|
39
|
-
# Spree.getJSON has the same method signature as $.getJSON
|
40
|
-
@ajax: (url, options) ->
|
41
|
-
if typeof(url) == "object"
|
42
|
-
options = url
|
43
|
-
url = undefined
|
44
|
-
|
45
|
-
options = options || {}
|
46
|
-
|
47
|
-
options = $.extend(options, { headers: { "X-Spree-Token": Spree.api_key } })
|
48
|
-
$.ajax(url, options)
|
49
|
-
|
50
|
-
@routes:
|
51
|
-
states_search: @pathFor('api/states')
|
52
|
-
apply_coupon_code: (order_id) ->
|
53
|
-
Spree.pathFor("api/orders/#{order_id}/apply_coupon_code")
|
54
|
-
|
55
|
-
@getJSON: (url, data, success) ->
|
56
|
-
if typeof data is 'function'
|
57
|
-
success = data
|
58
|
-
data = undefined
|
59
|
-
@ajax(
|
60
|
-
dataType: "json",
|
61
|
-
url: url,
|
62
|
-
data: data,
|
63
|
-
success: success
|
64
|
-
)
|
@@ -1,55 +0,0 @@
|
|
1
|
-
class Spree::PromotionBuilder
|
2
|
-
include ActiveModel::Model
|
3
|
-
|
4
|
-
attr_reader :promotion
|
5
|
-
attr_accessor :base_code, :number_of_codes, :user
|
6
|
-
|
7
|
-
validates :number_of_codes,
|
8
|
-
numericality: { only_integer: true, greater_than: 0 },
|
9
|
-
allow_nil: true
|
10
|
-
|
11
|
-
validate :promotion_validity
|
12
|
-
|
13
|
-
class_attribute :code_builder_class
|
14
|
-
self.code_builder_class = ::Spree::PromotionCode::CodeBuilder
|
15
|
-
|
16
|
-
# @param promotion_attrs [Hash] The desired attributes for the newly promotion
|
17
|
-
# @param attributes [Hash] The desired attributes for this builder
|
18
|
-
# @param user [Spree::User] The user who triggered this promotion build
|
19
|
-
def initialize(attributes = {}, promotion_attributes = {})
|
20
|
-
@promotion = Spree::Promotion.new(promotion_attributes)
|
21
|
-
super(attributes)
|
22
|
-
end
|
23
|
-
|
24
|
-
def perform
|
25
|
-
if can_build_codes?
|
26
|
-
@promotion.codes = code_builder.build_promotion_codes
|
27
|
-
end
|
28
|
-
|
29
|
-
return false unless valid?
|
30
|
-
|
31
|
-
@promotion.save
|
32
|
-
end
|
33
|
-
|
34
|
-
def number_of_codes=(value)
|
35
|
-
@number_of_codes = value.presence.try(:to_i)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def promotion_validity
|
41
|
-
if !@promotion.valid?
|
42
|
-
@promotion.errors.each do |attribute, error|
|
43
|
-
errors[attribute].push error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def can_build_codes?
|
49
|
-
@base_code && @number_of_codes
|
50
|
-
end
|
51
|
-
|
52
|
-
def code_builder
|
53
|
-
self.class.code_builder_class.new(@promotion, @base_code, @number_of_codes)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# A class responsible for building PromotionCodes
|
2
|
-
class ::Spree::PromotionCode::CodeBuilder
|
3
|
-
attr_reader :promotion, :num_codes, :base_code
|
4
|
-
|
5
|
-
class_attribute :random_code_length
|
6
|
-
self.random_code_length = 6
|
7
|
-
|
8
|
-
# Requres a +promotion+, +base_code+ and +num_codes+
|
9
|
-
#
|
10
|
-
# +promotion+ Must be a Spree::Promotion.
|
11
|
-
# +base_code+ Must be a String.
|
12
|
-
# +num_codes+ Must be a positive integer greater than zero.
|
13
|
-
def initialize(promotion, base_code, num_codes)
|
14
|
-
@base_code = base_code
|
15
|
-
@num_codes = num_codes
|
16
|
-
@promotion = promotion
|
17
|
-
end
|
18
|
-
|
19
|
-
# Builds and returns an array of Spree::PromotionCode's
|
20
|
-
def build_promotion_codes
|
21
|
-
codes.map do |code|
|
22
|
-
promotion.codes.build(value: code)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def codes
|
29
|
-
if num_codes > 1
|
30
|
-
generate_random_codes
|
31
|
-
else
|
32
|
-
[base_code]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def generate_random_codes
|
37
|
-
valid_codes = Set.new
|
38
|
-
|
39
|
-
while valid_codes.size < num_codes
|
40
|
-
new_codes = Array.new(num_codes) { generate_random_code }.to_set
|
41
|
-
valid_codes += get_unique_codes(new_codes)
|
42
|
-
end
|
43
|
-
|
44
|
-
valid_codes.to_a.take(num_codes)
|
45
|
-
end
|
46
|
-
|
47
|
-
def generate_random_code
|
48
|
-
suffix = Array.new(self.class.random_code_length) do
|
49
|
-
sample_characters.sample
|
50
|
-
end.join
|
51
|
-
|
52
|
-
"#{@base_code}_#{suffix}"
|
53
|
-
end
|
54
|
-
|
55
|
-
def sample_characters
|
56
|
-
@sample_characters ||= ('a'..'z').to_a
|
57
|
-
end
|
58
|
-
|
59
|
-
def get_unique_codes(code_set)
|
60
|
-
code_set - Spree::PromotionCode.where(value: code_set.to_a).pluck(:value)
|
61
|
-
end
|
62
|
-
end
|