spree 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/CHANGELOG +81 -4
- data/CONTRIBUTORS +18 -10
- data/Rakefile +5 -4
- data/app/controllers/admin/adjustments_controller.rb +17 -3
- data/app/controllers/admin/base_controller.rb +2 -2
- data/app/controllers/admin/checkouts_controller.rb +43 -34
- data/app/controllers/admin/line_items_controller.rb +32 -18
- data/app/controllers/admin/option_types_controller.rb +1 -1
- data/app/controllers/admin/orders_controller.rb +28 -7
- data/app/controllers/admin/payments_controller.rb +7 -7
- data/app/controllers/admin/products_controller.rb +12 -23
- data/app/controllers/admin/reports_controller.rb +19 -7
- data/app/controllers/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/admin/shipments_controller.rb +9 -9
- data/app/controllers/admin/users_controller.rb +3 -1
- data/app/controllers/admin/variants_controller.rb +2 -2
- data/app/controllers/checkouts_controller.rb +29 -18
- data/app/controllers/content_controller.rb +1 -1
- data/{vendor/extensions/localization/app → app}/controllers/locale_controller.rb +1 -1
- data/app/controllers/orders_controller.rb +33 -30
- data/app/controllers/password_resets_controller.rb +4 -4
- data/app/controllers/products_controller.rb +0 -6
- data/app/controllers/spree/base_controller.rb +9 -2
- data/app/controllers/user_sessions_controller.rb +18 -18
- data/app/controllers/users_controller.rb +2 -2
- data/app/helpers/admin/base_helper.rb +5 -2
- data/app/helpers/admin/navigation_helper.rb +1 -1
- data/app/helpers/admin/orders_helper.rb +0 -13
- data/app/helpers/admin/products_helper.rb +0 -8
- data/app/helpers/checkouts_helper.rb +5 -5
- data/app/helpers/products_helper.rb +0 -12
- data/app/helpers/spree/base_helper.rb +10 -39
- data/app/helpers/taxons_helper.rb +1 -0
- data/app/models/address.rb +6 -1
- data/app/models/app_configuration.rb +15 -14
- data/app/models/calculator/flexi_rate.rb +2 -1
- data/app/models/calculator/vat.rb +1 -1
- data/app/models/checkout.rb +1 -1
- data/app/models/creditcard.rb +26 -20
- data/app/models/inventory_unit.rb +70 -21
- data/app/models/line_item.rb +25 -11
- data/app/models/order.rb +16 -10
- data/app/models/payment.rb +4 -1
- data/app/models/payment_method.rb +14 -5
- data/app/models/product.rb +12 -4
- data/app/models/role.rb +2 -2
- data/app/models/shipment.rb +21 -2
- data/app/models/tax_category.rb +8 -0
- data/app/models/taxon.rb +8 -0
- data/app/models/user.rb +2 -3
- data/app/models/variant.rb +18 -13
- data/config/boot.rb +1 -5
- data/config/cucumber.yml +7 -0
- data/config/database.yml +20 -37
- data/config/database.yml.example +5 -6
- data/config/environment.rb +6 -5
- data/config/environments/cucumber.rb +30 -0
- data/config/environments/production.rb +1 -4
- data/config/environments/staging.rb +3 -0
- data/config/environments/test.rb +1 -1
- data/config/initializers/cookie_verification_secret.rb +7 -0
- data/config/initializers/locales.rb +4 -2
- data/config/initializers/new_rails_defaults.rb +2 -0
- data/config/initializers/spree.rb +1 -0
- data/config/initializers/workarounds_for_ruby19.rb +0 -25
- data/config/locales/{en-US.yml → en_spree.yml} +18 -4
- data/config/routes.rb +2 -1
- data/db/migrate/20100317120946_add_alt_text_to_images.rb +9 -0
- data/db/migrate/20100427121301_add_display_to_payment_methods.rb +9 -0
- data/db/migrate/20100504142133_add_addresses_checkouts_indexes.rb +16 -0
- data/db/migrate/20100506180619_add_icon_to_taxons.rb +18 -0
- data/db/migrate/20100506185838_add_description_to_taxons.rb +11 -0
- data/db/migrate/20100528155333_index_for_shipments_number.rb +9 -0
- data/db/migrate/20100528185820_add_index_on_users_persistence_token.rb +9 -0
- data/db/migrate/20100605152042_add_default_to_tax_categories.rb +9 -0
- data/db/sample/payment_methods.yml +8 -1
- data/db/sample/shipments.yml +2 -2
- data/db/schema.rb +54 -21
- data/features/checkout.feature +98 -0
- data/features/create_admin_user.feature +18 -0
- data/features/search.feature +35 -0
- data/features/sign_in.feature +25 -0
- data/features/sign_out.feature +12 -0
- data/features/sign_up.feature +20 -0
- data/features/step_definitions/error_steps.rb +3 -0
- data/features/step_definitions/model_steps.rb +3 -0
- data/features/step_definitions/pickle_steps.rb +73 -0
- data/features/step_definitions/role_steps.rb +8 -0
- data/features/step_definitions/session_steps.rb +14 -0
- data/features/step_definitions/user_steps.rb +67 -0
- data/features/step_definitions/web_steps.rb +197 -0
- data/features/support/create_admin_user.rb +6 -0
- data/features/support/env.rb +89 -0
- data/features/support/paths.rb +32 -0
- data/features/support/pickle.rb +24 -0
- data/features/work_with_cart.feature +41 -0
- data/lib/generators/extension_model/extension_model_generator.rb +10 -10
- data/lib/generators/instance/templates/databases/mysql.yml +11 -0
- data/lib/scopes/variant.rb +10 -0
- data/lib/spree.rb +3 -3
- data/lib/spree/extensions.rb +1 -1
- data/lib/tasks/cucumber.rake +47 -0
- data/lib/tasks/database.rake +29 -29
- data/public/images/admin/bg/spree_50.png +0 -0
- data/public/images/tile-header.png +0 -0
- data/public/images/tile-slider.png +0 -0
- data/public/javascripts/admin/checkouts/edit.js +33 -0
- data/public/javascripts/dashboard.js +2 -2
- data/public/javascripts/taxonomy.js +2 -2
- data/public/stylesheets/admin/admin-tables.css +4 -0
- data/public/stylesheets/admin/admin.css +31 -16
- data/public/stylesheets/screen.css +16 -3
- data/script/about +3 -2
- data/script/console +2 -2
- data/script/cucumber +10 -0
- data/script/dbconsole +1 -1
- data/script/destroy +2 -2
- data/script/generate +2 -2
- data/script/performance/benchmarker +1 -1
- data/script/performance/profiler +1 -1
- data/script/plugin +2 -2
- data/script/runner +2 -2
- data/script/server +2 -2
- data/test/fixtures/payment_methods.yml +12 -0
- data/test/functional/admin/checkouts_controller_test.rb +0 -2
- data/test/functional/admin/line_items_controller_test.rb +78 -39
- data/test/functional/admin/products_controller_test.rb +4 -5
- data/test/integration/checkout_test.rb +1 -0
- data/test/test_helper.rb +114 -86
- data/test/unit/creditcard_test.rb +28 -7
- data/test/unit/flexi_rate_calculator_test.rb +75 -0
- data/test/unit/helpers/products_helper_test.rb +4 -4
- data/test/unit/inventory_unit_test.rb +39 -5
- data/test/unit/line_item_test.rb +60 -1
- data/test/unit/order_state_test.rb +85 -58
- data/test/unit/order_test.rb +144 -123
- data/test/unit/product_test.rb +21 -0
- data/test/unit/return_authorization_test.rb +22 -28
- data/test/unit/shipment_test.rb +19 -7
- data/test/unit/variant_test.rb +100 -24
- data/vendor/extensions/api/api_extension.rb +2 -2
- data/vendor/extensions/api/app/controllers/api/base_controller.rb +14 -6
- data/vendor/extensions/api/app/controllers/api/countries_controller.rb +4 -0
- data/vendor/extensions/api/app/controllers/api/orders_controller.rb +4 -4
- data/vendor/extensions/api/app/controllers/api/products_controller.rb +5 -1
- data/vendor/extensions/api/app/controllers/api/shipments_controller.rb +7 -7
- data/vendor/extensions/api/app/controllers/api/states_controller.rb +5 -0
- data/vendor/extensions/api/config/locales/{en-US.yml → en.yml} +2 -2
- data/vendor/extensions/api/config/routes.rb +5 -0
- data/vendor/extensions/api/test/integration/orders_api_test.rb +4 -4
- data/vendor/extensions/overview_dashboard/app/views/admin/overview/index.html.erb +1 -1
- data/vendor/extensions/payment_gateway/app/models/gateway.rb +1 -1
- data/vendor/extensions/payment_gateway/app/models/gateway/authorize_net_cim.rb +41 -29
- data/vendor/extensions/payment_gateway/app/models/gateway/bogus.rb +3 -3
- data/vendor/extensions/payment_gateway/app/models/gateway/eway.rb +11 -0
- data/vendor/extensions/payment_gateway/app/models/gateway/sage_pay.rb +9 -0
- data/vendor/extensions/payment_gateway/config/locales/{en-US.yml → en.yml} +1 -1
- data/vendor/extensions/payment_gateway/lib/spree/payment_gateway.rb +46 -56
- data/vendor/extensions/payment_gateway/payment_gateway_extension.rb +9 -10
- data/vendor/extensions/payment_gateway/test/unit/authorize_net_cim_test.rb +7 -6
- data/vendor/extensions/theme_default/app/stylesheets/_checkout.less +10 -3
- data/vendor/extensions/theme_default/app/views/admin/adjustments/index.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/checkouts/_form.html.erb +31 -5
- data/vendor/extensions/theme_default/app/views/admin/checkouts/show.html.erb +27 -16
- data/vendor/extensions/theme_default/app/views/admin/images/_form.html.erb +4 -0
- data/vendor/extensions/theme_default/app/views/admin/images/index.html.erb +16 -13
- data/vendor/extensions/theme_default/app/views/admin/orders/_add_product.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/orders/_form.html.erb +7 -0
- data/vendor/extensions/theme_default/app/views/admin/orders/index.html.erb +5 -5
- data/vendor/extensions/theme_default/app/views/admin/payment_methods/_form.html.erb +12 -6
- data/vendor/extensions/theme_default/app/views/admin/payment_methods/index.html.erb +22 -11
- data/vendor/extensions/theme_default/app/views/admin/product_groups/update.js.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/products/_form.html.erb +6 -4
- data/vendor/extensions/theme_default/app/views/admin/shared/_address_form.html.erb +64 -55
- data/vendor/extensions/theme_default/app/views/admin/shared/_configuration_menu.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/shared/_order_tabs.html.erb +11 -3
- data/vendor/extensions/theme_default/app/views/admin/shared/_product_tabs.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/shipments/_form.html.erb +32 -29
- data/vendor/extensions/theme_default/app/views/admin/shipments/index.html.erb +2 -1
- data/vendor/extensions/theme_default/app/views/admin/tax_categories/_form.html.erb +6 -3
- data/vendor/extensions/theme_default/app/views/admin/tax_categories/index.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_taxon.html.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/taxons/_form.html.erb +11 -1
- data/vendor/extensions/theme_default/app/views/admin/taxons/edit.html.erb +2 -2
- data/vendor/extensions/theme_default/app/views/admin/users/_form.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/admin/variants/_form.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/checkouts/_confirm.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/checkouts/_delivery.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/checkouts/_summary.html.erb +6 -6
- data/vendor/extensions/theme_default/app/views/checkouts/edit.html.erb +3 -3
- data/vendor/extensions/theme_default/app/views/layouts/admin.html.erb +7 -5
- data/vendor/extensions/theme_default/app/views/layouts/spree_application.html.erb +8 -4
- data/vendor/extensions/theme_default/app/views/orders/_line_item.html.erb +1 -1
- data/vendor/extensions/theme_default/app/views/products/index.html.erb +0 -1
- data/vendor/extensions/theme_default/app/views/shared/_footer.html.erb +4 -2
- data/vendor/extensions/theme_default/app/views/shared/_products.html.erb +3 -1
- data/vendor/extensions/theme_default/app/views/shared/_user_form.html.erb +1 -1
- data/vendor/extensions/theme_default/public/images/admin/bg/spree_50.png +0 -0
- data/vendor/extensions/theme_default/public/images/tile-header.png +0 -0
- data/vendor/extensions/theme_default/public/images/tile-slider.png +0 -0
- data/vendor/extensions/theme_default/public/javascripts/admin/checkouts/edit.js +50 -0
- data/vendor/extensions/theme_default/public/javascripts/taxonomy.js +2 -2
- data/vendor/extensions/theme_default/public/stylesheets/admin/admin-tables.css +8 -0
- data/vendor/extensions/theme_default/public/stylesheets/admin/admin.css +31 -16
- data/vendor/extensions/theme_default/public/stylesheets/screen.css +16 -3
- data/vendor/plugins/attribute_fu/{tasks → lib/tasks}/attribute_fu_tasks.rake +0 -0
- data/vendor/plugins/enumerable_constants/{tasks → lib/tasks}/enumerable_constants_tasks.rake +0 -0
- data/vendor/plugins/find_by_param/lib/find_by_param.rb +9 -5
- data/vendor/plugins/find_by_param/{tasks → lib/tasks}/find_by_param_tasks.rake +0 -0
- data/vendor/plugins/jrails/{tasks → lib/tasks}/jrails.rake +0 -0
- data/vendor/plugins/jrails_auto_complete/{tasks → lib/tasks}/jrails_auto_complete_tasks.rake +0 -0
- data/vendor/plugins/mail_queue/{tasks → lib/tasks}/mailer_queue_tasks.rake +0 -0
- data/vendor/plugins/open_id_authentication/{tasks → lib/tasks}/open_id_authentication_tasks.rake +0 -0
- data/vendor/plugins/resource_controller/lib/resource_controller/helpers/internal.rb +2 -2
- data/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb +7 -7
- data/vendor/plugins/unobtrusive_date_picker/{tasks → lib/tasks}/datepicker_tasks.rake +0 -0
- metadata +82 -342
- data/app/helpers/admin/adjustments_helper.rb +0 -2
- data/app/helpers/admin/checkouts_helper.rb +0 -2
- data/app/helpers/admin/line_items_helper.rb +0 -2
- data/app/helpers/admin/properties_helper.rb +0 -9
- data/app/helpers/admin/prototypes_helper.rb +0 -18
- data/app/helpers/admin/return_authorizations_helper.rb +0 -2
- data/config/locales/cs-CZ.yml +0 -924
- data/config/locales/cs-CZ_rails.yml +0 -202
- data/config/locales/da.yml +0 -924
- data/config/locales/da_rails.yml +0 -197
- data/config/locales/de-CH.yml +0 -924
- data/config/locales/de-CH_rails.yml +0 -142
- data/config/locales/de.yml +0 -924
- data/config/locales/de_rails.yml +0 -140
- data/config/locales/en-AU.yml +0 -924
- data/config/locales/en-AU_rails.yml +0 -202
- data/config/locales/en-GB.yml +0 -924
- data/config/locales/en-GB_rails.yml +0 -196
- data/config/locales/en-US_rails.yml +0 -200
- data/config/locales/es.yml +0 -924
- data/config/locales/es_rails.yml +0 -173
- data/config/locales/fi.yml +0 -924
- data/config/locales/fi_rails.yml +0 -143
- data/config/locales/fr-FR.yml +0 -924
- data/config/locales/fr-FR_rails.yml +0 -123
- data/config/locales/il.yml +0 -924
- data/config/locales/il_rails.yml +0 -103
- data/config/locales/it.yml +0 -924
- data/config/locales/it_rails.yml +0 -146
- data/config/locales/jp.yml +0 -924
- data/config/locales/jp_rails.yml +0 -135
- data/config/locales/mx.yml +0 -924
- data/config/locales/mx_rails.yml +0 -181
- data/config/locales/nb-NO.yml +0 -924
- data/config/locales/nb-NO_rails.yml +0 -105
- data/config/locales/nl-BE.yml +0 -924
- data/config/locales/nl-BE_rails.yml +0 -155
- data/config/locales/nl-NL.yml +0 -924
- data/config/locales/nl-NL_rails.yml +0 -172
- data/config/locales/pl.yml +0 -924
- data/config/locales/pl_rails.yml +0 -118
- data/config/locales/pt-BR.yml +0 -924
- data/config/locales/pt-BR_rails.yml +0 -138
- data/config/locales/pt-PT.yml +0 -924
- data/config/locales/pt-PT_rails.yml +0 -133
- data/config/locales/ru-RU.yml +0 -924
- data/config/locales/ru-RU_rails.yml +0 -206
- data/config/locales/th.yml +0 -924
- data/config/locales/th_rails.yml +0 -195
- data/config/locales/vn.yml +0 -924
- data/config/locales/vn_rails.yml +0 -202
- data/lib/tasks/translation.rake +0 -102
- data/vendor/extensions/localization/README.rdoc +0 -5
- data/vendor/extensions/localization/Rakefile +0 -120
- data/vendor/extensions/localization/app/controllers/admin/localization_controller.rb +0 -2
- data/vendor/extensions/localization/app/helpers/locale_helper.rb +0 -2
- data/vendor/extensions/localization/app/helpers/localization_helper.rb +0 -2
- data/vendor/extensions/localization/app/views/shared/_language_bar.html.erb +0 -8
- data/vendor/extensions/localization/config/routes.rb +0 -4
- data/vendor/extensions/localization/lib/localization/user_preferences.rb +0 -9
- data/vendor/extensions/localization/lib/tasks/localization_extension_tasks.rake +0 -17
- data/vendor/extensions/localization/localization_extension.rb +0 -21
- data/vendor/extensions/localization/public/images/flags/ad.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ae.png +0 -0
- data/vendor/extensions/localization/public/images/flags/af.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ag.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ai.png +0 -0
- data/vendor/extensions/localization/public/images/flags/al.png +0 -0
- data/vendor/extensions/localization/public/images/flags/am.png +0 -0
- data/vendor/extensions/localization/public/images/flags/an.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ao.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ar.png +0 -0
- data/vendor/extensions/localization/public/images/flags/as.png +0 -0
- data/vendor/extensions/localization/public/images/flags/at.png +0 -0
- data/vendor/extensions/localization/public/images/flags/au.png +0 -0
- data/vendor/extensions/localization/public/images/flags/aw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ax.png +0 -0
- data/vendor/extensions/localization/public/images/flags/az.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ba.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/be.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/br.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/by.png +0 -0
- data/vendor/extensions/localization/public/images/flags/bz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ca.png +0 -0
- data/vendor/extensions/localization/public/images/flags/catalonia.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ch.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ci.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ck.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/co.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cx.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/cz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/da.png +0 -0
- data/vendor/extensions/localization/public/images/flags/de.png +0 -0
- data/vendor/extensions/localization/public/images/flags/de_CH.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/do.png +0 -0
- data/vendor/extensions/localization/public/images/flags/dz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ec.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ee.png +0 -0
- data/vendor/extensions/localization/public/images/flags/eg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/eh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/england.png +0 -0
- data/vendor/extensions/localization/public/images/flags/er.png +0 -0
- data/vendor/extensions/localization/public/images/flags/es.png +0 -0
- data/vendor/extensions/localization/public/images/flags/et.png +0 -0
- data/vendor/extensions/localization/public/images/flags/europeanunion.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fam.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/fr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ga.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ge.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/gy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ht.png +0 -0
- data/vendor/extensions/localization/public/images/flags/hu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/id.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ie.png +0 -0
- data/vendor/extensions/localization/public/images/flags/il.png +0 -0
- data/vendor/extensions/localization/public/images/flags/in.png +0 -0
- data/vendor/extensions/localization/public/images/flags/io.png +0 -0
- data/vendor/extensions/localization/public/images/flags/iq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ir.png +0 -0
- data/vendor/extensions/localization/public/images/flags/is.png +0 -0
- data/vendor/extensions/localization/public/images/flags/it.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/jp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ke.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ki.png +0 -0
- data/vendor/extensions/localization/public/images/flags/km.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ky.png +0 -0
- data/vendor/extensions/localization/public/images/flags/kz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/la.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/li.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ls.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/lv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ly.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ma.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/md.png +0 -0
- data/vendor/extensions/localization/public/images/flags/me.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ml.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mo.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mp.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mq.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ms.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mx.png +0 -0
- data/vendor/extensions/localization/public/images/flags/my.png +0 -0
- data/vendor/extensions/localization/public/images/flags/mz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/na.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ne.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ng.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ni.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/no.png +0 -0
- data/vendor/extensions/localization/public/images/flags/np.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/nz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/om.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pe.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ph.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ps.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/pw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/py.png +0 -0
- data/vendor/extensions/localization/public/images/flags/qa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/re.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ro.png +0 -0
- data/vendor/extensions/localization/public/images/flags/rs.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ru.png +0 -0
- data/vendor/extensions/localization/public/images/flags/rw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sa.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sb.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/scotland.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sd.png +0 -0
- data/vendor/extensions/localization/public/images/flags/se.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sh.png +0 -0
- data/vendor/extensions/localization/public/images/flags/si.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/so.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/st.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/sz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/td.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/th.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tj.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tk.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tl.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/to.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tr.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tv.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tw.png +0 -0
- data/vendor/extensions/localization/public/images/flags/tz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ua.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ug.png +0 -0
- data/vendor/extensions/localization/public/images/flags/um.png +0 -0
- data/vendor/extensions/localization/public/images/flags/us.png +0 -0
- data/vendor/extensions/localization/public/images/flags/uy.png +0 -0
- data/vendor/extensions/localization/public/images/flags/uz.png +0 -0
- data/vendor/extensions/localization/public/images/flags/va.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vc.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ve.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vg.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vi.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vn.png +0 -0
- data/vendor/extensions/localization/public/images/flags/vu.png +0 -0
- data/vendor/extensions/localization/public/images/flags/wales.png +0 -0
- data/vendor/extensions/localization/public/images/flags/wf.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ws.png +0 -0
- data/vendor/extensions/localization/public/images/flags/ye.png +0 -0
- data/vendor/extensions/localization/public/images/flags/yt.png +0 -0
- data/vendor/extensions/localization/public/images/flags/za.png +0 -0
- data/vendor/extensions/localization/public/images/flags/zm.png +0 -0
- data/vendor/extensions/localization/public/images/flags/zw.png +0 -0
- data/vendor/extensions/localization/spec/controllers/admin/localization_controller_spec.rb +0 -10
- data/vendor/extensions/localization/spec/controllers/locale_controller_spec.rb +0 -35
- data/vendor/extensions/localization/spec/helpers/locale_helper_spec.rb +0 -5
- data/vendor/extensions/localization/spec/helpers/localization_helper_spec.rb +0 -5
- data/vendor/extensions/localization/spec/spec.opts +0 -6
- data/vendor/extensions/localization/spec/spec_helper.rb +0 -37
- data/vendor/extensions/payment_gateway/app/models/gateway/protx.rb +0 -9
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_manage_products.rhtml +0 -31
- data/vendor/extensions/theme_default/app/views/admin/taxonomies/_success.rhtml +0 -1
data/test/unit/line_item_test.rb
CHANGED
@@ -25,6 +25,10 @@ class LineItemTest < ActiveSupport::TestCase
|
|
25
25
|
should "return the correct total" do
|
26
26
|
assert_in_delta @line_item.total, 30.00, 0.00001
|
27
27
|
end
|
28
|
+
|
29
|
+
should "allow line item to be destroyed" do
|
30
|
+
assert @line_item.destroy
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
context "when variant is out of stock" do
|
@@ -44,6 +48,21 @@ class LineItemTest < ActiveSupport::TestCase
|
|
44
48
|
assert !@line_item.valid?
|
45
49
|
end
|
46
50
|
end
|
51
|
+
|
52
|
+
context "when tracking inventory levels" do
|
53
|
+
setup { Spree::Config.set(:track_inventory_levels => true) }
|
54
|
+
should "not be valid" do
|
55
|
+
assert @line_item.valid?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when not tracking inventory levels" do
|
60
|
+
setup { Spree::Config.set(:track_inventory_levels => false) }
|
61
|
+
teardown { Spree::Config.set(:track_inventory_levels => true) }
|
62
|
+
should "be valid" do
|
63
|
+
assert @line_item.valid?
|
64
|
+
end
|
65
|
+
end
|
47
66
|
end
|
48
67
|
|
49
68
|
context "when variant is in stock but insufficient to cover the requested quantity" do
|
@@ -56,7 +75,7 @@ class LineItemTest < ActiveSupport::TestCase
|
|
56
75
|
setup do
|
57
76
|
Spree::Config.set(:allow_backorders => true)
|
58
77
|
end
|
59
|
-
should "
|
78
|
+
should "be valid" do
|
60
79
|
assert @line_item.valid?
|
61
80
|
end
|
62
81
|
end
|
@@ -68,6 +87,46 @@ class LineItemTest < ActiveSupport::TestCase
|
|
68
87
|
assert !@line_item.valid?
|
69
88
|
end
|
70
89
|
end
|
90
|
+
|
91
|
+
context "when tracking inventory levels" do
|
92
|
+
setup { Spree::Config.set(:track_inventory_levels => true) }
|
93
|
+
should "not be valid" do
|
94
|
+
assert @line_item.valid?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when not tracking inventory levels" do
|
99
|
+
setup { Spree::Config.set(:track_inventory_levels => false) }
|
100
|
+
teardown { Spree::Config.set(:track_inventory_levels => true) }
|
101
|
+
should "be valid" do
|
102
|
+
assert @line_item.valid?
|
103
|
+
end
|
104
|
+
end
|
71
105
|
end
|
72
106
|
|
107
|
+
context "when order is completely shipped" do
|
108
|
+
setup do
|
109
|
+
@order = Order.create!
|
110
|
+
@line_item = Factory.build(:line_item, :quantity => 2, :price => 15.00, :order => @order)
|
111
|
+
@order.line_items << @line_item
|
112
|
+
@order.complete!
|
113
|
+
@order.pay!
|
114
|
+
@order.ship!
|
115
|
+
end
|
116
|
+
|
117
|
+
should "not allow line item to be destroyed" do
|
118
|
+
assert !@line_item.destroy
|
119
|
+
end
|
120
|
+
|
121
|
+
context "and line_item quantity is decreased" do
|
122
|
+
setup do
|
123
|
+
@line_item.quantity = 1
|
124
|
+
end
|
125
|
+
|
126
|
+
should "not be valid" do
|
127
|
+
assert !@line_item.valid?
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
73
132
|
end
|
@@ -1,82 +1,109 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class OrderStateTest < ActiveSupport::TestCase
|
4
|
+
should "be in_progress initially" do
|
5
|
+
assert Order.new.in_progress?
|
6
|
+
end
|
4
7
|
context "Order" do
|
5
|
-
|
6
|
-
@order =
|
7
|
-
@order.
|
8
|
-
|
9
|
-
|
10
|
-
@order.
|
11
|
-
|
12
|
-
@order.
|
13
|
-
@order.save
|
14
|
-
|
15
|
-
@checkout.payment.update_attributes(:payable => @order, :amount => @order.total)
|
16
|
-
|
17
|
-
#make sure totals get recalculated
|
18
|
-
@order.reload
|
19
|
-
@order.save
|
20
|
-
end
|
21
|
-
|
22
|
-
should "be in_progress initally" do
|
23
|
-
assert @order.in_progress?
|
8
|
+
setup do
|
9
|
+
@order = Order.create!
|
10
|
+
@order.line_items << Factory(:line_item,:order=>@order,:price=>100, :quantity=>5)
|
11
|
+
@order.checkout.ship_address = Factory(:address)
|
12
|
+
@order.checkout.shipping_method = Factory(:shipping_method)
|
13
|
+
@order.update_totals
|
14
|
+
@order.payments = [Factory(:payment, :payable=>@order, :amount=>500)]
|
15
|
+
@order.save!
|
24
16
|
end
|
25
17
|
|
26
18
|
context "with a complete checkout and payment" do
|
27
|
-
setup do
|
19
|
+
setup do
|
28
20
|
@order.complete!
|
29
21
|
@order.update_totals!
|
30
22
|
end
|
31
23
|
|
32
24
|
should_change("@order.state", :from => "in_progress", :to => "new") { @order.state }
|
33
|
-
|
25
|
+
|
34
26
|
should "allow cancel" do
|
35
27
|
assert @order.can_cancel?
|
36
28
|
end
|
37
|
-
|
29
|
+
|
38
30
|
should "not allow resume" do
|
39
31
|
assert !@order.can_resume?
|
40
32
|
end
|
41
|
-
|
33
|
+
|
42
34
|
context "when canceled" do
|
43
35
|
setup do
|
44
36
|
@order.cancel!
|
45
37
|
end
|
46
|
-
|
38
|
+
|
47
39
|
should_change("@order.state", :from => "new", :to => "canceled") { @order.state }
|
48
|
-
|
40
|
+
should_change("@order.inventory_units.size", :to => 0) { @order.inventory_units.size }
|
41
|
+
|
42
|
+
should "change all shipments to pending" do
|
43
|
+
assert @order.shipments.all?(&:pending?)
|
44
|
+
end
|
45
|
+
|
49
46
|
should "allow resume" do
|
50
47
|
assert @order.can_resume?
|
51
48
|
end
|
52
|
-
|
49
|
+
|
53
50
|
context "and then resumed" do
|
54
51
|
setup do
|
55
52
|
@order.resume!
|
56
53
|
end
|
57
|
-
|
54
|
+
|
58
55
|
should_change("@order.state", :from => "canceled", :to => "new") { @order.state }
|
56
|
+
|
57
|
+
should "all shipments still be pending" do
|
58
|
+
assert @order.shipments.all?(&:pending?)
|
59
|
+
end
|
59
60
|
end
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
context "when paid" do
|
63
64
|
setup do
|
64
65
|
@order.pay!
|
65
66
|
end
|
66
|
-
|
67
|
+
|
67
68
|
should "allow ship" do
|
68
69
|
assert @order.can_ship?
|
69
70
|
end
|
70
|
-
|
71
|
+
|
72
|
+
context "and canceled" do
|
73
|
+
setup do
|
74
|
+
@order.cancel!
|
75
|
+
end
|
76
|
+
|
77
|
+
should_change("@order.state", :from => "paid", :to => "canceled") { @order.state }
|
78
|
+
should_change("@order.inventory_units.size", :to => 0) { @order.inventory_units.size }
|
79
|
+
|
80
|
+
should "change all shipments to pending" do
|
81
|
+
assert @order.shipments.all?(&:pending?)
|
82
|
+
end
|
83
|
+
|
84
|
+
context "and then resumed" do
|
85
|
+
setup do
|
86
|
+
@order.resume!
|
87
|
+
@order.shipments.reload
|
88
|
+
end
|
89
|
+
|
90
|
+
should_change("@order.state", :from => "canceled", :to => "paid") { @order.state }
|
91
|
+
|
92
|
+
should "change all shipments to ready_to_ship" do
|
93
|
+
assert @order.shipments.all?(&:ready_to_ship?)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
71
98
|
context "and all shipments are shipped" do
|
72
99
|
setup do
|
73
100
|
shipment = @order.shipment.reload
|
74
101
|
shipment.ship!
|
75
102
|
@order.reload
|
76
103
|
end
|
77
|
-
|
104
|
+
|
78
105
|
should_change("@order.state", :from => "paid", :to => "shipped") { @order.state }
|
79
|
-
|
106
|
+
|
80
107
|
context "and a return_authorization with all inventory_units returned" do
|
81
108
|
setup do
|
82
109
|
ra = ReturnAuthorization.new(:order => @order, :amount => 50.00)
|
@@ -84,31 +111,31 @@ class OrderStateTest < ActiveSupport::TestCase
|
|
84
111
|
ra.save!
|
85
112
|
@order.reload
|
86
113
|
end
|
87
|
-
|
114
|
+
|
88
115
|
should_change("@order.state", :from => "shipped", :to => "awaiting_return") { @order.state }
|
89
|
-
|
116
|
+
|
90
117
|
context "and received" do
|
91
118
|
setup do
|
92
119
|
@order.return_authorizations.first.receive!
|
93
120
|
@order.reload
|
94
121
|
end
|
95
|
-
|
122
|
+
|
96
123
|
should_change("@order.state", :from => "awaiting_return", :to => "credit_owed") { @order.state }
|
97
|
-
|
124
|
+
|
98
125
|
context "and a negative payment is created" do
|
99
|
-
setup do
|
126
|
+
setup do
|
100
127
|
@order.payments.create!(:amount => -50.00, :payment_method => Gateway.current)
|
101
128
|
#@creditcard.credit(50.00, @creditcard.authorization)
|
102
129
|
@order.reload
|
103
130
|
end
|
104
|
-
|
131
|
+
|
105
132
|
should_change("@order.state", :from => "credit_owed", :to => "returned") { @order.state }
|
106
133
|
end
|
107
|
-
|
134
|
+
|
108
135
|
end
|
109
|
-
|
136
|
+
|
110
137
|
end
|
111
|
-
|
138
|
+
|
112
139
|
context "and a return_authorization with not all inventory_units are returned is created" do
|
113
140
|
setup do
|
114
141
|
ra = ReturnAuthorization.new(:order => @order, :amount => 50.00)
|
@@ -116,33 +143,33 @@ class OrderStateTest < ActiveSupport::TestCase
|
|
116
143
|
ra.save!
|
117
144
|
@order.reload
|
118
145
|
end
|
119
|
-
|
146
|
+
|
120
147
|
should_change("@order.state", :from => "shipped", :to => "awaiting_return") { @order.state }
|
121
|
-
|
148
|
+
|
122
149
|
context "and received" do
|
123
150
|
setup do
|
124
151
|
@order.return_authorizations.first.receive!
|
125
152
|
@order.reload
|
126
153
|
end
|
127
|
-
|
154
|
+
|
128
155
|
should_change("@order.state", :from => "awaiting_return", :to => "credit_owed") { @order.state }
|
129
|
-
|
156
|
+
|
130
157
|
context "and a negative payment is created" do
|
131
|
-
setup do
|
158
|
+
setup do
|
132
159
|
@order.payments.create!(:amount => -50.00, :payment_method => Gateway.current)
|
133
160
|
@order.reload
|
134
161
|
end
|
135
|
-
|
162
|
+
|
136
163
|
should_change("@order.state", :from => "credit_owed", :to => "shipped") { @order.state }
|
137
164
|
end
|
138
|
-
|
165
|
+
|
139
166
|
end
|
140
|
-
|
167
|
+
|
141
168
|
end
|
142
|
-
|
169
|
+
|
143
170
|
end
|
144
|
-
|
145
|
-
|
171
|
+
|
172
|
+
|
146
173
|
context "and an additional charge is added" do
|
147
174
|
setup do
|
148
175
|
@credit = Factory(:charge, :amount => 3.00, :order => @order)
|
@@ -156,12 +183,12 @@ class OrderStateTest < ActiveSupport::TestCase
|
|
156
183
|
setup do
|
157
184
|
Factory(:payment, :payable => @order, :amount => 3.00)
|
158
185
|
end
|
159
|
-
|
186
|
+
|
160
187
|
should_change("@order.state", :from => "balance_due", :to => "paid") { @order.state }
|
161
188
|
end
|
162
189
|
|
163
190
|
end
|
164
|
-
|
191
|
+
|
165
192
|
|
166
193
|
context "and an additional credit is added" do
|
167
194
|
setup do
|
@@ -173,16 +200,16 @@ class OrderStateTest < ActiveSupport::TestCase
|
|
173
200
|
should_change("@order.state", :from => "paid", :to => "credit_owed") { @order.state }
|
174
201
|
|
175
202
|
context "and a negative payment is created" do
|
176
|
-
setup do
|
203
|
+
setup do
|
177
204
|
@order.payments.create!(:amount => -2.00, :payment_method => Gateway.current)
|
178
|
-
@order.update_totals!
|
205
|
+
@order.update_totals!
|
179
206
|
@order.reload
|
180
|
-
end
|
207
|
+
end
|
181
208
|
should_change("@order.state", :from => "credit_owed", :to => "paid") { @order.state }
|
182
209
|
end
|
183
210
|
|
184
211
|
end
|
185
|
-
|
212
|
+
|
186
213
|
end
|
187
214
|
|
188
215
|
|
data/test/unit/order_test.rb
CHANGED
@@ -4,157 +4,178 @@ require 'test_helper'
|
|
4
4
|
# check seslling units / restocking
|
5
5
|
|
6
6
|
class OrderTest < ActiveSupport::TestCase
|
7
|
-
context "create" do
|
8
|
-
setup { Order.create }
|
9
|
-
should_change("Checkout.count", :by => 1) { Checkout.count }
|
10
|
-
end
|
11
|
-
|
12
7
|
context "Order" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
should "remove line items if quantity drops to 0" do
|
24
|
-
@order.save # wipe any accidental zeros
|
25
|
-
l = @order.line_items.length
|
26
|
-
@order.line_items.first.update_attribute(:quantity, 0)
|
27
|
-
@order.save
|
28
|
-
assert_equal(l-1, @order.line_items.length)
|
29
|
-
end
|
30
|
-
|
31
|
-
should "update totals" do
|
32
|
-
@order.item_total = nil
|
33
|
-
@order.adjustment_total = nil
|
34
|
-
@order.total = nil
|
35
|
-
@order.update_totals
|
36
|
-
assert_not_nil(@order.item_total)
|
37
|
-
assert_not_nil(@order.charge_total)
|
38
|
-
assert_not_nil(@order.total)
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when line_items change" do
|
42
|
-
setup do
|
43
|
-
@first_price = @order.line_items.first.price
|
44
|
-
@order.line_items.first.update_attribute(:quantity, @order.line_items.first.quantity + 1)
|
45
|
-
@order.save
|
8
|
+
should_have_many :line_items
|
9
|
+
|
10
|
+
context "#create" do
|
11
|
+
setup { @order = Order.create! }
|
12
|
+
should_change("Checkout.count", :by => 1) { Checkout.count }
|
13
|
+
should "generate token" do
|
14
|
+
assert !@order.token.blank?
|
15
|
+
end
|
16
|
+
should "create default tax charge" do
|
17
|
+
assert !@order.tax_charges.empty?
|
46
18
|
end
|
47
|
-
should_change("item total", :by => @first_price) { @order.item_total }
|
48
19
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
20
|
+
|
21
|
+
context "#update_totals" do
|
22
|
+
should "update totals" do
|
23
|
+
order = Order.create!
|
24
|
+
order.item_total = nil
|
25
|
+
order.adjustment_total = nil
|
26
|
+
order.total = nil
|
27
|
+
order.update_totals
|
28
|
+
assert_not_nil order.item_total
|
29
|
+
assert_not_nil order.charge_total
|
30
|
+
assert_not_nil order.total
|
31
|
+
end
|
52
32
|
end
|
53
|
-
|
54
|
-
context "
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
should "update
|
64
|
-
|
33
|
+
|
34
|
+
context "#save" do
|
35
|
+
should "remove line items if quantity drops to 0" do
|
36
|
+
order = Order.create!
|
37
|
+
order.line_items << [Factory(:line_item, :order=>order),Factory(:line_item, :order=>order)]
|
38
|
+
assert order.line_items.length == 2
|
39
|
+
order.line_items.first.quantity = 0
|
40
|
+
order.save!
|
41
|
+
assert order.line_items.length == 1
|
42
|
+
end
|
43
|
+
should "update item_total when line_item quantity changes" do
|
44
|
+
order = Order.create!
|
45
|
+
line_item = Factory(:line_item, :price=>111, :quantity=>1, :order=>order)
|
46
|
+
order.line_items << line_item
|
47
|
+
order.save!
|
48
|
+
assert_equal 111,order.item_total
|
49
|
+
|
50
|
+
line_item.quantity = 2
|
51
|
+
order.save!
|
52
|
+
assert_equal 222, order.item_total
|
65
53
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
54
|
+
should "create shipment with pending state" do
|
55
|
+
order = Order.new
|
56
|
+
assert order.shipments.empty?
|
57
|
+
order.save!
|
58
|
+
assert !order.shipments.empty?
|
59
|
+
assert_equal 'pending', order.shipments.first.state
|
71
60
|
end
|
72
|
-
|
73
61
|
context "with empty stock" do
|
74
|
-
setup do
|
75
|
-
line_item = @order.line_items.first
|
76
|
-
num_left = line_item.variant.inventory_units.with_state("on_hand").count
|
77
|
-
InventoryUnit.destroy_on_hand(line_item.variant, num_left)
|
78
|
-
end
|
79
62
|
should "be able to save order when allow_backorders is off" do
|
63
|
+
order = Order.create!
|
64
|
+
line_item = Factory(:line_item,:order => order)
|
65
|
+
order.line_items << line_item
|
66
|
+
order.complete
|
67
|
+
#let's clear our stock..
|
68
|
+
on_stock_count = line_item.variant.inventory_units.with_state("on_hand").count
|
69
|
+
InventoryUnit.destroy_on_hand(line_item.variant, on_stock_count)
|
70
|
+
#.. and turn backorders off
|
80
71
|
Spree::Config.set(:allow_backorders => false)
|
81
|
-
assert
|
72
|
+
assert order.save!
|
82
73
|
Spree::Config.set(:allow_backorders => true)
|
83
74
|
end
|
84
75
|
end
|
85
76
|
end
|
86
|
-
|
87
|
-
|
77
|
+
context "#complete" do
|
78
|
+
should "change state from in_progress to new" do
|
79
|
+
order = Order.create!
|
80
|
+
assert_equal "in_progress", order.state
|
81
|
+
order.complete!
|
82
|
+
assert_equal "new", order.state
|
83
|
+
end
|
84
|
+
should "update checkout completed_at" do
|
85
|
+
order = Order.create!
|
86
|
+
assert order.completed_at.nil?
|
87
|
+
order.complete!
|
88
|
+
assert !order.completed_at.nil?
|
89
|
+
assert !order.checkout.completed_at.nil?
|
90
|
+
end
|
91
|
+
should "create inventory units" do
|
92
|
+
order = Order.create!
|
93
|
+
order.line_items <<
|
94
|
+
[Factory.build(:line_item, :quantity=>1, :order=>order),
|
95
|
+
Factory.build(:line_item, :quantity=>2, :order=>order)]
|
96
|
+
assert_equal 0, order.inventory_units.count
|
97
|
+
assert_equal 0, order.shipment.inventory_units.count
|
98
|
+
order.complete!
|
99
|
+
assert_equal 3, order.inventory_units.count
|
100
|
+
assert_equal 3, order.shipment.inventory_units.count
|
101
|
+
end
|
102
|
+
end
|
103
|
+
context "#pay!" do
|
88
104
|
should "make all shipments ready" do
|
89
|
-
|
90
|
-
|
91
|
-
|
105
|
+
order = Order.create!
|
106
|
+
order.line_items << Factory(:line_item, :order=>order)
|
107
|
+
order.complete!
|
108
|
+
assert !order.shipments.empty?
|
109
|
+
assert !order.shipments.all?(&:ready_to_ship?)
|
110
|
+
order.pay!
|
111
|
+
assert order.shipments.all?(&:ready_to_ship?)
|
92
112
|
end
|
93
113
|
end
|
94
|
-
|
95
|
-
context "ship!" do
|
114
|
+
context "#ship!" do
|
96
115
|
should "make all shipments shipped" do
|
97
|
-
|
98
|
-
|
99
|
-
|
116
|
+
order = Order.create!
|
117
|
+
order.line_items << Factory(:line_item, :order=>order)
|
118
|
+
order.complete!
|
119
|
+
order.pay!
|
120
|
+
assert !order.shipments.empty?
|
121
|
+
assert !order.shipments.all?(&:shipped?)
|
122
|
+
order.ship!
|
123
|
+
assert order.shipments.all?(&:shipped?)
|
100
124
|
end
|
101
125
|
end
|
102
|
-
|
103
|
-
context "under_paid!" do
|
126
|
+
context "#under_paid!" do
|
104
127
|
should "make all shipments pending" do
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
context "outstanding_balance and outstanding_credit" do
|
115
|
-
setup do
|
116
|
-
@order = Factory(:order)
|
117
|
-
Factory(:line_item, :variant => Factory(:variant, :price => 5.00), :order => @order, :quantity => 1, :price => 5.00)
|
118
|
-
@order.reload
|
119
|
-
@order.save
|
120
|
-
Factory(:payment, :payable => @order, :amount => 2.50)
|
121
|
-
@order.reload
|
122
|
-
@order.save
|
123
|
-
end
|
124
|
-
|
125
|
-
context "with outstanding balance of 2.50" do
|
126
|
-
should "be have outstanding_balance of 2.50" do
|
127
|
-
assert_equal 2.50, @order.outstanding_balance.to_f
|
128
|
-
end
|
129
|
-
should "be have outstanding_credit of 0.00" do
|
130
|
-
assert_equal 0.00, @order.outstanding_credit.to_f
|
128
|
+
order = Order.create!
|
129
|
+
order.line_items << Factory(:line_item, :order=>order)
|
130
|
+
order.complete!
|
131
|
+
order.pay!
|
132
|
+
assert !order.shipments.empty?
|
133
|
+
assert !order.shipments.all?(&:pending?)
|
134
|
+
order.under_paid!
|
135
|
+
assert order.shipments.all?(&:pending?)
|
131
136
|
end
|
132
137
|
end
|
133
|
-
|
134
|
-
context "with outstanding credit of 2.50" do
|
138
|
+
context "" do
|
135
139
|
setup do
|
136
|
-
@order
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
should "be have outstanding_credit of 2.50" do
|
142
|
-
assert_equal 3.00, @order.outstanding_credit.to_f
|
140
|
+
@order = Factory(:line_item, :quantity => 1, :price => 5.00).order
|
141
|
+
@order.reload
|
142
|
+
@order.save
|
143
|
+
Factory(:payment, :payable => @order, :amount => 2.50)
|
144
|
+
@order.reload
|
143
145
|
end
|
144
|
-
end
|
145
146
|
|
146
|
-
|
147
|
-
|
148
|
-
|
147
|
+
context "with partial payment" do
|
148
|
+
should "have #outstanding_balance" do
|
149
|
+
assert_equal 2.50, @order.outstanding_balance.to_f
|
150
|
+
end
|
151
|
+
should "have no #outstanding_credit" do
|
152
|
+
assert_equal 0.00, @order.outstanding_credit.to_f
|
153
|
+
end
|
149
154
|
end
|
150
|
-
|
151
|
-
|
155
|
+
|
156
|
+
context "with extra payment" do
|
157
|
+
setup do
|
158
|
+
@order.payments.first.update_attribute(:amount, 8.00)
|
159
|
+
end
|
160
|
+
should "have no #outstanding_balance" do
|
161
|
+
assert_equal 0.00, @order.outstanding_balance.to_f
|
162
|
+
end
|
163
|
+
should "have #outstanding_credit" do
|
164
|
+
assert_equal 3.00, @order.outstanding_credit.to_f
|
165
|
+
end
|
152
166
|
end
|
153
|
-
|
154
|
-
|
167
|
+
|
168
|
+
context "with exact (full) payment" do
|
169
|
+
setup do
|
170
|
+
@order.payments.first.update_attribute(:amount, 5.00)
|
171
|
+
end
|
172
|
+
should "have no #outstanding_balance" do
|
173
|
+
assert_equal 0.00, @order.outstanding_balance.to_f
|
174
|
+
end
|
175
|
+
should "have no #outstanding_credit" do
|
176
|
+
assert_equal 0.00, @order.outstanding_credit.to_f
|
177
|
+
end
|
155
178
|
end
|
156
179
|
end
|
157
|
-
|
158
180
|
end
|
159
|
-
|
160
181
|
end
|