Merge pull request #5703 from Matt-Yorkley/checkout-addresses

Checkout addresses
This commit is contained in:
Luis Ramos
2020-07-01 19:06:29 +01:00
committed by GitHub
5 changed files with 419 additions and 138 deletions

View File

@@ -9,7 +9,7 @@ class UserDefaultAddressSetter
# Sets the order bill address as the user default bill address
def set_default_bill_address
new_bill_address = @order.bill_address.clone.attributes
new_bill_address = @order.bill_address.dup.attributes.except!('created_at', 'updated_at')
set_bill_address_attributes(@current_user, new_bill_address)
set_bill_address_attributes(@order.customer, new_bill_address)
@@ -17,7 +17,7 @@ class UserDefaultAddressSetter
# Sets the order ship address as the user default ship address
def set_default_ship_address
new_ship_address = @order.ship_address.clone.attributes
new_ship_address = @order.ship_address.dup.attributes.except!('created_at', 'updated_at')
set_ship_address_attributes(@current_user, new_ship_address)
set_ship_address_attributes(@order.customer, new_ship_address)

View File

@@ -0,0 +1,253 @@
class RequireTimestamps < ActiveRecord::Migration
def up
current_time = Time.zone.now
change_column_null :customers, :created_at, false, current_time
change_column_null :customers, :updated_at, false, current_time
change_column_null :delayed_jobs, :created_at, false, current_time
change_column_null :delayed_jobs, :updated_at, false, current_time
change_column_null :distributors_shipping_methods, :created_at, false, current_time
change_column_null :distributors_shipping_methods, :updated_at, false, current_time
change_column_null :enterprise_fees, :created_at, false, current_time
change_column_null :enterprise_fees, :updated_at, false, current_time
change_column_null :enterprises, :created_at, false, current_time
change_column_null :enterprises, :updated_at, false, current_time
change_column_null :exchange_fees, :created_at, false, current_time
change_column_null :exchange_fees, :updated_at, false, current_time
change_column_null :exchange_variants, :created_at, false, current_time
change_column_null :exchange_variants, :updated_at, false, current_time
change_column_null :exchanges, :created_at, false, current_time
change_column_null :exchanges, :updated_at, false, current_time
change_column_null :inventory_items, :created_at, false, current_time
change_column_null :inventory_items, :updated_at, false, current_time
change_column_null :order_cycle_schedules, :created_at, false, current_time
change_column_null :order_cycle_schedules, :updated_at, false, current_time
change_column_null :order_cycles, :created_at, false, current_time
change_column_null :order_cycles, :updated_at, false, current_time
change_column_null :producer_properties, :created_at, false, current_time
change_column_null :producer_properties, :updated_at, false, current_time
change_column_null :proxy_orders, :created_at, false, current_time
change_column_null :proxy_orders, :updated_at, false, current_time
change_column_null :schedules, :created_at, false, current_time
change_column_null :schedules, :updated_at, false, current_time
change_column_null :sessions, :created_at, false, current_time
change_column_null :sessions, :updated_at, false, current_time
change_column_null :spree_activators, :created_at, false, current_time
change_column_null :spree_activators, :updated_at, false, current_time
change_column_null :spree_addresses, :created_at, false, current_time
change_column_null :spree_addresses, :updated_at, false, current_time
change_column_null :spree_adjustments, :created_at, false, current_time
change_column_null :spree_adjustments, :updated_at, false, current_time
change_column_null :spree_calculators, :created_at, false, current_time
change_column_null :spree_calculators, :updated_at, false, current_time
change_column_null :spree_configurations, :created_at, false, current_time
change_column_null :spree_configurations, :updated_at, false, current_time
change_column_null :spree_credit_cards, :created_at, false, current_time
change_column_null :spree_credit_cards, :updated_at, false, current_time
change_column_null :spree_gateways, :created_at, false, current_time
change_column_null :spree_gateways, :updated_at, false, current_time
change_column_null :spree_inventory_units, :created_at, false, current_time
change_column_null :spree_inventory_units, :updated_at, false, current_time
change_column_null :spree_line_items, :created_at, false, current_time
change_column_null :spree_line_items, :updated_at, false, current_time
change_column_null :spree_log_entries, :created_at, false, current_time
change_column_null :spree_log_entries, :updated_at, false, current_time
change_column_null :spree_option_types, :created_at, false, current_time
change_column_null :spree_option_types, :updated_at, false, current_time
change_column_null :spree_option_values, :created_at, false, current_time
change_column_null :spree_option_values, :updated_at, false, current_time
change_column_null :spree_orders, :created_at, false, current_time
change_column_null :spree_orders, :updated_at, false, current_time
change_column_null :spree_payment_methods, :created_at, false, current_time
change_column_null :spree_payment_methods, :updated_at, false, current_time
change_column_null :spree_payments, :created_at, false, current_time
change_column_null :spree_payments, :updated_at, false, current_time
change_column_null :spree_preferences, :created_at, false, current_time
change_column_null :spree_preferences, :updated_at, false, current_time
change_column_null :spree_product_option_types, :created_at, false, current_time
change_column_null :spree_product_option_types, :updated_at, false, current_time
change_column_null :spree_product_properties, :created_at, false, current_time
change_column_null :spree_product_properties, :updated_at, false, current_time
change_column_null :spree_products, :created_at, false, current_time
change_column_null :spree_products, :updated_at, false, current_time
change_column_null :spree_promotion_rules, :created_at, false, current_time
change_column_null :spree_promotion_rules, :updated_at, false, current_time
change_column_null :spree_properties, :created_at, false, current_time
change_column_null :spree_properties, :updated_at, false, current_time
change_column_null :spree_return_authorizations, :created_at, false, current_time
change_column_null :spree_return_authorizations, :updated_at, false, current_time
change_column_null :spree_shipments, :created_at, false, current_time
change_column_null :spree_shipments, :updated_at, false, current_time
change_column_null :spree_shipping_categories, :created_at, false, current_time
change_column_null :spree_shipping_categories, :updated_at, false, current_time
change_column_null :spree_shipping_method_categories, :created_at, false, current_time
change_column_null :spree_shipping_method_categories, :updated_at, false, current_time
change_column_null :spree_shipping_methods, :created_at, false, current_time
change_column_null :spree_shipping_methods, :updated_at, false, current_time
change_column_null :spree_shipping_rates, :created_at, false, current_time
change_column_null :spree_shipping_rates, :updated_at, false, current_time
change_column_null :spree_skrill_transactions, :created_at, false, current_time
change_column_null :spree_skrill_transactions, :updated_at, false, current_time
change_column_null :spree_state_changes, :created_at, false, current_time
change_column_null :spree_state_changes, :updated_at, false, current_time
change_column_null :spree_stock_items, :created_at, false, current_time
change_column_null :spree_stock_items, :updated_at, false, current_time
change_column_null :spree_stock_locations, :created_at, false, current_time
change_column_null :spree_stock_locations, :updated_at, false, current_time
change_column_null :spree_stock_movements, :created_at, false, current_time
change_column_null :spree_stock_movements, :updated_at, false, current_time
change_column_null :spree_stock_transfers, :created_at, false, current_time
change_column_null :spree_stock_transfers, :updated_at, false, current_time
change_column_null :spree_tax_categories, :created_at, false, current_time
change_column_null :spree_tax_categories, :updated_at, false, current_time
change_column_null :spree_tax_rates, :created_at, false, current_time
change_column_null :spree_tax_rates, :updated_at, false, current_time
change_column_null :spree_taxonomies, :created_at, false, current_time
change_column_null :spree_taxonomies, :updated_at, false, current_time
change_column_null :spree_taxons, :created_at, false, current_time
change_column_null :spree_taxons, :updated_at, false, current_time
change_column_null :spree_tokenized_permissions, :created_at, false, current_time
change_column_null :spree_tokenized_permissions, :updated_at, false, current_time
change_column_null :spree_users, :created_at, false, current_time
change_column_null :spree_users, :updated_at, false, current_time
change_column_null :spree_zone_members, :created_at, false, current_time
change_column_null :spree_zone_members, :updated_at, false, current_time
change_column_null :spree_zones, :created_at, false, current_time
change_column_null :spree_zones, :updated_at, false, current_time
change_column_null :stripe_accounts, :created_at, false, current_time
change_column_null :stripe_accounts, :updated_at, false, current_time
change_column_null :subscription_line_items, :created_at, false, current_time
change_column_null :subscription_line_items, :updated_at, false, current_time
change_column_null :subscriptions, :created_at, false, current_time
change_column_null :subscriptions, :updated_at, false, current_time
change_column_null :tag_rules, :created_at, false, current_time
change_column_null :tag_rules, :updated_at, false, current_time
change_column_null :column_preferences, :created_at, false, current_time
change_column_null :column_preferences, :updated_at, false, current_time
end
def down
change_column_null :customers, :created_at, true
change_column_null :customers, :updated_at, true
change_column_null :delayed_jobs, :created_at, true
change_column_null :delayed_jobs, :updated_at, true
change_column_null :distributors_shipping_methods, :created_at, true
change_column_null :distributors_shipping_methods, :updated_at, true
change_column_null :enterprise_fees, :created_at, true
change_column_null :enterprise_fees, :updated_at, true
change_column_null :enterprises, :created_at, true
change_column_null :enterprises, :updated_at, true
change_column_null :exchange_fees, :created_at, true
change_column_null :exchange_fees, :updated_at, true
change_column_null :exchange_variants, :created_at, true
change_column_null :exchange_variants, :updated_at, true
change_column_null :exchanges, :created_at, true
change_column_null :exchanges, :updated_at, true
change_column_null :inventory_items, :created_at, true
change_column_null :inventory_items, :updated_at, true
change_column_null :order_cycle_schedules, :created_at, true
change_column_null :order_cycle_schedules, :updated_at, true
change_column_null :order_cycles, :created_at, true
change_column_null :order_cycles, :updated_at, true
change_column_null :producer_properties, :created_at, true
change_column_null :producer_properties, :updated_at, true
change_column_null :proxy_orders, :created_at, true
change_column_null :proxy_orders, :updated_at, true
change_column_null :schedules, :created_at, true
change_column_null :schedules, :updated_at, true
change_column_null :sessions, :created_at, true
change_column_null :sessions, :updated_at, true
change_column_null :spree_activators, :created_at, true
change_column_null :spree_activators, :updated_at, true
change_column_null :spree_addresses, :created_at, true
change_column_null :spree_addresses, :updated_at, true
change_column_null :spree_adjustments, :created_at, true
change_column_null :spree_adjustments, :updated_at, true
change_column_null :spree_calculators, :created_at, true
change_column_null :spree_calculators, :updated_at, true
change_column_null :spree_configurations, :created_at, true
change_column_null :spree_configurations, :updated_at, true
change_column_null :spree_credit_cards, :created_at, true
change_column_null :spree_credit_cards, :updated_at, true
change_column_null :spree_gateways, :created_at, true
change_column_null :spree_gateways, :updated_at, true
change_column_null :spree_inventory_units, :created_at, true
change_column_null :spree_inventory_units, :updated_at, true
change_column_null :spree_line_items, :created_at, true
change_column_null :spree_line_items, :updated_at, true
change_column_null :spree_log_entries, :created_at, true
change_column_null :spree_log_entries, :updated_at, true
change_column_null :spree_option_types, :created_at, true
change_column_null :spree_option_types, :updated_at, true
change_column_null :spree_option_values, :created_at, true
change_column_null :spree_option_values, :updated_at, true
change_column_null :spree_orders, :created_at, true
change_column_null :spree_orders, :updated_at, true
change_column_null :spree_payment_methods, :created_at, true
change_column_null :spree_payment_methods, :updated_at, true
change_column_null :spree_payments, :created_at, true
change_column_null :spree_payments, :updated_at, true
change_column_null :spree_preferences, :created_at, true
change_column_null :spree_preferences, :updated_at, true
change_column_null :spree_product_option_types, :created_at, true
change_column_null :spree_product_option_types, :updated_at, true
change_column_null :spree_product_properties, :created_at, true
change_column_null :spree_product_properties, :updated_at, true
change_column_null :spree_products, :created_at, true
change_column_null :spree_products, :updated_at, true
change_column_null :spree_promotion_rules, :created_at, true
change_column_null :spree_promotion_rules, :updated_at, true
change_column_null :spree_properties, :created_at, true
change_column_null :spree_properties, :updated_at, true
change_column_null :spree_return_authorizations, :created_at, true
change_column_null :spree_return_authorizations, :updated_at, true
change_column_null :spree_shipments, :created_at, true
change_column_null :spree_shipments, :updated_at, true
change_column_null :spree_shipping_categories, :created_at, true
change_column_null :spree_shipping_categories, :updated_at, true
change_column_null :spree_shipping_method_categories, :created_at, true
change_column_null :spree_shipping_method_categories, :updated_at, true
change_column_null :spree_shipping_methods, :created_at, true
change_column_null :spree_shipping_methods, :updated_at, true
change_column_null :spree_shipping_rates, :created_at, true
change_column_null :spree_shipping_rates, :updated_at, true
change_column_null :spree_skrill_transactions, :created_at, true
change_column_null :spree_skrill_transactions, :updated_at, true
change_column_null :spree_state_changes, :created_at, true
change_column_null :spree_state_changes, :updated_at, true
change_column_null :spree_stock_items, :created_at, true
change_column_null :spree_stock_items, :updated_at, true
change_column_null :spree_stock_locations, :created_at, true
change_column_null :spree_stock_locations, :updated_at, true
change_column_null :spree_stock_movements, :created_at, true
change_column_null :spree_stock_movements, :updated_at, true
change_column_null :spree_stock_transfers, :created_at, true
change_column_null :spree_stock_transfers, :updated_at, true
change_column_null :spree_tax_categories, :created_at, true
change_column_null :spree_tax_categories, :updated_at, true
change_column_null :spree_tax_rates, :created_at, true
change_column_null :spree_tax_rates, :updated_at, true
change_column_null :spree_taxonomies, :created_at, true
change_column_null :spree_taxonomies, :updated_at, true
change_column_null :spree_taxons, :created_at, true
change_column_null :spree_taxons, :updated_at, true
change_column_null :spree_tokenized_permissions, :created_at, true
change_column_null :spree_tokenized_permissions, :updated_at, true
change_column_null :spree_users, :created_at, true
change_column_null :spree_users, :updated_at, true
change_column_null :spree_zone_members, :created_at, true
change_column_null :spree_zone_members, :updated_at, true
change_column_null :spree_zones, :created_at, true
change_column_null :spree_zones, :updated_at, true
change_column_null :stripe_accounts, :created_at, true
change_column_null :stripe_accounts, :updated_at, true
change_column_null :subscription_line_items, :created_at, true
change_column_null :subscription_line_items, :updated_at, true
change_column_null :subscriptions, :created_at, true
change_column_null :subscriptions, :updated_at, true
change_column_null :tag_rules, :created_at, true
change_column_null :tag_rules, :updated_at, true
change_column_null :column_preferences, :created_at, true
change_column_null :column_preferences, :updated_at, true
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20200624091611) do
ActiveRecord::Schema.define(version: 20200630070422) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -32,8 +32,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "action_name", null: false
t.string "column_name", null: false
t.boolean "visible", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "column_preferences", ["user_id", "action_name", "column_name"], name: "index_column_prefs_on_user_id_and_action_name_and_column_name", unique: true, using: :btree
@@ -51,8 +51,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "enterprise_id", null: false
t.string "code"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "bill_address_id"
t.integer "ship_address_id"
t.string "name"
@@ -75,8 +75,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.datetime "failed_at"
t.string "locked_by"
t.string "queue"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
@@ -92,8 +92,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "distributors_shipping_methods", force: true do |t|
t.integer "distributor_id"
t.integer "shipping_method_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "distributors_shipping_methods", ["distributor_id"], name: "index_distributors_shipping_methods_on_distributor_id", using: :btree
@@ -103,8 +103,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "enterprise_id"
t.string "fee_type"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "tax_category_id"
t.boolean "inherits_tax_category", default: false, null: false
end
@@ -190,8 +190,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "address_id"
t.text "pickup_times"
t.string "next_collection_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "distributor_info"
t.string "logo_file_name"
t.string "logo_content_type"
@@ -229,8 +229,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "exchange_fees", force: true do |t|
t.integer "exchange_id"
t.integer "enterprise_fee_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "exchange_fees", ["enterprise_fee_id"], name: "index_exchange_fees_on_enterprise_fee_id", using: :btree
@@ -239,8 +239,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "exchange_variants", force: true do |t|
t.integer "exchange_id"
t.integer "variant_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "exchange_variants", ["exchange_id"], name: "index_exchange_variants_on_exchange_id", using: :btree
@@ -252,8 +252,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "receiver_id"
t.text "pickup_time"
t.text "pickup_instructions"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "incoming", default: false, null: false
t.text "receival_instructions"
end
@@ -266,8 +266,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "enterprise_id", null: false
t.integer "variant_id", null: false
t.boolean "visible", default: true, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "inventory_items", ["enterprise_id", "variant_id"], name: "index_inventory_items_on_enterprise_id_and_variant_id", unique: true, using: :btree
@@ -275,8 +275,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "order_cycle_schedules", force: true do |t|
t.integer "order_cycle_id", null: false
t.integer "schedule_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "order_cycle_schedules", ["order_cycle_id"], name: "index_order_cycle_schedules_on_order_cycle_id", using: :btree
@@ -287,8 +287,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.datetime "orders_open_at"
t.datetime "orders_close_at"
t.integer "coordinator_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "producer_properties", force: true do |t|
@@ -296,8 +296,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "producer_id"
t.integer "property_id"
t.integer "position", default: 0, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "producer_properties", ["position"], name: "index_producer_properties_on_position", using: :btree
@@ -308,8 +308,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "subscription_id", null: false
t.integer "order_id"
t.datetime "canceled_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "order_cycle_id", null: false
t.datetime "placed_at"
t.datetime "confirmed_at"
@@ -321,15 +321,15 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "schedules", force: true do |t|
t.string "name", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "sessions", force: true do |t|
t.string "session_id", null: false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree
@@ -338,8 +338,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_activators", force: true do |t|
t.string "description"
t.datetime "expires_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "starts_at"
t.string "name"
t.string "event_name"
@@ -363,8 +363,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "alternative_phone"
t.integer "state_id"
t.integer "country_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "company"
t.float "latitude"
t.float "longitude"
@@ -379,8 +379,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "label"
t.string "source_type"
t.integer "adjustable_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "mandatory"
t.integer "originator_id"
t.string "originator_type"
@@ -413,15 +413,15 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "type"
t.integer "calculable_id", null: false
t.string "calculable_type", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_configurations", force: true do |t|
t.string "name"
t.string "type", limit: 50
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_configurations", ["name", "type"], name: "index_configurations_on_name_and_type", using: :btree
@@ -446,8 +446,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "start_year"
t.string "issue_number"
t.integer "address_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "gateway_customer_profile_id"
t.string "gateway_payment_profile_id"
t.integer "user_id"
@@ -466,16 +466,16 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "environment", default: "development"
t.string "server", default: "test"
t.boolean "test_mode", default: true
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_inventory_units", force: true do |t|
t.string "state"
t.integer "variant_id"
t.integer "order_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "shipment_id"
t.integer "return_authorization_id"
t.boolean "pending", default: true
@@ -490,8 +490,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "variant_id"
t.integer "quantity", null: false
t.decimal "price", precision: 8, scale: 2, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "max_quantity"
t.string "currency"
t.decimal "distribution_fee", precision: 10, scale: 2
@@ -507,15 +507,15 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "source_id"
t.string "source_type"
t.text "details"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_option_types", force: true do |t|
t.string "name", limit: 100
t.string "presentation", limit: 100
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "position", default: 0, null: false
end
@@ -524,8 +524,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "name"
t.string "presentation"
t.integer "option_type_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_option_values_line_items", id: false, force: true do |t|
@@ -550,8 +550,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "state"
t.decimal "adjustment_total", precision: 10, scale: 2, default: 0.0, null: false
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "completed_at"
t.integer "bill_address_id"
t.integer "ship_address_id"
@@ -581,8 +581,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.text "description"
t.boolean "active", default: true
t.string "environment", default: "development"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "deleted_at"
t.string "display_on"
end
@@ -590,8 +590,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_payments", force: true do |t|
t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false
t.integer "order_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "source_id"
t.string "source_type"
t.integer "payment_method_id"
@@ -635,8 +635,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_preferences", force: true do |t|
t.text "value"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "key"
t.string "value_type"
end
@@ -670,16 +670,16 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "position"
t.integer "product_id"
t.integer "option_type_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_product_properties", force: true do |t|
t.string "value"
t.integer "product_id"
t.integer "property_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "position", default: 0
end
@@ -704,8 +704,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "meta_keywords"
t.integer "tax_category_id"
t.integer "shipping_category_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "supplier_id"
t.boolean "group_buy"
t.float "group_buy_unit_size"
@@ -758,8 +758,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "user_id"
t.integer "product_group_id"
t.string "type"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_promotion_rules", ["product_group_id"], name: "index_promotion_rules_on_product_group_id", using: :btree
@@ -776,8 +776,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_properties", force: true do |t|
t.string "name"
t.string "presentation", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_return_authorizations", force: true do |t|
@@ -786,8 +786,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.decimal "amount", precision: 10, scale: 2, default: 0.0, null: false
t.integer "order_id"
t.text "reason"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "stock_location_id"
end
@@ -810,8 +810,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.datetime "shipped_at"
t.integer "order_id"
t.integer "address_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "state"
t.integer "stock_location_id"
end
@@ -821,16 +821,16 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_shipping_categories", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "temperature_controlled", default: false, null: false
end
create_table "spree_shipping_method_categories", force: true do |t|
t.integer "shipping_method_id", null: false
t.integer "shipping_category_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_shipping_method_categories", ["shipping_category_id"], name: "index_spree_shipping_method_categories_on_shipping_category_id", using: :btree
@@ -838,8 +838,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_shipping_methods", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "display_on"
t.datetime "deleted_at"
t.boolean "require_ship_address", default: true
@@ -857,8 +857,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "shipping_method_id"
t.boolean "selected", default: false
t.decimal "cost", precision: 8, scale: 2, default: 0.0
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_shipping_rates", ["shipment_id", "shipping_method_id"], name: "spree_shipping_rates_join_index", unique: true, using: :btree
@@ -870,8 +870,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "transaction_id"
t.integer "customer_id"
t.string "payment_type"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_state_changes", force: true do |t|
@@ -879,8 +879,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "previous_state"
t.integer "stateful_id"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "stateful_type"
t.string "next_state"
end
@@ -895,8 +895,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "stock_location_id"
t.integer "variant_id"
t.integer "count_on_hand", default: 0, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "backorderable", default: false
t.datetime "deleted_at"
end
@@ -907,8 +907,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_stock_locations", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "address1"
t.string "address2"
t.string "city"
@@ -926,8 +926,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "stock_item_id"
t.integer "quantity", default: 0
t.string "action"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "originator_id"
t.string "originator_type"
end
@@ -939,8 +939,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "reference"
t.integer "source_location_id"
t.integer "destination_location_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "number"
end
@@ -951,8 +951,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_tax_categories", force: true do |t|
t.string "name"
t.string "description"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "is_default", default: false
t.datetime "deleted_at"
end
@@ -961,8 +961,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.decimal "amount", precision: 8, scale: 5
t.integer "zone_id"
t.integer "tax_category_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "included_in_price", default: false
t.string "name"
t.boolean "show_rate_in_label", default: true
@@ -971,8 +971,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "spree_taxonomies", force: true do |t|
t.string "name", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "position", default: 0
end
@@ -982,8 +982,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "name", null: false
t.string "permalink"
t.integer "taxonomy_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lft"
t.integer "rgt"
t.string "icon_file_name"
@@ -1004,8 +1004,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "permissable_id"
t.string "permissable_type"
t.string "token"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "spree_tokenized_permissions", ["permissable_id", "permissable_type"], name: "index_tokenized_name_and_type", using: :btree
@@ -1028,8 +1028,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.string "login"
t.integer "ship_address_id"
t.integer "bill_address_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "authentication_token"
t.string "unlock_token"
t.datetime "locked_at"
@@ -1075,15 +1075,15 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "zoneable_id"
t.string "zoneable_type"
t.integer "zone_id"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "spree_zones", force: true do |t|
t.string "name"
t.string "description"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "default_tax", default: false
t.integer "zone_members_count", default: 0
end
@@ -1091,8 +1091,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "stripe_accounts", force: true do |t|
t.string "stripe_user_id"
t.string "stripe_publishable_key"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "enterprise_id"
end
@@ -1102,8 +1102,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "subscription_id", null: false
t.integer "variant_id", null: false
t.integer "quantity", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.decimal "price_estimate", precision: 8, scale: 2
end
@@ -1118,8 +1118,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
t.integer "shipping_method_id", null: false
t.datetime "begins_at"
t.datetime "ends_at"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "bill_address_id", null: false
t.integer "ship_address_id", null: false
t.datetime "canceled_at"
@@ -1147,8 +1147,8 @@ ActiveRecord::Schema.define(version: 20200624091611) do
create_table "tag_rules", force: true do |t|
t.integer "enterprise_id", null: false
t.string "type", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "is_default", default: false, null: false
t.integer "priority", default: 99, null: false
end

View File

@@ -74,7 +74,7 @@ feature "As a consumer I want to check out my cart", js: true do
fill_out_form
end
it "allows user to save default billing address and shipping address" do
it "creates a new default billing address and shipping address" do
expect(user.bill_address).to be_nil
expect(user.ship_address).to be_nil
@@ -94,6 +94,32 @@ feature "As a consumer I want to check out my cart", js: true do
expect(user.reload.ship_address.address1).to eq '123 Your Head'
end
context "when the user and customer have existing default addresses" do
let(:existing_address) { create(:address) }
before do
user.bill_address = existing_address
user.ship_address = existing_address
end
it "updates billing address and shipping address" do
expect(order.bill_address).to be_nil
expect(order.ship_address).to be_nil
place_order
expect(page).to have_content "Your order has been processed successfully"
expect(order.reload.bill_address.address1).to eq '123 Your Head'
expect(order.reload.ship_address.address1).to eq '123 Your Head'
expect(order.customer.bill_address.address1).to eq '123 Your Head'
expect(order.customer.ship_address.address1).to eq '123 Your Head'
expect(user.reload.bill_address.address1).to eq '123 Your Head'
expect(user.reload.ship_address.address1).to eq '123 Your Head'
end
end
it "it doesn't tell about previous orders" do
expect(page).to have_no_content("You have an order for this order cycle already.")
end

View File

@@ -9,23 +9,25 @@ describe Spree.user_class do
describe "addresses" do
let(:user) { create(:user, bill_address: create(:address)) }
it 'updates billing address with new address' do
old_bill_address = user.bill_address
new_bill_address = create(:address, firstname: 'abc')
context "updating addresses via nested attributes" do
it 'updates billing address with new address' do
old_bill_address = user.bill_address
new_bill_address = create(:address, firstname: 'abc')
user.update(bill_address_attributes: new_bill_address.clone.attributes.merge('id' => old_bill_address.id))
user.update(bill_address_attributes: new_bill_address.dup.attributes.merge('id' => old_bill_address.id).except!('created_at', 'updated_at'))
expect(user.bill_address.id).to eq old_bill_address.id
expect(user.bill_address.firstname).to eq new_bill_address.firstname
end
expect(user.bill_address.id).to eq old_bill_address.id
expect(user.bill_address.firstname).to eq new_bill_address.firstname
end
it 'creates new shipping address' do
new_ship_address = create(:address, firstname: 'abc')
it 'creates new shipping address' do
new_ship_address = create(:address, firstname: 'abc')
user.update(ship_address_attributes: new_ship_address.clone.attributes)
user.update(ship_address_attributes: new_ship_address.dup.attributes.except!('created_at', 'updated_at'))
expect(user.ship_address.id).not_to eq new_ship_address.id
expect(user.ship_address.firstname).to eq new_ship_address.firstname
expect(user.ship_address.id).not_to eq new_ship_address.id
expect(user.ship_address.firstname).to eq new_ship_address.firstname
end
end
end