spree_core 3.1.5 → 3.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/spree/ransackable_attributes.rb +6 -1
- data/app/models/concerns/spree/user_methods.rb +10 -0
- data/app/models/spree/legacy_user.rb +0 -8
- data/app/models/spree/order.rb +1 -1
- data/app/models/spree/product.rb +8 -0
- data/app/models/spree/product/scopes.rb +7 -3
- data/app/models/spree/stock_transfer.rb +1 -1
- data/config/locales/en.yml +2 -0
- data/lib/spree/core/version.rb +1 -1
- data/spree_core.gemspec +2 -2
- metadata +11 -208
- data/spec/fixtures/microdata.html +0 -22
- data/spec/fixtures/microdata_itemref.html +0 -15
- data/spec/fixtures/microdata_no_itemscope.html +0 -20
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/helpers/base_helper_spec.rb +0 -200
- data/spec/helpers/products_helper_spec.rb +0 -296
- data/spec/lib/calculated_adjustments_spec.rb +0 -7
- data/spec/lib/i18n_spec.rb +0 -123
- data/spec/lib/search/base_spec.rb +0 -86
- data/spec/lib/spree/core/controller_helpers/auth_spec.rb +0 -103
- data/spec/lib/spree/core/controller_helpers/order_spec.rb +0 -110
- data/spec/lib/spree/core/controller_helpers/search_spec.rb +0 -17
- data/spec/lib/spree/core/controller_helpers/store_spec.rb +0 -72
- data/spec/lib/spree/core/controller_helpers/strong_parameters_spec.rb +0 -39
- data/spec/lib/spree/core/delegate_belongs_to_spec.rb +0 -22
- data/spec/lib/spree/core/importer/order_spec.rb +0 -605
- data/spec/lib/spree/core/number_generator_spec.rb +0 -175
- data/spec/lib/spree/core/token_generator_spec.rb +0 -24
- data/spec/lib/spree/core/validators/email_spec.rb +0 -53
- data/spec/lib/spree/core_spec.rb +0 -23
- data/spec/lib/spree/localized_number_spec.rb +0 -48
- data/spec/lib/spree/migrations_spec.rb +0 -36
- data/spec/lib/spree/money_spec.rb +0 -122
- data/spec/lib/tasks/exchanges_spec.rb +0 -136
- data/spec/mailers/order_mailer_spec.rb +0 -122
- data/spec/mailers/reimbursement_mailer_spec.rb +0 -47
- data/spec/mailers/shipment_mailer_spec.rb +0 -81
- data/spec/mailers/test_mailer_spec.rb +0 -38
- data/spec/models/option_type_prototype_spec.rb +0 -9
- data/spec/models/spree/ability_spec.rb +0 -251
- data/spec/models/spree/address_spec.rb +0 -291
- data/spec/models/spree/adjustable/adjuster/base_spec.rb +0 -10
- data/spec/models/spree/adjustable/adjuster/promotion_spec.rb +0 -211
- data/spec/models/spree/adjustable/adjuster/tax_spec.rb +0 -86
- data/spec/models/spree/adjustable/adjustments_updater_spec.rb +0 -26
- data/spec/models/spree/adjustment_spec.rb +0 -189
- data/spec/models/spree/app_configuration_spec.rb +0 -26
- data/spec/models/spree/asset_spec.rb +0 -28
- data/spec/models/spree/calculator/default_tax_spec.rb +0 -152
- data/spec/models/spree/calculator/flat_percent_item_total_spec.rb +0 -25
- data/spec/models/spree/calculator/flat_rate_spec.rb +0 -47
- data/spec/models/spree/calculator/flexi_rate_spec.rb +0 -41
- data/spec/models/spree/calculator/percent_on_line_item_spec.rb +0 -15
- data/spec/models/spree/calculator/price_sack_spec.rb +0 -30
- data/spec/models/spree/calculator/refunds/default_refund_amount_spec.rb +0 -51
- data/spec/models/spree/calculator/shipping.rb +0 -8
- data/spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb +0 -23
- data/spec/models/spree/calculator/shipping/flat_rate_spec.rb +0 -13
- data/spec/models/spree/calculator/shipping/flexi_rate_spec.rb +0 -52
- data/spec/models/spree/calculator/shipping/per_item_spec.rb +0 -20
- data/spec/models/spree/calculator/shipping/price_sack_spec.rb +0 -29
- data/spec/models/spree/calculator/tiered_flat_rate_spec.rb +0 -40
- data/spec/models/spree/calculator/tiered_percent_spec.rb +0 -51
- data/spec/models/spree/calculator_spec.rb +0 -69
- data/spec/models/spree/classification_spec.rb +0 -93
- data/spec/models/spree/concerns/display_money_spec.rb +0 -43
- data/spec/models/spree/concerns/user_methods_spec.rb +0 -55
- data/spec/models/spree/concerns/vat_price_calculation_spec.rb +0 -66
- data/spec/models/spree/country_spec.rb +0 -55
- data/spec/models/spree/credit_card_spec.rb +0 -328
- data/spec/models/spree/customer_return_spec.rb +0 -240
- data/spec/models/spree/exchange_spec.rb +0 -75
- data/spec/models/spree/gateway/bogus_simple.rb +0 -20
- data/spec/models/spree/gateway/bogus_spec.rb +0 -13
- data/spec/models/spree/gateway_spec.rb +0 -61
- data/spec/models/spree/image_spec.rb +0 -8
- data/spec/models/spree/inventory_unit_spec.rb +0 -225
- data/spec/models/spree/line_item_spec.rb +0 -327
- data/spec/models/spree/option_type_spec.rb +0 -14
- data/spec/models/spree/option_value_spec.rb +0 -18
- data/spec/models/spree/order/address_spec.rb +0 -50
- data/spec/models/spree/order/adjustments_spec.rb +0 -29
- data/spec/models/spree/order/callbacks_spec.rb +0 -42
- data/spec/models/spree/order/checkout_spec.rb +0 -782
- data/spec/models/spree/order/currency_updater_spec.rb +0 -32
- data/spec/models/spree/order/finalizing_spec.rb +0 -114
- data/spec/models/spree/order/helpers_spec.rb +0 -5
- data/spec/models/spree/order/payment_spec.rb +0 -214
- data/spec/models/spree/order/risk_assessment_spec.rb +0 -84
- data/spec/models/spree/order/shipments_spec.rb +0 -43
- data/spec/models/spree/order/state_machine_spec.rb +0 -211
- data/spec/models/spree/order/store_credit_spec.rb +0 -426
- data/spec/models/spree/order/tax_spec.rb +0 -84
- data/spec/models/spree/order/totals_spec.rb +0 -24
- data/spec/models/spree/order/updating_spec.rb +0 -18
- data/spec/models/spree/order/validations_spec.rb +0 -15
- data/spec/models/spree/order_contents_spec.rb +0 -297
- data/spec/models/spree/order_inventory_spec.rb +0 -238
- data/spec/models/spree/order_merger_spec.rb +0 -135
- data/spec/models/spree/order_spec.rb +0 -967
- data/spec/models/spree/order_updater_spec.rb +0 -305
- data/spec/models/spree/payment/gateway_options_spec.rb +0 -127
- data/spec/models/spree/payment/store_credit_spec.rb +0 -60
- data/spec/models/spree/payment_method/store_credit_spec.rb +0 -291
- data/spec/models/spree/payment_method_spec.rb +0 -103
- data/spec/models/spree/payment_spec.rb +0 -919
- data/spec/models/spree/preference_spec.rb +0 -80
- data/spec/models/spree/preferences/configuration_spec.rb +0 -30
- data/spec/models/spree/preferences/preferable_spec.rb +0 -348
- data/spec/models/spree/preferences/scoped_store_spec.rb +0 -58
- data/spec/models/spree/preferences/store_spec.rb +0 -46
- data/spec/models/spree/price_spec.rb +0 -128
- data/spec/models/spree/product/scopes_spec.rb +0 -183
- data/spec/models/spree/product_duplicator_spec.rb +0 -103
- data/spec/models/spree/product_filter_spec.rb +0 -26
- data/spec/models/spree/product_option_type_spec.rb +0 -9
- data/spec/models/spree/product_promotion_rule_spec.rb +0 -9
- data/spec/models/spree/product_property_spec.rb +0 -22
- data/spec/models/spree/product_spec.rb +0 -540
- data/spec/models/spree/promotion/actions/create_adjustment_spec.rb +0 -50
- data/spec/models/spree/promotion/actions/create_item_adjustments_spec.rb +0 -148
- data/spec/models/spree/promotion/actions/create_line_items_spec.rb +0 -86
- data/spec/models/spree/promotion/actions/free_shipping_spec.rb +0 -36
- data/spec/models/spree/promotion/rules/first_order_spec.rb +0 -75
- data/spec/models/spree/promotion/rules/item_total_spec.rb +0 -282
- data/spec/models/spree/promotion/rules/one_use_per_user_spec.rb +0 -42
- data/spec/models/spree/promotion/rules/option_value_spec.rb +0 -90
- data/spec/models/spree/promotion/rules/product_spec.rb +0 -143
- data/spec/models/spree/promotion/rules/taxon_spec.rb +0 -102
- data/spec/models/spree/promotion/rules/user_logged_in_spec.rb +0 -27
- data/spec/models/spree/promotion/rules/user_spec.rb +0 -45
- data/spec/models/spree/promotion_action_spec.rb +0 -10
- data/spec/models/spree/promotion_category_spec.rb +0 -17
- data/spec/models/spree/promotion_handler/cart_spec.rb +0 -102
- data/spec/models/spree/promotion_handler/coupon_spec.rb +0 -323
- data/spec/models/spree/promotion_handler/free_shipping_spec.rb +0 -48
- data/spec/models/spree/promotion_handler/page_spec.rb +0 -44
- data/spec/models/spree/promotion_rule_spec.rb +0 -29
- data/spec/models/spree/promotion_rule_taxon_spec.rb +0 -9
- data/spec/models/spree/promotion_rule_user_spec.rb +0 -9
- data/spec/models/spree/promotion_spec.rb +0 -644
- data/spec/models/spree/property_prototype_spec.rb +0 -9
- data/spec/models/spree/property_spec.rb +0 -5
- data/spec/models/spree/prototype_spec.rb +0 -5
- data/spec/models/spree/prototype_taxon_spec.rb +0 -9
- data/spec/models/spree/refund_reason_spec.rb +0 -7
- data/spec/models/spree/refund_spec.rb +0 -195
- data/spec/models/spree/reimbursement/credit_spec.rb +0 -36
- data/spec/models/spree/reimbursement/reimbursement_type_engine_spec.rb +0 -140
- data/spec/models/spree/reimbursement/reimbursement_type_validator_spec.rb +0 -83
- data/spec/models/spree/reimbursement_performer_spec.rb +0 -30
- data/spec/models/spree/reimbursement_spec.rb +0 -188
- data/spec/models/spree/reimbursement_tax_calculator_spec.rb +0 -63
- data/spec/models/spree/reimbursement_type/credit_spec.rb +0 -53
- data/spec/models/spree/reimbursement_type/exchange_spec.rb +0 -46
- data/spec/models/spree/reimbursement_type/original_payment_spec.rb +0 -55
- data/spec/models/spree/reimbursement_type/store_credit_spec.rb +0 -101
- data/spec/models/spree/return_authorization_reason_spec.rb +0 -7
- data/spec/models/spree/return_authorization_spec.rb +0 -230
- data/spec/models/spree/return_item/eligibility_validator/default_spec.rb +0 -77
- data/spec/models/spree/return_item/eligibility_validator/inventory_shipped_spec.rb +0 -58
- data/spec/models/spree/return_item/eligibility_validator/no_reimbursements_spec.rb +0 -61
- data/spec/models/spree/return_item/eligibility_validator/order_completed_spec.rb +0 -32
- data/spec/models/spree/return_item/eligibility_validator/rma_required_spec.rb +0 -29
- data/spec/models/spree/return_item/eligibility_validator/time_since_purchase_spec.rb +0 -35
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_option_value_spec.rb +0 -65
- data/spec/models/spree/return_item/exchange_variant_eligibility/same_product_spec.rb +0 -43
- data/spec/models/spree/return_item_spec.rb +0 -731
- data/spec/models/spree/returns_calculator_spec.rb +0 -14
- data/spec/models/spree/role_spec.rb +0 -7
- data/spec/models/spree/shipment_spec.rb +0 -740
- data/spec/models/spree/shipping_calculator_spec.rb +0 -45
- data/spec/models/spree/shipping_category_spec.rb +0 -19
- data/spec/models/spree/shipping_method_spec.rb +0 -95
- data/spec/models/spree/shipping_rate_spec.rb +0 -140
- data/spec/models/spree/state_spec.rb +0 -29
- data/spec/models/spree/stock/availability_validator_spec.rb +0 -36
- data/spec/models/spree/stock/content_item_spec.rb +0 -31
- data/spec/models/spree/stock/coordinator_spec.rb +0 -51
- data/spec/models/spree/stock/differentiator_spec.rb +0 -39
- data/spec/models/spree/stock/estimator_spec.rb +0 -202
- data/spec/models/spree/stock/inventory_unit_builder_spec.rb +0 -38
- data/spec/models/spree/stock/package_spec.rb +0 -194
- data/spec/models/spree/stock/packer_spec.rb +0 -70
- data/spec/models/spree/stock/prioritizer_spec.rb +0 -125
- data/spec/models/spree/stock/quantifier_spec.rb +0 -126
- data/spec/models/spree/stock/splitter/backordered_spec.rb +0 -29
- data/spec/models/spree/stock/splitter/base_spec.rb +0 -21
- data/spec/models/spree/stock/splitter/shipping_category_spec.rb +0 -47
- data/spec/models/spree/stock/splitter/weight_spec.rb +0 -32
- data/spec/models/spree/stock_item_spec.rb +0 -428
- data/spec/models/spree/stock_location_spec.rb +0 -243
- data/spec/models/spree/stock_movement_spec.rb +0 -56
- data/spec/models/spree/stock_transfer_spec.rb +0 -50
- data/spec/models/spree/store_credit_event_spec.rb +0 -101
- data/spec/models/spree/store_credit_spec.rb +0 -786
- data/spec/models/spree/store_spec.rb +0 -78
- data/spec/models/spree/tax_category_spec.rb +0 -32
- data/spec/models/spree/tax_rate_spec.rb +0 -542
- data/spec/models/spree/taxon_spec.rb +0 -74
- data/spec/models/spree/taxonomy_spec.rb +0 -18
- data/spec/models/spree/tracker_spec.rb +0 -21
- data/spec/models/spree/user_spec.rb +0 -203
- data/spec/models/spree/variant_spec.rb +0 -795
- data/spec/models/spree/zone_member_spec.rb +0 -38
- data/spec/models/spree/zone_spec.rb +0 -470
- data/spec/spec_helper.rb +0 -77
- data/spec/support/big_decimal.rb +0 -5
- data/spec/support/concerns/adjustment_source.rb +0 -23
- data/spec/support/concerns/default_price.rb +0 -37
- data/spec/support/rake.rb +0 -13
- data/spec/support/test_gateway.rb +0 -2
- data/spec/validators/db_maximum_length_validator_spec.rb +0 -22
@@ -1,175 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Core::NumberGenerator do
|
4
|
-
let(:number_generator) { described_class.new(options) }
|
5
|
-
let(:random) { instance_double(Random) }
|
6
|
-
|
7
|
-
let(:model) do
|
8
|
-
mod = number_generator
|
9
|
-
|
10
|
-
Class.new(ActiveRecord::Base) do
|
11
|
-
self.table_name = 'spree_orders'
|
12
|
-
include mod
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
before do
|
17
|
-
expect(Random).to receive(:new).and_return(random)
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:options) { { prefix: 'R' } }
|
21
|
-
|
22
|
-
%i[prefix length].each do |name|
|
23
|
-
describe "##{name}" do
|
24
|
-
let(:value) { double('Generic Value') }
|
25
|
-
|
26
|
-
it 'returns attribute value from options' do
|
27
|
-
expect(described_class.new(options.merge(name => value)).public_send(name)).to be(value)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "##{name}=" do
|
32
|
-
let(:value_a) { double('Generic Value A') }
|
33
|
-
let(:value_b) { double('Generic Value B') }
|
34
|
-
|
35
|
-
it 'writes attribute value' do
|
36
|
-
object = described_class.new(options.merge(name => value_a))
|
37
|
-
expect { object.public_send(:"#{name}=", value_b) }
|
38
|
-
.to change { object.public_send(name) }
|
39
|
-
.from(value_a)
|
40
|
-
.to(value_b)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
shared_examples_for 'duplicate without length increment' do
|
46
|
-
before do
|
47
|
-
expect(random).to receive(:rand).
|
48
|
-
with(expected_rand_limit).
|
49
|
-
and_return(next_candidate_index).
|
50
|
-
exactly(expected_length).times
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'sets permalink field' do
|
54
|
-
expect { subject }.to change(resource, :number).from(nil).to(next_candidate)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
shared_examples_for 'generating permalink'do
|
59
|
-
let(:resource) { model.new }
|
60
|
-
|
61
|
-
before do
|
62
|
-
expect(random).to receive(:rand).
|
63
|
-
with(expected_rand_limit).
|
64
|
-
and_return(first_candidate_index).
|
65
|
-
exactly(expected_length).times
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'and generated candidate is unique' do
|
69
|
-
before do
|
70
|
-
expect(model).to receive(:exists?).with(number: first_candidate).and_return(false)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'sets permalink field' do
|
74
|
-
expect { subject }.to change(resource, :number).from(nil).to(first_candidate)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context 'and generated candidate is NOT unique' do
|
79
|
-
before do
|
80
|
-
expect(model).to receive(:exists?).with(number: first_candidate).and_return(true).ordered
|
81
|
-
expect(model).to receive(:count).and_return(record_count).ordered
|
82
|
-
expect(model).to receive(:exists?).with(number: next_candidate).and_return(false)
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'and less than half of the value space taken' do
|
86
|
-
let(:next_candidate) { next_candidate_low }
|
87
|
-
let(:record_count) { 10 ** expected_length / 2 - 1 }
|
88
|
-
|
89
|
-
include_examples 'duplicate without length increment'
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'and exactly half of the value space taken' do
|
93
|
-
let(:next_candidate) { next_candidate_low }
|
94
|
-
let(:record_count) { 10 ** expected_length / 2 }
|
95
|
-
|
96
|
-
include_examples 'duplicate without length increment'
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'and more than half of the value space is taken' do
|
100
|
-
let(:record_count) { 10 ** expected_length / 2 + 1 }
|
101
|
-
let(:next_candidate) { next_candidate_high }
|
102
|
-
|
103
|
-
before do
|
104
|
-
expect(random).to receive(:rand).
|
105
|
-
with(expected_rand_limit).
|
106
|
-
and_return(next_candidate_index).
|
107
|
-
exactly(expected_length.succ).times
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'sets permalink field' do
|
111
|
-
expect { subject }.to change(resource, :number).from(nil).to(next_candidate)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '#included' do
|
118
|
-
context 'generates .number_generator on host' do
|
119
|
-
it 'returns number generator' do
|
120
|
-
expect(model.number_generator).to be(number_generator)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context 'generates validation hooks on host' do
|
125
|
-
subject { resource.valid? }
|
126
|
-
|
127
|
-
let(:first_candidate_index) { 0 }
|
128
|
-
let(:next_candidate_index) { 1 }
|
129
|
-
let(:expected_rand_limit) { 10 }
|
130
|
-
let(:expected_length) { 9 }
|
131
|
-
|
132
|
-
context 'when permalink field value is nil' do
|
133
|
-
context 'on defaults' do
|
134
|
-
let(:first_candidate) { 'R000000000' }
|
135
|
-
let(:next_candidate_low) { 'R111111111' }
|
136
|
-
let(:next_candidate_high) { 'R1111111111' }
|
137
|
-
|
138
|
-
include_examples 'generating permalink'
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'with length: option' do
|
142
|
-
let(:options) { super().merge(length: 10) }
|
143
|
-
let(:expected_length) { 10 }
|
144
|
-
|
145
|
-
let(:first_candidate) { 'R0000000000' }
|
146
|
-
let(:next_candidate_low) { 'R1111111111' }
|
147
|
-
let(:next_candidate_high) { 'R11111111111' }
|
148
|
-
|
149
|
-
include_examples 'generating permalink'
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'with letters option' do
|
153
|
-
let(:options) { super().merge(letters: true) }
|
154
|
-
let(:expected_rand_limit) { 36 }
|
155
|
-
|
156
|
-
let(:first_candidate) { 'RAAAAAAAAA' }
|
157
|
-
let(:first_candidate_index) { 10 }
|
158
|
-
let(:next_candidate_index) { 11 }
|
159
|
-
let(:next_candidate_low) { 'RBBBBBBBBB' }
|
160
|
-
let(:next_candidate_high) { 'RBBBBBBBBBB' }
|
161
|
-
|
162
|
-
include_examples 'generating permalink'
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context 'when permalink field value is present' do
|
167
|
-
let(:resource) { model.new(number: 'Test') }
|
168
|
-
|
169
|
-
it 'does not touch field' do
|
170
|
-
expect { subject }.not_to change(resource, :number)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Core::TokenGenerator do
|
4
|
-
class DummyClass
|
5
|
-
include Spree::Core::TokenGenerator
|
6
|
-
|
7
|
-
attr_reader :created_at
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@created_at = Time.now.to_i
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:dummy_class_instance) { DummyClass.new }
|
15
|
-
|
16
|
-
describe 'generate_guest_token' do
|
17
|
-
let(:generated_token) { dummy_class_instance.generate_guest_token }
|
18
|
-
|
19
|
-
it 'generates random token with timestamp' do
|
20
|
-
expect(generated_token.size).to eq 35
|
21
|
-
expect(generated_token).to include dummy_class_instance.created_at.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EmailValidator do
|
4
|
-
|
5
|
-
class Tester
|
6
|
-
include ActiveModel::Validations
|
7
|
-
attr_accessor :email_address
|
8
|
-
validates :email_address, email: true
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:valid_emails) {[
|
12
|
-
'valid@email.com',
|
13
|
-
'valid@email.com.uk',
|
14
|
-
'e@email.com',
|
15
|
-
'valid+email@email.com',
|
16
|
-
'valid-email@email.com',
|
17
|
-
'valid_email@email.com',
|
18
|
-
'validemail_@email.com',
|
19
|
-
'valid.email@email.com'
|
20
|
-
]}
|
21
|
-
let(:invalid_emails) {[
|
22
|
-
'',
|
23
|
-
' ',
|
24
|
-
'invalid email@email.com',
|
25
|
-
'invalidemail @email.com',
|
26
|
-
'invalidemail@email..com',
|
27
|
-
'.invalid.email@email.com',
|
28
|
-
'invalid.email.@email.com',
|
29
|
-
'@email.com',
|
30
|
-
'.@email.com',
|
31
|
-
'invalidemailemail.com',
|
32
|
-
'@invalid.email@email.com',
|
33
|
-
'invalid@email@email.com',
|
34
|
-
'invalid.email@@email.com'
|
35
|
-
]}
|
36
|
-
|
37
|
-
it 'validates valid email addresses' do
|
38
|
-
tester = Tester.new
|
39
|
-
valid_emails.each do |email|
|
40
|
-
tester.email_address = email
|
41
|
-
expect(tester.valid?).to be true
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'validates invalid email addresses' do
|
46
|
-
tester = Tester.new
|
47
|
-
invalid_emails.each do |email|
|
48
|
-
tester.email_address = email
|
49
|
-
expect(tester.valid?).to be false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
data/spec/lib/spree/core_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree do
|
4
|
-
describe '.admin_path' do
|
5
|
-
it { expect(Spree.admin_path).to eq(Spree::Config[:admin_path]) }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '.admin_path=' do
|
9
|
-
let!(:original_admin_path) { Spree.admin_path }
|
10
|
-
let(:new_admin_path) { '/admin-secret-path' }
|
11
|
-
|
12
|
-
before do
|
13
|
-
Spree.admin_path = new_admin_path
|
14
|
-
end
|
15
|
-
|
16
|
-
it { expect(Spree.admin_path).to eq(new_admin_path) }
|
17
|
-
it { expect(Spree::Config[:admin_path]).to eq(new_admin_path) }
|
18
|
-
|
19
|
-
after do
|
20
|
-
Spree.admin_path = original_admin_path
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::LocalizedNumber do
|
4
|
-
|
5
|
-
context ".parse" do
|
6
|
-
before do
|
7
|
-
I18n.enforce_available_locales = false
|
8
|
-
I18n.locale = I18n.default_locale
|
9
|
-
I18n.backend.store_translations(:de, { :number => { :currency => { :format => { :delimiter => '.', :separator => ',' } } } })
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
I18n.locale = I18n.default_locale
|
14
|
-
I18n.enforce_available_locales = true
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with decimal point" do
|
18
|
-
it "captures the proper amount for a formatted price" do
|
19
|
-
expect(subject.class.parse('1,599.99')).to eql 1599.99
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "with decimal comma" do
|
24
|
-
it "captures the proper amount for a formatted price" do
|
25
|
-
I18n.locale = :de
|
26
|
-
expect(subject.class.parse('1.599,99')).to eql 1599.99
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "with a numeric price" do
|
31
|
-
it "uses the price as is" do
|
32
|
-
I18n.locale = :de
|
33
|
-
expect(subject.class.parse(1599.99)).to eql 1599.99
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "string argument" do
|
38
|
-
it "should not be modified" do
|
39
|
-
I18n.locale = :de
|
40
|
-
number = '1.599,99'
|
41
|
-
number_bak = number.dup
|
42
|
-
subject.class.parse(number)
|
43
|
-
expect(number).to eql(number_bak)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
describe Migrations do
|
5
|
-
let(:app_migrations) { [".", "34_add_title.rb", "52_add_text.rb"] }
|
6
|
-
let(:engine_migrations) { [".", "334_create_orders.spree.rb", "777_create_products.spree.rb"] }
|
7
|
-
|
8
|
-
let(:config) { double("Config", root: "dir") }
|
9
|
-
|
10
|
-
let(:engine_dir) { "dir/db/migrate" }
|
11
|
-
let(:app_dir) { "#{Rails.root}/db/migrate" }
|
12
|
-
|
13
|
-
subject { described_class.new(config, "spree") }
|
14
|
-
|
15
|
-
before do
|
16
|
-
expect(File).to receive(:directory?).with(app_dir).and_return true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "warns about missing migrations" do
|
20
|
-
expect(Dir).to receive(:entries).with(app_dir).and_return app_migrations
|
21
|
-
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations
|
22
|
-
|
23
|
-
silence_stream(STDOUT) {
|
24
|
-
expect(subject.check).to eq true
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
context "no missing migrations" do
|
29
|
-
it "says nothing" do
|
30
|
-
expect(Dir).to receive(:entries).with(engine_dir).and_return engine_migrations
|
31
|
-
expect(Dir).to receive(:entries).with(app_dir).and_return(app_migrations + engine_migrations)
|
32
|
-
expect(subject.check).to eq nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Spree::Money do
|
5
|
-
before do
|
6
|
-
configure_spree_preferences do |config|
|
7
|
-
config.currency = "USD"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "formats correctly" do
|
12
|
-
money = Spree::Money.new(10)
|
13
|
-
expect(money.to_s).to eq("$10.00")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "can get cents" do
|
17
|
-
money = Spree::Money.new(10)
|
18
|
-
expect(money.cents).to eq(1000)
|
19
|
-
end
|
20
|
-
|
21
|
-
context "with currency" do
|
22
|
-
it "passed in option" do
|
23
|
-
money = Spree::Money.new(10, :with_currency => true, :html => false)
|
24
|
-
expect(money.to_s).to eq("$10.00 USD")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "hide cents" do
|
29
|
-
it "hides cents suffix" do
|
30
|
-
money = Spree::Money.new(10, no_cents: true)
|
31
|
-
expect(money.to_s).to eq("$10")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "shows cents suffix" do
|
35
|
-
money = Spree::Money.new(10)
|
36
|
-
expect(money.to_s).to eq("$10.00")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "currency parameter" do
|
41
|
-
context "when currency is specified in Canadian Dollars" do
|
42
|
-
it "uses the currency param over the global configuration" do
|
43
|
-
money = Spree::Money.new(10, :currency => 'CAD', :with_currency => true, :html => false)
|
44
|
-
expect(money.to_s).to eq("$10.00 CAD")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when currency is specified in Japanese Yen" do
|
49
|
-
it "uses the currency param over the global configuration" do
|
50
|
-
money = Spree::Money.new(100, :currency => 'JPY', :html => false)
|
51
|
-
expect(money.to_s).to eq("¥100")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "symbol positioning" do
|
57
|
-
it "passed in option" do
|
58
|
-
money = Spree::Money.new(10, :symbol_position => :after, :html => false)
|
59
|
-
expect(money.to_s).to eq("10.00 $")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context "sign before symbol" do
|
64
|
-
it "defaults to -$10.00" do
|
65
|
-
money = Spree::Money.new(-10)
|
66
|
-
expect(money.to_s).to eq("-$10.00")
|
67
|
-
end
|
68
|
-
|
69
|
-
it "passed in option" do
|
70
|
-
money = Spree::Money.new(-10, :sign_before_symbol => false)
|
71
|
-
expect(money.to_s).to eq("$-10.00")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "JPY" do
|
76
|
-
before do
|
77
|
-
configure_spree_preferences do |config|
|
78
|
-
config.currency = "JPY"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "formats correctly" do
|
83
|
-
money = Spree::Money.new(1000, :html => false)
|
84
|
-
expect(money.to_s).to eq("¥1,000")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "EUR" do
|
89
|
-
before do
|
90
|
-
configure_spree_preferences do |config|
|
91
|
-
config.currency = "EUR"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# Regression test for #2634
|
96
|
-
it "formats as plain by default" do
|
97
|
-
money = Spree::Money.new(10, symbol_position: :after)
|
98
|
-
expect(money.to_s).to eq("10.00 €")
|
99
|
-
end
|
100
|
-
|
101
|
-
it "formats as HTML if asked (nicely) to" do
|
102
|
-
money = Spree::Money.new(10, symbol_position: :after)
|
103
|
-
# The HTML'ified version of "10.00 €"
|
104
|
-
expect(money.to_html).to eq("10.00 €")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "formats as HTML with currency" do
|
108
|
-
money = Spree::Money.new(10, symbol_position: :after, with_currency: true)
|
109
|
-
# The HTML'ified version of "10.00 €"
|
110
|
-
expect(money.to_html).to eq("10.00 € <span class=\"currency\">EUR</span>")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "#as_json" do
|
115
|
-
let(:options) { double('options') }
|
116
|
-
|
117
|
-
it "returns the expected string" do
|
118
|
-
money = Spree::Money.new(10)
|
119
|
-
expect(money.as_json(options)).to eq("$10.00")
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|