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/product_test.rb
CHANGED
@@ -154,6 +154,27 @@ class ProductTest < ActiveSupport::TestCase
|
|
154
154
|
should "not have a product id" do
|
155
155
|
assert @product.id.nil?
|
156
156
|
end
|
157
|
+
|
158
|
+
context "when a default tax category is defined" do
|
159
|
+
setup do
|
160
|
+
@tax_category = Factory(:tax_category, :is_default => true)
|
161
|
+
end
|
162
|
+
|
163
|
+
should "return associated tax category" do
|
164
|
+
assert_equal @product.tax_category, TaxCategory.first
|
165
|
+
end
|
166
|
+
|
167
|
+
context "and produt has no tax category" do
|
168
|
+
setup do
|
169
|
+
@product.tax_category = nil
|
170
|
+
@product.save
|
171
|
+
end
|
172
|
+
|
173
|
+
should "return default tax category" do
|
174
|
+
assert_equal @product.tax_category, TaxCategory.find(:first, :conditions => {:is_default => true})
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
157
178
|
end
|
158
179
|
|
159
180
|
context "New Product instantiated with on_hand" do
|
@@ -2,10 +2,14 @@ require 'test_helper.rb'
|
|
2
2
|
|
3
3
|
class ReturnAuthorizationTest < ActiveSupport::TestCase
|
4
4
|
fixtures :payment_methods
|
5
|
-
|
5
|
+
should "be authorized initially" do
|
6
|
+
assert ReturnAuthorization.new.authorized?
|
7
|
+
end
|
8
|
+
|
6
9
|
context "ReturnAuthorization" do
|
7
10
|
setup do
|
8
|
-
|
11
|
+
@order = Order.create!
|
12
|
+
@order.line_items << [Factory(:line_item, :order=>@order),Factory(:line_item, :order=>@order)]
|
9
13
|
|
10
14
|
#complete order / checkout
|
11
15
|
@order.complete!
|
@@ -13,19 +17,12 @@ class ReturnAuthorizationTest < ActiveSupport::TestCase
|
|
13
17
|
|
14
18
|
#@order.pay!
|
15
19
|
@order.update_attribute(:state, 'paid')
|
16
|
-
|
17
|
-
#force shipment to ready_to_ship
|
18
|
-
shipment = @order.shipment
|
19
|
-
shipment.ready!
|
20
20
|
|
21
21
|
@order.reload
|
22
|
-
|
23
|
-
@line_item = @order.line_items.first
|
24
|
-
@return_authorization = ReturnAuthorization.create(:order => @order, :amount => @line_item.total)
|
25
|
-
end
|
22
|
+
@order.shipment.reload #hack for the @order.shipment caching
|
26
23
|
|
27
|
-
|
28
|
-
|
24
|
+
@line_item = @order.line_items.first
|
25
|
+
@return_authorization = ReturnAuthorization.new(:order => @order, :amount => @line_item.total)
|
29
26
|
end
|
30
27
|
|
31
28
|
context "with an order that has no shipped units" do
|
@@ -34,69 +31,66 @@ class ReturnAuthorizationTest < ActiveSupport::TestCase
|
|
34
31
|
assert_not_nil @return_authorization.errors.on(:order)
|
35
32
|
end
|
36
33
|
end
|
37
|
-
|
34
|
+
|
38
35
|
context "with an order that has shipped units" do
|
39
36
|
setup do
|
40
|
-
@return_authorization.order.shipment.order.reload
|
41
|
-
@shipment = @return_authorization.order.shipment
|
42
|
-
|
43
37
|
@return_authorization.order.shipment.ship!
|
44
38
|
@return_authorization.order.reload
|
45
39
|
end
|
46
|
-
|
40
|
+
|
47
41
|
should "be valid" do
|
48
42
|
assert @return_authorization.valid?
|
49
43
|
assert_nil @return_authorization.errors.on(:order)
|
50
44
|
end
|
51
|
-
|
45
|
+
|
52
46
|
context "with no inventory_units" do
|
53
47
|
should "not be receivable" do
|
54
48
|
assert !@return_authorization.can_receive?
|
55
49
|
end
|
56
50
|
end
|
57
|
-
|
51
|
+
|
58
52
|
context "with inventory_units" do
|
59
53
|
setup do
|
60
54
|
@return_authorization.add_variant(@line_item.variant_id, @line_item.quantity)
|
61
55
|
@return_authorization.inventory_units.reload
|
62
56
|
end
|
63
|
-
|
57
|
+
|
64
58
|
should "be receivable" do
|
65
59
|
assert @return_authorization.can_receive?
|
66
60
|
end
|
67
|
-
|
61
|
+
|
68
62
|
should "increase inventory_units.size" do
|
69
63
|
assert_equal @line_item.quantity, @return_authorization.inventory_units.size
|
70
64
|
end
|
71
|
-
|
65
|
+
|
72
66
|
should "decrease order.returnable_units count for returned variant" do
|
73
67
|
assert_equal nil, @return_authorization.order.returnable_units[@line_item.variant]
|
74
68
|
end
|
75
|
-
|
69
|
+
|
76
70
|
should "change order state to awaiting_return" do
|
77
71
|
assert_equal "awaiting_return", @return_authorization.order.state
|
78
72
|
end
|
79
|
-
|
73
|
+
|
80
74
|
context "that have been recieved" do
|
81
75
|
setup do
|
82
76
|
::ReturnAuthorizationCredit
|
83
77
|
@return_authorization.receive!
|
84
78
|
@return_authorization.order.reload
|
85
79
|
end
|
86
|
-
|
80
|
+
|
87
81
|
should_change("@return_authorization.order.adjustments.size", :by => 1) { @return_authorization.order.adjustments.size }
|
88
82
|
should_change("@return_authorization.order.credits.size", :by => 1) { @return_authorization.order.credits.size }
|
89
|
-
|
83
|
+
|
90
84
|
should "change state to received" do
|
91
85
|
assert @return_authorization.received?
|
92
86
|
end
|
93
|
-
|
87
|
+
|
94
88
|
should "change order state to credit_owed" do
|
95
89
|
assert @return_authorization.order.credit_owed?
|
96
90
|
end
|
97
91
|
end
|
98
92
|
end
|
99
|
-
|
93
|
+
|
100
94
|
end
|
101
95
|
|
102
96
|
end
|
data/test/unit/shipment_test.rb
CHANGED
@@ -23,6 +23,18 @@ class ShipmentTest < ActiveSupport::TestCase
|
|
23
23
|
assert_equal 1, @shipment.state_events.count
|
24
24
|
assert_equal 'pending', @shipment.state_events.first.previous_state
|
25
25
|
end
|
26
|
+
|
27
|
+
context "with paid order" do
|
28
|
+
setup do
|
29
|
+
create_paid_order
|
30
|
+
@shipment = Factory(:shipment, :order => @order, :inventory_unit_ids => @order.inventory_unit_ids)
|
31
|
+
@shipment.inventory_units << Factory(:inventory_unit)
|
32
|
+
@shipment.save!
|
33
|
+
end
|
34
|
+
should "be ready_to_ship" do
|
35
|
+
assert @shipment.ready_to_ship?
|
36
|
+
end
|
37
|
+
end
|
26
38
|
|
27
39
|
context "when shipped" do
|
28
40
|
setup do
|
@@ -51,9 +63,8 @@ class ShipmentTest < ActiveSupport::TestCase
|
|
51
63
|
|
52
64
|
context "manifest" do
|
53
65
|
setup do
|
54
|
-
|
66
|
+
@order = Order.create!
|
55
67
|
|
56
|
-
@order.line_items.clear
|
57
68
|
@variant1 = Factory(:variant)
|
58
69
|
@variant2 = Factory(:variant)
|
59
70
|
Factory(:line_item, :variant => @variant1, :order => @order, :quantity => 2)
|
@@ -76,8 +87,7 @@ class ShipmentTest < ActiveSupport::TestCase
|
|
76
87
|
|
77
88
|
context "line_items" do
|
78
89
|
setup do
|
79
|
-
|
80
|
-
@order.line_items.clear
|
90
|
+
@order = Order.create!
|
81
91
|
@line_item1 = Factory(:line_item, :variant => Factory(:variant), :order => @order, :quantity => 2)
|
82
92
|
@line_item2 = Factory(:line_item, :variant => Factory(:variant), :order => @order, :quantity => 3)
|
83
93
|
@line_item3 = Factory(:line_item, :variant => Factory(:variant), :order => @order, :quantity => 4)
|
@@ -126,7 +136,9 @@ class ShipmentTest < ActiveSupport::TestCase
|
|
126
136
|
|
127
137
|
context "recalculate_order after shipping_method change" do
|
128
138
|
setup do
|
129
|
-
|
139
|
+
@order = Order.create!
|
140
|
+
@order.line_items << Factory(:line_item, :order=>@order)
|
141
|
+
@order.checkout.shipping_method = Factory(:shipping_method)
|
130
142
|
@order.complete!
|
131
143
|
|
132
144
|
@new_shipping_method = Factory(:shipping_method)
|
@@ -134,10 +146,10 @@ class ShipmentTest < ActiveSupport::TestCase
|
|
134
146
|
c.preferred_amount = 5.0
|
135
147
|
c.save!
|
136
148
|
|
149
|
+
@shipment = @order.shipment
|
137
150
|
@shipment.shipping_method = @new_shipping_method
|
151
|
+
@shipment.shipping_method.zone.stub!(:include?) {true}
|
138
152
|
@shipment.save!
|
139
|
-
@shipment.reload
|
140
|
-
|
141
153
|
@shipment.recalculate_order
|
142
154
|
end
|
143
155
|
|
data/test/unit/variant_test.rb
CHANGED
@@ -6,26 +6,42 @@ class VariantTest < ActiveSupport::TestCase
|
|
6
6
|
context "without inventory units" do
|
7
7
|
setup { @variant = Variant.new }
|
8
8
|
should "not have inventory units" do
|
9
|
-
|
9
|
+
assert_equal 0, @variant.inventory_units.size
|
10
10
|
end
|
11
11
|
should "on_hand should be zero" do
|
12
|
-
|
12
|
+
assert_equal 0, @variant.on_hand
|
13
13
|
end
|
14
14
|
should "not be deleted" do
|
15
15
|
assert !@variant.deleted?
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
context "
|
20
|
-
setup {
|
21
|
-
|
22
|
-
|
19
|
+
context "when tracking inventory levels" do
|
20
|
+
setup { Spree::Config.set(:track_inventory_levels => true) }
|
21
|
+
|
22
|
+
context "with specified on_hand" do
|
23
|
+
setup { @variant = Variant.new(:on_hand => 5) }
|
24
|
+
should "on_hand should match specified units" do
|
25
|
+
assert_equal 5, @variant.on_hand
|
26
|
+
end
|
27
|
+
should_not_change("InventoryUnit.count") { InventoryUnit.count }
|
23
28
|
end
|
24
|
-
|
25
|
-
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when not tracking inventory levels" do
|
32
|
+
setup { Spree::Config.set(:track_inventory_levels => false) }
|
33
|
+
teardown { Spree::Config.set(:track_inventory_levels => true) }
|
34
|
+
should "raise exception when setting on_hand" do
|
35
|
+
assert_raise RuntimeError do
|
36
|
+
@variant = Variant.new(:on_hand => 5)
|
37
|
+
end
|
38
|
+
assert_raise RuntimeError do
|
39
|
+
@variant = Variant.new()
|
40
|
+
@variant.on_hand = 5
|
41
|
+
end
|
26
42
|
end
|
27
|
-
should_not_change("InventoryUnit.count") { InventoryUnit.count }
|
28
43
|
end
|
44
|
+
|
29
45
|
end
|
30
46
|
|
31
47
|
context "Variant.create" do
|
@@ -54,25 +70,45 @@ class VariantTest < ActiveSupport::TestCase
|
|
54
70
|
end
|
55
71
|
should_not_change("InventoryUnit.count") { InventoryUnit.count }
|
56
72
|
end
|
57
|
-
context "
|
58
|
-
setup
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
73
|
+
context "when tracking inventory levels" do
|
74
|
+
setup { Spree::Config.set(:track_inventory_levels => true) }
|
75
|
+
|
76
|
+
context "with specified inventory level" do
|
77
|
+
setup do
|
78
|
+
@variant = Variant.new(:on_hand => 3)
|
79
|
+
@product.variants << @variant
|
80
|
+
@product.save
|
81
|
+
end
|
82
|
+
teardown do
|
83
|
+
@variant.destroy
|
84
|
+
end
|
85
|
+
should "adjust inventory levels" do
|
86
|
+
assert_equal 3, @variant.on_hand
|
87
|
+
assert_equal 3, @variant.product.reload.count_on_hand
|
88
|
+
end
|
89
|
+
|
90
|
+
should_not_change("InventoryUnit.count") { InventoryUnit.count }
|
65
91
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
92
|
+
end
|
93
|
+
context "when not tracking inventory levels" do
|
94
|
+
setup { Spree::Config.set(:track_inventory_levels => false) }
|
95
|
+
teardown { Spree::Config.set(:track_inventory_levels => true) }
|
96
|
+
should "raise exception when setting on_hand" do
|
97
|
+
assert_raise RuntimeError do
|
98
|
+
@variant = Variant.new(:on_hand => 5)
|
99
|
+
end
|
100
|
+
assert_raise RuntimeError do
|
101
|
+
@variant = Variant.new()
|
102
|
+
@variant.on_hand = 5
|
103
|
+
end
|
69
104
|
end
|
70
|
-
|
71
|
-
should_not_change("InventoryUnit.count") { InventoryUnit.count }
|
72
105
|
end
|
106
|
+
|
73
107
|
end
|
74
|
-
|
108
|
+
|
109
|
+
context "Variant instance with 1 unit of inventory and when tracking inventory levels" do
|
75
110
|
setup do
|
111
|
+
Spree::Config.set(:track_inventory_levels => true)
|
76
112
|
@variant = Factory(:variant)
|
77
113
|
@variant.on_hand = 1
|
78
114
|
end
|
@@ -128,10 +164,50 @@ class VariantTest < ActiveSupport::TestCase
|
|
128
164
|
should "return false for in_stock?" do
|
129
165
|
assert !@variant.in_stock?
|
130
166
|
end
|
131
|
-
should "return
|
167
|
+
should "return true for available?" do
|
168
|
+
assert @variant.available?
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context "Variant instance when not tracking inventory levels" do
|
174
|
+
setup do
|
175
|
+
Spree::Config.set(:track_inventory_levels => false)
|
176
|
+
@variant = Factory(:variant)
|
177
|
+
end
|
178
|
+
teardown do
|
179
|
+
Spree::Config.set(:track_inventory_levels => true)
|
180
|
+
@variant.destroy
|
181
|
+
end
|
182
|
+
should "raise exception when setting on_hand" do
|
183
|
+
assert_raise RuntimeError do
|
184
|
+
@variant.on_hand = 5
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context "when backordering is allowed" do
|
189
|
+
setup do
|
190
|
+
Spree::Config.set(:allow_backorders => true)
|
191
|
+
end
|
192
|
+
should "return true for in_stock?" do
|
193
|
+
assert @variant.in_stock?
|
194
|
+
end
|
195
|
+
should "return true for available?" do
|
196
|
+
assert @variant.available?
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context "when backordering is disallowed" do
|
201
|
+
setup { Spree::Config.set(:allow_backorders => false) }
|
202
|
+
teardown { Spree::Config.set(:allow_backorders => true) }
|
203
|
+
should "return true for in_stock?" do
|
204
|
+
assert @variant.in_stock?
|
205
|
+
end
|
206
|
+
should "return true for available?" do
|
132
207
|
assert @variant.available?
|
133
208
|
end
|
134
209
|
end
|
210
|
+
|
135
211
|
end
|
136
212
|
|
137
213
|
should 'be deleted if deleted_at is set' do
|
@@ -35,13 +35,13 @@ class ApiExtension < Spree::Extension
|
|
35
35
|
|
36
36
|
def generate_api_key
|
37
37
|
if object.generate_api_key!
|
38
|
-
|
38
|
+
self.notice = t('api.key_generated')
|
39
39
|
end
|
40
40
|
redirect_to edit_object_path
|
41
41
|
end
|
42
42
|
def clear_api_key
|
43
43
|
if object.clear_api_key!
|
44
|
-
|
44
|
+
self.notice = t('api.key_cleared')
|
45
45
|
end
|
46
46
|
redirect_to edit_object_path
|
47
47
|
end
|
@@ -3,6 +3,7 @@ class Api::BaseController < Spree::BaseController
|
|
3
3
|
|
4
4
|
def self.resource_controller_for_api
|
5
5
|
resource_controller
|
6
|
+
skip_before_filter :verify_authenticity_token, :if => lambda { admin_token_passed_in_headers }
|
6
7
|
|
7
8
|
index.response do |wants|
|
8
9
|
wants.json { render :json => collection.to_json(collection_serialization_options) }
|
@@ -22,12 +23,19 @@ class Api::BaseController < Spree::BaseController
|
|
22
23
|
failure.wants.json { render :json => object_errors.to_json, :status => 422 }
|
23
24
|
end
|
24
25
|
|
26
|
+
define_method :admin_token_passed_in_headers do
|
27
|
+
token = request.headers['X-SpreeAPIKey']
|
28
|
+
return false unless token
|
29
|
+
@current_user = User.find_by_api_key(token)
|
30
|
+
@current_user.has_role? 'admin'
|
31
|
+
end
|
32
|
+
|
25
33
|
define_method :end_of_association_chain do
|
26
34
|
(parent? ? parent_association : model).scoped(:include => eager_load_associations)
|
27
35
|
end
|
28
36
|
|
29
37
|
define_method :collection do
|
30
|
-
@collection
|
38
|
+
@collection ||= search.all(:limit => 100)
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
@@ -70,7 +78,7 @@ class Api::BaseController < Spree::BaseController
|
|
70
78
|
@search.order ||= "descend_by_created_at"
|
71
79
|
@search
|
72
80
|
end
|
73
|
-
|
81
|
+
|
74
82
|
def collection_serialization_options
|
75
83
|
{}
|
76
84
|
end
|
@@ -78,13 +86,13 @@ class Api::BaseController < Spree::BaseController
|
|
78
86
|
def object_serialization_options
|
79
87
|
{}
|
80
88
|
end
|
81
|
-
|
89
|
+
|
82
90
|
def eager_load_associations
|
83
91
|
nil
|
84
92
|
end
|
85
|
-
|
93
|
+
|
86
94
|
def object_errors
|
87
95
|
{:errors => object.errors.full_messages}
|
88
96
|
end
|
89
|
-
|
90
|
-
end
|
97
|
+
|
98
|
+
end
|