spree_core 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/spree/admin/images_helper.rb +1 -1
- data/app/helpers/spree/base_helper.rb +5 -2
- data/app/models/spree/address.rb +9 -1
- data/app/models/spree/adjustment.rb +2 -2
- data/app/models/spree/calculator/default_tax.rb +5 -1
- data/app/models/spree/credit_card.rb +2 -0
- data/app/models/spree/gateway.rb +1 -1
- data/app/models/spree/inventory_unit.rb +5 -4
- data/app/models/spree/legacy_user.rb +2 -11
- data/app/models/spree/line_item.rb +2 -3
- data/app/models/spree/log_entry.rb +4 -0
- data/app/models/spree/option_type.rb +6 -0
- data/app/models/spree/option_value.rb +12 -1
- data/app/models/spree/order.rb +34 -16
- data/app/models/spree/order/checkout.rb +4 -0
- data/app/models/spree/order_inventory.rb +1 -1
- data/app/models/spree/payment.rb +10 -2
- data/app/models/spree/payment/processing.rb +5 -4
- data/app/models/spree/payment_method.rb +2 -0
- data/app/models/spree/price.rb +5 -0
- data/app/models/spree/product.rb +6 -5
- data/app/models/spree/product/scopes.rb +12 -6
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion.rb +1 -8
- data/app/models/spree/promotion/rules/user_logged_in.rb +1 -3
- data/app/models/spree/property.rb +8 -0
- data/app/models/spree/shipment.rb +9 -14
- data/app/models/spree/shipping_method.rb +3 -2
- data/app/models/spree/shipping_rate.rb +7 -9
- data/app/models/spree/stock/estimator.rb +21 -14
- data/app/models/spree/stock/package.rb +1 -1
- data/app/models/spree/stock/packer.rb +1 -1
- data/app/models/spree/stock/quantifier.rb +11 -2
- data/app/models/spree/stock_item.rb +2 -2
- data/app/models/spree/stock_location.rb +8 -0
- data/app/models/spree/stock_movement.rb +3 -1
- data/app/models/spree/taxon.rb +2 -2
- data/app/models/spree/variant.rb +19 -4
- data/app/models/spree/zone.rb +1 -1
- data/app/views/spree/shared/_routes.html.erb +1 -1
- data/config/locales/en.yml +15 -1
- data/db/default/spree/countries.rb +7 -7
- data/db/migrate/20130417120034_add_index_to_source_columns_on_adjustments.rb +5 -0
- data/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +5 -2
- data/db/migrate/20131026154747_add_track_inventory_to_variant.rb +5 -0
- data/db/migrate/20131120234456_add_updated_at_to_variants.rb +5 -0
- data/db/migrate/20131211192741_unique_shipping_method_categories.rb +24 -0
- data/db/migrate/20140120160805_add_index_to_variant_id_and_currency_on_prices.rb +5 -0
- data/lib/generators/spree/dummy/dummy_generator.rb +14 -3
- data/lib/generators/spree/dummy/templates/rails/database.yml +10 -0
- data/lib/spree/core.rb +3 -0
- data/lib/spree/core/controller_helpers/order.rb +4 -1
- data/lib/spree/core/controller_helpers/ssl.rb +5 -7
- data/lib/spree/core/controller_helpers/strong_parameters.rb +6 -0
- data/lib/spree/core/delegate_belongs_to.rb +16 -10
- data/lib/spree/core/engine.rb +11 -2
- data/lib/spree/core/mail_method.rb +27 -0
- data/lib/spree/core/mail_settings.rb +33 -38
- data/lib/spree/core/permalinks.rb +5 -1
- data/lib/spree/core/s3_support.rb +1 -1
- data/lib/spree/core/user_address.rb +30 -0
- data/lib/spree/core/validators/email.rb +9 -3
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/i18n.rb +1 -0
- data/lib/spree/migrations.rb +55 -0
- data/lib/spree/money.rb +171 -1
- data/lib/spree/permitted_attributes.rb +6 -6
- data/lib/spree/testing_support/capybara_ext.rb +6 -5
- data/lib/spree/testing_support/controller_requests.rb +20 -4
- data/lib/spree/testing_support/factories/product_factory.rb +4 -0
- data/lib/spree/testing_support/factories/variant_factory.rb +15 -0
- metadata +158 -164
data/app/models/spree/zone.rb
CHANGED
@@ -128,7 +128,7 @@ module Spree
|
|
128
128
|
|
129
129
|
def remove_defunct_members
|
130
130
|
if zone_members.any?
|
131
|
-
zone_members.where('zoneable_id IS NULL OR zoneable_type != ?', "Spree::#{kind.
|
131
|
+
zone_members.where('zoneable_id IS NULL OR zoneable_type != ?', "Spree::#{kind.classify}").destroy_all
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
data/config/locales/en.yml
CHANGED
@@ -357,12 +357,15 @@ en:
|
|
357
357
|
attachment_url: Attachments URL
|
358
358
|
authorization_failure: Authorization Failure
|
359
359
|
available_on: Available On
|
360
|
+
avs_response: AVS Response
|
360
361
|
back: Back
|
361
362
|
back_end: Backend
|
363
|
+
backordered: Backordered
|
362
364
|
back_to_adjustments_list: Back To Adjustments List
|
363
365
|
back_to_images_list: Back To Images List
|
364
366
|
back_to_option_types_list: Back To Option Types List
|
365
367
|
back_to_orders_list: Back To Orders List
|
368
|
+
back_to_payment: Back To Payment
|
366
369
|
back_to_payment_methods_list: Back To Payment Methods List
|
367
370
|
back_to_payments_list: Back To Payments List
|
368
371
|
back_to_products_list: Back To Products List
|
@@ -466,6 +469,7 @@ en:
|
|
466
469
|
customer_details_updated: Customer Details Updated
|
467
470
|
customer_search: Customer Search
|
468
471
|
cut: Cut
|
472
|
+
cvv_response: CVV Response
|
469
473
|
dash:
|
470
474
|
jirafe:
|
471
475
|
app_id: App ID
|
@@ -550,6 +554,7 @@ en:
|
|
550
554
|
count_on_hand_setter: Cannot set count_on_hand manually, as it is set automatically by the recalculate_count_on_hand callback. Please use `update_column(:count_on_hand, value)` instead.
|
551
555
|
expiration: Expiration
|
552
556
|
extension: Extension
|
557
|
+
failed_payment_attempts: Failed Payment Attempts
|
553
558
|
filename: Filename
|
554
559
|
fill_in_customer_info: Please fill in customer info
|
555
560
|
filter_results: Filter Results
|
@@ -635,6 +640,8 @@ en:
|
|
635
640
|
locale_changed: Locale Changed
|
636
641
|
location: Location
|
637
642
|
lock: Lock
|
643
|
+
log_entries: "Log Entries"
|
644
|
+
logs: "Logs"
|
638
645
|
logged_in_as: Logged in as
|
639
646
|
logged_in_succesfully: Logged in successfully
|
640
647
|
logged_out: You have been logged out.
|
@@ -762,7 +769,7 @@ en:
|
|
762
769
|
thanks: Thank you for your business.
|
763
770
|
total: ! 'Order Total: %{total}'
|
764
771
|
order_not_found: We couldn't find your order. Please try that action again.
|
765
|
-
order_number: Order
|
772
|
+
order_number: Order %{number}
|
766
773
|
order_populator:
|
767
774
|
out_of_stock: ! '%{item} is out of stock.'
|
768
775
|
selected_quantity_not_available: ! 'Selected quantity of %{item} is not available.'
|
@@ -917,6 +924,8 @@ en:
|
|
917
924
|
return_quantity: Return Quantity
|
918
925
|
returned: Returned
|
919
926
|
review: Review
|
927
|
+
risk: Risk
|
928
|
+
risk_analysis: Risk Analysis
|
920
929
|
rma_credit: RMA Credit
|
921
930
|
rma_number: RMA Number
|
922
931
|
rma_value: RMA Value
|
@@ -931,6 +940,7 @@ en:
|
|
931
940
|
sales_total_description: Sales Total For All Orders
|
932
941
|
sales_totals: Sales Totals
|
933
942
|
save_and_continue: Save and Continue
|
943
|
+
save_my_address: Save my address
|
934
944
|
say_no: 'No'
|
935
945
|
say_yes: 'Yes'
|
936
946
|
scope: Scope
|
@@ -964,6 +974,7 @@ en:
|
|
964
974
|
shipment_state: Shipment State
|
965
975
|
shipment_states:
|
966
976
|
backorder: backorder
|
977
|
+
canceled: canceled
|
967
978
|
partial: partial
|
968
979
|
pending: pending
|
969
980
|
ready: ready
|
@@ -1028,6 +1039,7 @@ en:
|
|
1028
1039
|
street_address_2: Street Address (cont'd)
|
1029
1040
|
subtotal: Subtotal
|
1030
1041
|
subtract: Subtract
|
1042
|
+
success: Success
|
1031
1043
|
successfully_created: ! '%{resource} has been successfully created!'
|
1032
1044
|
successfully_removed: ! '%{resource} has been successfully removed!'
|
1033
1045
|
successfully_signed_up_for_analytics: Successfully signed up for Spree Analytics
|
@@ -1062,6 +1074,8 @@ en:
|
|
1062
1074
|
time: Time
|
1063
1075
|
to_add_variants_you_must_first_define: To add variants, you must first define
|
1064
1076
|
total: Total
|
1077
|
+
total_price: Total price
|
1078
|
+
track_inventory: Track Inventory
|
1065
1079
|
tracking: Tracking
|
1066
1080
|
tracking_number: Tracking Number
|
1067
1081
|
tracking_url: Tracking URL
|
@@ -27,7 +27,7 @@ Spree::Country.create!([
|
|
27
27
|
{ name: "Jamaica", iso3: "JAM", iso: "JM", iso_name: "JAMAICA", numcode: "388" },
|
28
28
|
{ name: "Japan", iso3: "JPN", iso: "JP", iso_name: "JAPAN", numcode: "392" },
|
29
29
|
{ name: "Jordan", iso3: "JOR", iso: "JO", iso_name: "JORDAN", numcode: "400" },
|
30
|
-
{ name: "Belgium", iso3: "BEL", iso: "BE", iso_name: "BELGIUM", numcode: "56"
|
30
|
+
{ name: "Belgium", iso3: "BEL", iso: "BE", iso_name: "BELGIUM", numcode: "56" },
|
31
31
|
{ name: "Belize", iso3: "BLZ", iso: "BZ", iso_name: "BELIZE", numcode: "84" },
|
32
32
|
{ name: "Kazakhstan", iso3: "KAZ", iso: "KZ", iso_name: "KAZAKHSTAN", numcode: "398" },
|
33
33
|
{ name: "Uganda", iso3: "UGA", iso: "UG", iso_name: "UGANDA", numcode: "800" },
|
@@ -48,7 +48,7 @@ Spree::Country.create!([
|
|
48
48
|
{ name: "South Korea", iso3: "KOR", iso: "KR", iso_name: "KOREA, REPUBLIC OF", numcode: "410" },
|
49
49
|
{ name: "Moldova, Republic of", iso3: "MDA", iso: "MD", iso_name: "MOLDOVA, REPUBLIC OF", numcode: "498" },
|
50
50
|
{ name: "United States", iso3: "USA", iso: "US", iso_name: "UNITED STATES", numcode: "840", states_required: true },
|
51
|
-
{ name: "Bosnia and Herzegovina", iso3: "BIH", iso: "BA", iso_name: "BOSNIA AND HERZEGOVINA", numcode: "70"
|
51
|
+
{ name: "Bosnia and Herzegovina", iso3: "BIH", iso: "BA", iso_name: "BOSNIA AND HERZEGOVINA", numcode: "70" },
|
52
52
|
{ name: "Czech Republic", iso3: "CZE", iso: "CZ", iso_name: "CZECH REPUBLIC", numcode: "203" },
|
53
53
|
{ name: "Kuwait", iso3: "KWT", iso: "KW", iso_name: "KUWAIT", numcode: "414" },
|
54
54
|
{ name: "Monaco", iso3: "MCO", iso: "MC", iso_name: "MONACO", numcode: "492" },
|
@@ -99,7 +99,7 @@ Spree::Country.create!([
|
|
99
99
|
{ name: "Sweden", iso3: "SWE", iso: "SE", iso_name: "SWEDEN", numcode: "752" },
|
100
100
|
{ name: "Honduras", iso3: "HND", iso: "HN", iso_name: "HONDURAS", numcode: "340" },
|
101
101
|
{ name: "Rwanda", iso3: "RWA", iso: "RW", iso_name: "RWANDA", numcode: "646" },
|
102
|
-
{ name: "Switzerland", iso3: "CHE", iso: "CH", iso_name: "SWITZERLAND", numcode: "756"
|
102
|
+
{ name: "Switzerland", iso3: "CHE", iso: "CH", iso_name: "SWITZERLAND", numcode: "756" },
|
103
103
|
{ name: "Hong Kong", iso3: "HKG", iso: "HK", iso_name: "HONG KONG", numcode: "344" },
|
104
104
|
{ name: "Syrian Arab Republic", iso3: "SYR", iso: "SY", iso_name: "SYRIAN ARAB REPUBLIC", numcode: "760" },
|
105
105
|
{ name: "Taiwan", iso3: "TWN", iso: "TW", iso_name: "TAIWAN, PROVINCE OF CHINA", numcode: "158" },
|
@@ -109,7 +109,7 @@ Spree::Country.create!([
|
|
109
109
|
{ name: "Aruba", iso3: "ABW", iso: "AW", iso_name: "ARUBA", numcode: "533" },
|
110
110
|
{ name: "Australia", iso3: "AUS", iso: "AU", iso_name: "AUSTRALIA", numcode: "36", states_required: true },
|
111
111
|
{ name: "Thailand", iso3: "THA", iso: "TH", iso_name: "THAILAND", numcode: "764" },
|
112
|
-
{ name: "Austria", iso3: "AUT", iso: "AT", iso_name: "AUSTRIA", numcode: "40"
|
112
|
+
{ name: "Austria", iso3: "AUT", iso: "AT", iso_name: "AUSTRIA", numcode: "40" },
|
113
113
|
{ name: "Madagascar", iso3: "MDG", iso: "MG", iso_name: "MADAGASCAR", numcode: "450" },
|
114
114
|
{ name: "Togo", iso3: "TGO", iso: "TG", iso_name: "TOGO", numcode: "768" },
|
115
115
|
{ name: "Azerbaijan", iso3: "AZE", iso: "AZ", iso_name: "AZERBAIJAN", numcode: "31" },
|
@@ -118,7 +118,7 @@ Spree::Country.create!([
|
|
118
118
|
{ name: "Tokelau", iso3: "TKL", iso: "TK", iso_name: "TOKELAU", numcode: "772" },
|
119
119
|
{ name: "Bahamas", iso3: "BHS", iso: "BS", iso_name: "BAHAMAS", numcode: "44" },
|
120
120
|
{ name: "China", iso3: "CHN", iso: "CN", iso_name: "CHINA", numcode: "156" },
|
121
|
-
{ name: "Malaysia", iso3: "MYS", iso: "MY", iso_name: "MALAYSIA", numcode: "458"
|
121
|
+
{ name: "Malaysia", iso3: "MYS", iso: "MY", iso_name: "MALAYSIA", numcode: "458" },
|
122
122
|
{ name: "Tonga", iso3: "TON", iso: "TO", iso_name: "TONGA", numcode: "776" },
|
123
123
|
{ name: "Bahrain", iso3: "BHR", iso: "BH", iso_name: "BAHRAIN", numcode: "48" },
|
124
124
|
{ name: "Colombia", iso3: "COL", iso: "CO", iso_name: "COLOMBIA", numcode: "170" },
|
@@ -153,7 +153,7 @@ Spree::Country.create!([
|
|
153
153
|
{ name: "Sierra Leone", iso3: "SLE", iso: "SL", iso_name: "SIERRA LEONE", numcode: "694" },
|
154
154
|
{ name: "Tuvalu", iso3: "TUV", iso: "TV", iso_name: "TUVALU", numcode: "798" },
|
155
155
|
{ name: "Costa Rica", iso3: "CRI", iso: "CR", iso_name: "COSTA RICA", numcode: "188" },
|
156
|
-
{ name: "Germany", iso3: "DEU", iso: "DE", iso_name: "GERMANY", numcode: "276"
|
156
|
+
{ name: "Germany", iso3: "DEU", iso: "DE", iso_name: "GERMANY", numcode: "276" },
|
157
157
|
{ name: "Mauritius", iso3: "MUS", iso: "MU", iso_name: "MAURITIUS", numcode: "480" },
|
158
158
|
{ name: "Palau", iso3: "PLW", iso: "PW", iso_name: "PALAU", numcode: "585" },
|
159
159
|
{ name: "Cote D'Ivoire", iso3: "CIV", iso: "CI", iso_name: "COTE D'IVOIRE", numcode: "384" },
|
@@ -201,7 +201,7 @@ Spree::Country.create!([
|
|
201
201
|
{ name: "Nepal", iso3: "NPL", iso: "NP", iso_name: "NEPAL", numcode: "524", states_required: true },
|
202
202
|
{ name: "Wallis and Futuna", iso3: "WLF", iso: "WF", iso_name: "WALLIS AND FUTUNA", numcode: "876" },
|
203
203
|
{ name: "Western Sahara", iso3: "ESH", iso: "EH", iso_name: "WESTERN SAHARA", numcode: "732" },
|
204
|
-
{ name: "Argentina", iso3: "ARG", iso: "AR", iso_name: "ARGENTINA", numcode: "32"
|
204
|
+
{ name: "Argentina", iso3: "ARG", iso: "AR", iso_name: "ARGENTINA", numcode: "32" },
|
205
205
|
{ name: "Canada", iso3: "CAN", iso: "CA", iso_name: "CANADA", numcode: "124", states_required: true },
|
206
206
|
{ name: "Eritrea", iso3: "ERI", iso: "ER", iso_name: "ERITREA", numcode: "232" },
|
207
207
|
{ name: "Lithuania", iso3: "LTU", iso: "LT", iso_name: "LITHUANIA", numcode: "440" },
|
@@ -1,7 +1,10 @@
|
|
1
1
|
class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
|
4
|
-
|
3
|
+
Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
|
4
|
+
line_items.each do |line_item|
|
5
|
+
next if line_item.variant.nil?
|
6
|
+
next if line_item.variant.product.nil?
|
7
|
+
next if line_item.product.nil?
|
5
8
|
line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
|
6
9
|
end
|
7
10
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class UniqueShippingMethodCategories < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
klass = Spree::ShippingMethodCategory
|
4
|
+
columns = %w[shipping_category_id shipping_method_id]
|
5
|
+
|
6
|
+
say "Find duplicate #{klass} records"
|
7
|
+
duplicates = klass.
|
8
|
+
select((columns + %w[COUNT(*)]).join(',')).
|
9
|
+
group(columns.join(',')).
|
10
|
+
having('COUNT(*) > 1').
|
11
|
+
map { |row| row.attributes.slice(*columns) }
|
12
|
+
|
13
|
+
say "Delete all but the oldest duplicate #{klass} record"
|
14
|
+
duplicates.each do |conditions|
|
15
|
+
klass.where(conditions).order(:created_at).drop(1).each(&:destroy)
|
16
|
+
end
|
17
|
+
|
18
|
+
say "Add unique index to #{klass.table_name} for #{columns.inspect}"
|
19
|
+
add_index klass.table_name, columns, unique: true, name: 'unique_spree_shipping_method_categories'
|
20
|
+
|
21
|
+
say "Remove redundant simple index on #{klass.table_name}"
|
22
|
+
remove_index klass.table_name, name: 'index_spree_shipping_method_categories_on_shipping_category_id'
|
23
|
+
end
|
24
|
+
end
|
@@ -53,9 +53,9 @@ module Spree
|
|
53
53
|
def test_dummy_inject_extension_requirements
|
54
54
|
if DummyGeneratorHelper.inject_extension_requirements
|
55
55
|
inside dummy_path do
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
inject_require_for('spree_frontend')
|
57
|
+
inject_require_for('spree_backend')
|
58
|
+
inject_require_for('spree_api')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -82,6 +82,17 @@ module Spree
|
|
82
82
|
attr :database
|
83
83
|
|
84
84
|
protected
|
85
|
+
|
86
|
+
def inject_require_for(requirement)
|
87
|
+
inject_into_file 'config/application.rb', %Q[
|
88
|
+
begin
|
89
|
+
require '#{requirement}'
|
90
|
+
rescue LoadError
|
91
|
+
# #{requirement} is not available.
|
92
|
+
end
|
93
|
+
], :before => /require '#{@lib_name}'/, :verbose => true
|
94
|
+
end
|
95
|
+
|
85
96
|
def dummy_path
|
86
97
|
ENV['DUMMY_PATH'] || 'spec/dummy'
|
87
98
|
end
|
@@ -27,21 +27,31 @@ production:
|
|
27
27
|
database: <%= database_prefix %>spree_production
|
28
28
|
encoding: utf8
|
29
29
|
<% when 'postgres' %>
|
30
|
+
<% db_host = ENV['DB_HOST'] -%>
|
30
31
|
development:
|
31
32
|
adapter: postgresql
|
32
33
|
database: <%= database_prefix %>spree_development
|
33
34
|
username: postgres
|
34
35
|
min_messages: warning
|
36
|
+
<% unless db_host.blank? %>
|
37
|
+
host: <%= db_host %>
|
38
|
+
<% end %>
|
35
39
|
test:
|
36
40
|
adapter: postgresql
|
37
41
|
database: <%= database_prefix %>spree_test
|
38
42
|
username: postgres
|
39
43
|
min_messages: warning
|
44
|
+
<% unless db_host.blank? %>
|
45
|
+
host: <%= db_host %>
|
46
|
+
<% end %>
|
40
47
|
production:
|
41
48
|
adapter: postgresql
|
42
49
|
database: <%= database_prefix %>spree_production
|
43
50
|
username: postgres
|
44
51
|
min_messages: warning
|
52
|
+
<% unless db_host.blank? %>
|
53
|
+
host: <%= db_host %>
|
54
|
+
<% end %>
|
45
55
|
<% else %>
|
46
56
|
development:
|
47
57
|
adapter: sqlite3
|
data/lib/spree/core.rb
CHANGED
@@ -38,6 +38,7 @@ module Spree
|
|
38
38
|
end
|
39
39
|
|
40
40
|
require 'spree/core/version'
|
41
|
+
require 'spree/migrations'
|
41
42
|
require 'spree/core/engine'
|
42
43
|
|
43
44
|
require 'spree/i18n'
|
@@ -49,6 +50,8 @@ require 'spree/core/permalinks'
|
|
49
50
|
require 'spree/core/token_resource'
|
50
51
|
require 'spree/core/calculated_adjustments'
|
51
52
|
require 'spree/core/product_duplicator'
|
53
|
+
require 'spree/core/mail_method'
|
54
|
+
require 'spree/core/mail_settings'
|
52
55
|
|
53
56
|
ActiveRecord::Base.class_eval do
|
54
57
|
include CollectiveIdea::Acts::NestedSet
|
@@ -13,10 +13,12 @@ module Spree
|
|
13
13
|
# The current incomplete order from the session for use in cart and during checkout
|
14
14
|
def current_order(create_order_if_necessary = false)
|
15
15
|
return @current_order if @current_order
|
16
|
+
|
16
17
|
if session[:order_id]
|
17
18
|
current_order = Spree::Order.includes(:adjustments).find_by(id: session[:order_id], currency: current_currency)
|
18
19
|
@current_order = current_order unless current_order.try(:completed?)
|
19
20
|
end
|
21
|
+
|
20
22
|
if create_order_if_necessary and (@current_order.nil? or @current_order.completed?)
|
21
23
|
@current_order = Spree::Order.new(currency: current_currency)
|
22
24
|
@current_order.user ||= try_spree_current_user
|
@@ -29,6 +31,7 @@ module Spree
|
|
29
31
|
session[:access_token] = @current_order.token
|
30
32
|
end
|
31
33
|
end
|
34
|
+
|
32
35
|
if @current_order
|
33
36
|
@current_order.last_ip_address = ip_address
|
34
37
|
session[:order_id] = @current_order.id
|
@@ -58,7 +61,7 @@ module Spree
|
|
58
61
|
last_incomplete_order = user.last_incomplete_spree_order
|
59
62
|
if session[:order_id].nil? && last_incomplete_order
|
60
63
|
session[:order_id] = last_incomplete_order.id
|
61
|
-
elsif current_order
|
64
|
+
elsif current_order && last_incomplete_order && current_order != last_incomplete_order
|
62
65
|
current_order.merge!(last_incomplete_order, user)
|
63
66
|
end
|
64
67
|
end
|
@@ -15,16 +15,14 @@ module Spree
|
|
15
15
|
|
16
16
|
def self.ssl_required(*actions)
|
17
17
|
ssl_allowed *actions
|
18
|
-
if
|
19
|
-
if
|
20
|
-
|
21
|
-
|
22
|
-
force_ssl :only => actions
|
23
|
-
end
|
18
|
+
if actions.empty? or Rails.application.config.force_ssl
|
19
|
+
force_ssl :if => :ssl_supported?
|
20
|
+
else
|
21
|
+
force_ssl :if => :ssl_supported?, :only => actions
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
def
|
25
|
+
def ssl_supported?
|
28
26
|
return Spree::Config[:allow_ssl_in_production] if Rails.env.production?
|
29
27
|
return Spree::Config[:allow_ssl_in_staging] if Rails.env.staging?
|
30
28
|
return Spree::Config[:allow_ssl_in_development_and_test] if (Rails.env.development? or Rails.env.test?)
|
@@ -30,6 +30,12 @@ module Spree
|
|
30
30
|
:line_items_attributes => permitted_line_item_attributes
|
31
31
|
]
|
32
32
|
end
|
33
|
+
|
34
|
+
def permitted_product_attributes
|
35
|
+
permitted_attributes.product_attributes + [
|
36
|
+
:product_properties_attributes => permitted_product_properties_attributes
|
37
|
+
]
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -38,14 +38,11 @@ module DelegateBelongsTo
|
|
38
38
|
attrs.concat get_association_column_names(association) if attrs.delete :defaults
|
39
39
|
attrs.each do |attr|
|
40
40
|
class_def attr do |*args|
|
41
|
-
|
42
|
-
send(:delegator_for, association).send(attr)
|
43
|
-
else
|
44
|
-
send(:delegator_for, association).send(attr, *args)
|
45
|
-
end
|
41
|
+
send(:delegator_for, association, attr, *args)
|
46
42
|
end
|
43
|
+
|
47
44
|
class_def "#{attr}=" do |val|
|
48
|
-
send(:
|
45
|
+
send(:delegator_for_setter, association, attr, val)
|
49
46
|
end
|
50
47
|
end
|
51
48
|
end
|
@@ -71,19 +68,28 @@ module DelegateBelongsTo
|
|
71
68
|
end
|
72
69
|
|
73
70
|
private
|
74
|
-
|
75
71
|
def class_def(name, method=nil, &blk)
|
76
72
|
class_eval { method.nil? ? define_method(name, &blk) : define_method(name, method) }
|
77
73
|
end
|
74
|
+
end
|
78
75
|
|
76
|
+
def delegator_for(association, attr, *args)
|
77
|
+
return if self.class.column_names.include?(attr.to_s)
|
78
|
+
send("#{association}=", self.class.reflect_on_association(association).klass.new) if send(association).nil?
|
79
|
+
if args.empty?
|
80
|
+
send(association).send(attr)
|
81
|
+
else
|
82
|
+
send(association).send(attr, *args)
|
83
|
+
end
|
79
84
|
end
|
80
85
|
|
81
|
-
def
|
86
|
+
def delegator_for_setter(association, attr, val)
|
87
|
+
return if self.class.column_names.include?(attr.to_s)
|
82
88
|
send("#{association}=", self.class.reflect_on_association(association).klass.new) if send(association).nil?
|
83
|
-
send(association)
|
89
|
+
send(association).send("#{attr}=", val)
|
84
90
|
end
|
85
91
|
protected :delegator_for
|
86
|
-
|
92
|
+
protected :delegator_for_setter
|
87
93
|
end
|
88
94
|
|
89
95
|
ActiveRecord::Base.send :include, DelegateBelongsTo
|
data/lib/spree/core/engine.rb
CHANGED
@@ -52,6 +52,7 @@ module Spree
|
|
52
52
|
end
|
53
53
|
|
54
54
|
initializer "spree.mail.settings" do |app|
|
55
|
+
ActionMailer::Base.add_delivery_method :spree, Spree::Core::MailMethod
|
55
56
|
Spree::Core::MailSettings.init
|
56
57
|
Mail.register_interceptor(Spree::Core::MailInterceptor)
|
57
58
|
end
|
@@ -76,7 +77,11 @@ module Spree
|
|
76
77
|
]
|
77
78
|
end
|
78
79
|
|
79
|
-
|
80
|
+
# Promotion rules need to be evaluated on after initialize otherwise
|
81
|
+
# Spree.user_class would be nil and users might experience errors related
|
82
|
+
# to malformed model associations (Spree.user_class is only defined on
|
83
|
+
# the app initializer)
|
84
|
+
config.after_initialize do
|
80
85
|
Rails.application.config.spree.promotions.rules.concat [
|
81
86
|
Spree::Promotion::Rules::ItemTotal,
|
82
87
|
Spree::Promotion::Rules::Product,
|
@@ -98,8 +103,12 @@ module Spree
|
|
98
103
|
:number,
|
99
104
|
:verification_value]
|
100
105
|
end
|
106
|
+
|
107
|
+
initializer "spree.core.checking_migrations" do |app|
|
108
|
+
Migrations.new(config, engine_name).check
|
109
|
+
end
|
101
110
|
end
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
105
|
-
require 'spree/core/routes'
|
114
|
+
require 'spree/core/routes'
|