gemgento 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/README.md +9 -0
- data/Rakefile +21 -0
- data/app/adapters/gemgento/magento/address_adapter.rb +37 -0
- data/app/adapters/gemgento/magento/customer_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/line_item_adapter.rb +41 -0
- data/app/adapters/gemgento/magento/order_adapter.rb +97 -0
- data/app/adapters/gemgento/magento/order_status_adapter.rb +24 -0
- data/app/adapters/gemgento/magento/payment_adapter.rb +38 -0
- data/app/adapters/gemgento/magento/product_adapater.rb +24 -0
- data/app/adapters/gemgento/magento/quote_adapter.rb +17 -0
- data/app/adapters/gemgento/magento/shipment_adapter.rb +74 -0
- data/app/adapters/gemgento/magento/shipment_item_adapter.rb +39 -0
- data/app/adapters/gemgento/magento/shipment_track_adapter.rb +31 -0
- data/app/adapters/gemgento/magento_adapter.rb +17 -0
- data/app/assets/fonts/FuturaStd-Bold.otf +0 -0
- data/app/assets/fonts/FuturaStd-Book.otf +0 -0
- data/app/assets/fonts/FuturaStd-Light.otf +0 -0
- data/app/assets/fonts/FuturaStd-Medium.otf +0 -0
- data/app/assets/fonts/Verlag-Black.otf +0 -0
- data/app/assets/fonts/Verlag-BlackItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Bold.otf +0 -0
- data/app/assets/fonts/Verlag-BoldItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Book.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-2.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic-3.otf +0 -0
- data/app/assets/fonts/Verlag-BookItalic.otf +0 -0
- data/app/assets/fonts/Verlag-Light.otf +0 -0
- data/app/assets/fonts/Verlag-LightItalic.otf +0 -0
- data/app/assets/fonts/Verlag-XLight.otf +0 -0
- data/app/assets/fonts/Verlag-XLightItalic.otf +0 -0
- data/app/assets/images/about_store.jpg +0 -0
- data/app/assets/images/gemgento-icon-bolt.png +0 -0
- data/app/assets/javascripts/gemgento/active_admin.js.coffee +42 -0
- data/app/assets/javascripts/gemgento/checkout/address.coffee +23 -0
- data/app/assets/javascripts/gemgento/gemgento.js +1 -0
- data/app/assets/javascripts/gemgento/global.js.coffee +31 -0
- data/app/assets/stylesheets/gemgento/active_admin.css.scss +549 -0
- data/app/assets/stylesheets/gemgento/default-views/_address.scss +11 -0
- data/app/assets/stylesheets/gemgento/default-views/_category.scss +54 -0
- data/app/assets/stylesheets/gemgento/default-views/_checkout.scss +28 -0
- data/app/assets/stylesheets/gemgento/default-views/_footer.scss +13 -0
- data/app/assets/stylesheets/gemgento/default-views/_form.scss +127 -0
- data/app/assets/stylesheets/gemgento/default-views/_header.scss +32 -0
- data/app/assets/stylesheets/gemgento/default-views/_layout.css.scss +157 -0
- data/app/assets/stylesheets/gemgento/default-views/_pages.css.scss +83 -0
- data/app/assets/stylesheets/gemgento/default-views/_product.scss +57 -0
- data/app/assets/stylesheets/gemgento/default-views/_shopping_bag.scss +87 -0
- data/app/assets/stylesheets/gemgento/default-views/_subheader.css.scss +30 -0
- data/app/assets/stylesheets/gemgento/default-views/application.css.scss +1 -0
- data/app/controllers/concerns/gemgento/api/v1/base.rb +15 -0
- data/app/controllers/concerns/gemgento/api/v1/product_filters.rb +33 -0
- data/app/controllers/gemgento/addresses_controller.rb +14 -0
- data/app/controllers/gemgento/api/v1/categories_controller.rb +13 -0
- data/app/controllers/gemgento/api/v1/products_controller.rb +23 -0
- data/app/controllers/gemgento/api/v1/search_controller.rb +14 -0
- data/app/controllers/gemgento/application_controller.rb +5 -0
- data/app/controllers/gemgento/cart_controller.rb +99 -0
- data/app/controllers/gemgento/categories_controller.rb +37 -0
- data/app/controllers/gemgento/checkout/address_controller.rb +48 -0
- data/app/controllers/gemgento/checkout/confirm_controller.rb +72 -0
- data/app/controllers/gemgento/checkout/coupons_controller.rb +42 -0
- data/app/controllers/gemgento/checkout/gift_card_controller.rb +39 -0
- data/app/controllers/gemgento/checkout/gift_controller.rb +32 -0
- data/app/controllers/gemgento/checkout/login_controller.rb +123 -0
- data/app/controllers/gemgento/checkout/payment_controller.rb +70 -0
- data/app/controllers/gemgento/checkout/paypal_controller.rb +23 -0
- data/app/controllers/gemgento/checkout/shipping_controller.rb +46 -0
- data/app/controllers/gemgento/checkout/shipping_payment_controller.rb +58 -0
- data/app/controllers/gemgento/checkout/thank_you_controller.rb +45 -0
- data/app/controllers/gemgento/checkout_controller.rb +120 -0
- data/app/controllers/gemgento/countries_controller.rb +17 -0
- data/app/controllers/gemgento/errors_controller.rb +7 -0
- data/app/controllers/gemgento/footer_items_controller.rb +16 -0
- data/app/controllers/gemgento/home_controller.rb +7 -0
- data/app/controllers/gemgento/magento/addresses_controller.rb +61 -0
- data/app/controllers/gemgento/magento/base_controller.rb +18 -0
- data/app/controllers/gemgento/magento/categories_controller.rb +103 -0
- data/app/controllers/gemgento/magento/email/sales/credit_memos_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/invoices_controller.rb +21 -0
- data/app/controllers/gemgento/magento/email/sales/orders_controller.rb +20 -0
- data/app/controllers/gemgento/magento/email/sales/shipments_controller.rb +25 -0
- data/app/controllers/gemgento/magento/emails_controller.rb +11 -0
- data/app/controllers/gemgento/magento/inventory_controller.rb +30 -0
- data/app/controllers/gemgento/magento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/magento/price_rules_controller.rb +22 -0
- data/app/controllers/gemgento/magento/product_attribute_sets_controller.rb +37 -0
- data/app/controllers/gemgento/magento/product_attributes_controller.rb +70 -0
- data/app/controllers/gemgento/magento/products_controller.rb +240 -0
- data/app/controllers/gemgento/magento/recurring_profiles_controller.rb +42 -0
- data/app/controllers/gemgento/magento/stores_controller.rb +21 -0
- data/app/controllers/gemgento/magento/user_groups_controller.rb +23 -0
- data/app/controllers/gemgento/magento/users_controller.rb +63 -0
- data/app/controllers/gemgento/order_export_controller.rb +21 -0
- data/app/controllers/gemgento/orders_controller.rb +12 -0
- data/app/controllers/gemgento/products_controller.rb +12 -0
- data/app/controllers/gemgento/regions_controller.rb +18 -0
- data/app/controllers/gemgento/search_controller.rb +16 -0
- data/app/controllers/gemgento/shipments_controller.rb +5 -0
- data/app/controllers/gemgento/stock_notifications_controller.rb +22 -0
- data/app/controllers/gemgento/subscribers_controller.rb +35 -0
- data/app/controllers/gemgento/sync_controller.rb +50 -0
- data/app/controllers/gemgento/user/addresses_controller.rb +79 -0
- data/app/controllers/gemgento/user/base_controller.rb +14 -0
- data/app/controllers/gemgento/user/home_controller.rb +9 -0
- data/app/controllers/gemgento/user/orders_controller.rb +17 -0
- data/app/controllers/gemgento/user/passwords_controller.rb +18 -0
- data/app/controllers/gemgento/user/recurring_profiles_controller.rb +31 -0
- data/app/controllers/gemgento/user/registration_session_controller.rb +103 -0
- data/app/controllers/gemgento/user/registrations_controller.rb +28 -0
- data/app/controllers/gemgento/user/saved_credit_cards_controller.rb +56 -0
- data/app/controllers/gemgento/user/sessions_controller.rb +50 -0
- data/app/controllers/gemgento/user/wishlist_items_controller.rb +55 -0
- data/app/controllers/gemgento/users_controller.rb +36 -0
- data/app/helpers/gemgento/application_helper.rb +125 -0
- data/app/helpers/gemgento/categories_helper.rb +39 -0
- data/app/helpers/gemgento/checkout/payment_helper.rb +5 -0
- data/app/helpers/gemgento/products_helper.rb +23 -0
- data/app/jobs/gemgento/import_job.rb +12 -0
- data/app/mailers/gemgento/sales_mailer.rb +80 -0
- data/app/models/admin_user.rb +7 -0
- data/app/models/concerns/gemgento/product_touches.rb +26 -0
- data/app/models/gemgento.rb +5 -0
- data/app/models/gemgento/adapter/sellect/customer.rb +34 -0
- data/app/models/gemgento/adapter/sellect/order.rb +378 -0
- data/app/models/gemgento/adapter/sellect/product.rb +250 -0
- data/app/models/gemgento/adapter/sellect_adapter.rb +16 -0
- data/app/models/gemgento/adapter/shopify/address.rb +40 -0
- data/app/models/gemgento/adapter/shopify/category.rb +51 -0
- data/app/models/gemgento/adapter/shopify/customer.rb +66 -0
- data/app/models/gemgento/adapter/shopify/order.rb +334 -0
- data/app/models/gemgento/adapter/shopify/product.rb +377 -0
- data/app/models/gemgento/adapter/shopify/product_category_position.rb +58 -0
- data/app/models/gemgento/adapter/shopify_adapter.rb +63 -0
- data/app/models/gemgento/address.rb +206 -0
- data/app/models/gemgento/api_job.rb +68 -0
- data/app/models/gemgento/asset.rb +185 -0
- data/app/models/gemgento/asset_file.rb +57 -0
- data/app/models/gemgento/asset_type.rb +8 -0
- data/app/models/gemgento/bundle.rb +5 -0
- data/app/models/gemgento/bundle/item.rb +17 -0
- data/app/models/gemgento/bundle/option.rb +20 -0
- data/app/models/gemgento/category.rb +235 -0
- data/app/models/gemgento/country.rb +21 -0
- data/app/models/gemgento/gift_message.rb +8 -0
- data/app/models/gemgento/image_import.rb +141 -0
- data/app/models/gemgento/import.rb +125 -0
- data/app/models/gemgento/inventory.rb +60 -0
- data/app/models/gemgento/inventory_import.rb +51 -0
- data/app/models/gemgento/line_item.rb +142 -0
- data/app/models/gemgento/line_item_option.rb +10 -0
- data/app/models/gemgento/magento_db.rb +35 -0
- data/app/models/gemgento/magento_response.rb +10 -0
- data/app/models/gemgento/order.rb +56 -0
- data/app/models/gemgento/order_status.rb +7 -0
- data/app/models/gemgento/payment.rb +50 -0
- data/app/models/gemgento/price_rule.rb +258 -0
- data/app/models/gemgento/price_tier.rb +36 -0
- data/app/models/gemgento/product.rb +607 -0
- data/app/models/gemgento/product_attribute.rb +48 -0
- data/app/models/gemgento/product_attribute_option.rb +39 -0
- data/app/models/gemgento/product_attribute_set.rb +22 -0
- data/app/models/gemgento/product_attribute_value.rb +26 -0
- data/app/models/gemgento/product_category.rb +34 -0
- data/app/models/gemgento/product_import.rb +359 -0
- data/app/models/gemgento/quote.rb +586 -0
- data/app/models/gemgento/recurring_profile.rb +28 -0
- data/app/models/gemgento/region.rb +14 -0
- data/app/models/gemgento/relation.rb +10 -0
- data/app/models/gemgento/relation_type.rb +7 -0
- data/app/models/gemgento/saved_credit_card.rb +45 -0
- data/app/models/gemgento/search.rb +14 -0
- data/app/models/gemgento/session.rb +49 -0
- data/app/models/gemgento/shipment.rb +38 -0
- data/app/models/gemgento/shipment_comment.rb +19 -0
- data/app/models/gemgento/shipment_item.rb +11 -0
- data/app/models/gemgento/shipment_track.rb +21 -0
- data/app/models/gemgento/stock_notification.rb +17 -0
- data/app/models/gemgento/store.rb +31 -0
- data/app/models/gemgento/store_tag.rb +8 -0
- data/app/models/gemgento/subscriber.rb +30 -0
- data/app/models/gemgento/swatch.rb +9 -0
- data/app/models/gemgento/sync.rb +134 -0
- data/app/models/gemgento/tag.rb +64 -0
- data/app/models/gemgento/user.rb +161 -0
- data/app/models/gemgento/user_group.rb +13 -0
- data/app/models/gemgento/wishlist_item.rb +11 -0
- data/app/services/gemgento/magento_api.rb +173 -0
- data/app/services/gemgento/price.rb +67 -0
- data/app/validators/gemgento/credit_card_validator.rb +50 -0
- data/app/validators/gemgento/image_import_validator.rb +100 -0
- data/app/validators/gemgento/inventory_import_validator.rb +73 -0
- data/app/validators/gemgento/inventory_validator.rb +14 -0
- data/app/validators/gemgento/product_import_validator.rb +163 -0
- data/app/views/admin/product_positions/_index.html.haml +14 -0
- data/app/views/devise/registrations/edit.haml +37 -0
- data/app/views/gemgento/addresses/_address.json.jbuilder +6 -0
- data/app/views/gemgento/addresses/region_options.html.haml +1 -0
- data/app/views/gemgento/api/v1/categories/_category.json.jbuilder +52 -0
- data/app/views/gemgento/api/v1/categories/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/categories/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/products/_attributes.json.jbuilder +9 -0
- data/app/views/gemgento/api/v1/products/_product.json.jbuilder +18 -0
- data/app/views/gemgento/api/v1/products/_relationships.json.jbuilder +48 -0
- data/app/views/gemgento/api/v1/products/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/products/show.json.jbuilder +7 -0
- data/app/views/gemgento/api/v1/search/index.json.jbuilder +8 -0
- data/app/views/gemgento/api/v1/search/show.json.jbuilder +8 -0
- data/app/views/gemgento/assets/_asset.json.jbuilder +13 -0
- data/app/views/gemgento/cart/show.html.haml +67 -0
- data/app/views/gemgento/categories/_category.json.jbuilder +9 -0
- data/app/views/gemgento/categories/_product_tile.html.haml +16 -0
- data/app/views/gemgento/categories/index.html.haml +10 -0
- data/app/views/gemgento/categories/index.json.jbuilder +1 -0
- data/app/views/gemgento/categories/show.html.haml +16 -0
- data/app/views/gemgento/categories/show.json.jbuilder +1 -0
- data/app/views/gemgento/checkout/_checkout_header.html.haml +17 -0
- data/app/views/gemgento/checkout/address/error.js.erb +1 -0
- data/app/views/gemgento/checkout/address/show.html.haml +88 -0
- data/app/views/gemgento/checkout/address/success.js.erb +1 -0
- data/app/views/gemgento/checkout/confirm/error.js.erb +0 -0
- data/app/views/gemgento/checkout/confirm/show.html.haml +60 -0
- data/app/views/gemgento/checkout/confirm/success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_guest_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/login_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_fail.js.erb +1 -0
- data/app/views/gemgento/checkout/login/registration_success.js.erb +1 -0
- data/app/views/gemgento/checkout/login/show.html.haml +50 -0
- data/app/views/gemgento/checkout/payment/error.js.erb +1 -0
- data/app/views/gemgento/checkout/payment/show.html.haml +56 -0
- data/app/views/gemgento/checkout/payment/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping/error.js.erb +0 -0
- data/app/views/gemgento/checkout/shipping/show.html.haml +26 -0
- data/app/views/gemgento/checkout/shipping/success.js.erb +1 -0
- data/app/views/gemgento/checkout/shipping_payment/show.haml +52 -0
- data/app/views/gemgento/checkout/thank_you/show.html.haml +6 -0
- data/app/views/gemgento/countries/_country.json.jbuilder +4 -0
- data/app/views/gemgento/countries/index.json.jbuilder +3 -0
- data/app/views/gemgento/countries/show.json.jbuilder +1 -0
- data/app/views/gemgento/home/index.html.haml +1 -0
- data/app/views/gemgento/order/add_item.js.erb +0 -0
- data/app/views/gemgento/order/no_inventory.js.erb +1 -0
- data/app/views/gemgento/order/remove_item.js.erb +0 -0
- data/app/views/gemgento/order/update_item.js.erb +0 -0
- data/app/views/gemgento/order_export/index.html.haml +2 -0
- data/app/views/gemgento/order_items/_order_item.json.jbuilder +7 -0
- data/app/views/gemgento/orders/_order.json.jbuilder +29 -0
- data/app/views/gemgento/products/_product.json.jbuilder +40 -0
- data/app/views/gemgento/products/index.html.haml +19 -0
- data/app/views/gemgento/products/show.html.haml +67 -0
- data/app/views/gemgento/products/show.json.jbuilder +1 -0
- data/app/views/gemgento/sales_mailer/credit_memo_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/invoice_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/order_email.html.haml +1 -0
- data/app/views/gemgento/sales_mailer/shipment_email.html.haml +1 -0
- data/app/views/gemgento/search/index.html.haml +8 -0
- data/app/views/gemgento/shared/_asset.json.jbuilder +35 -0
- data/app/views/gemgento/shared/_asset_file.json.jbuilder +19 -0
- data/app/views/gemgento/shared/_asset_type.json.jbuilder +13 -0
- data/app/views/gemgento/shared/_error_messages.haml +7 -0
- data/app/views/gemgento/shared/_flash_messages.haml +4 -0
- data/app/views/gemgento/shared/_footer.haml +7 -0
- data/app/views/gemgento/shared/_header.haml +23 -0
- data/app/views/gemgento/shared/_mini_bag.haml +36 -0
- data/app/views/gemgento/shared/_product_image.haml +8 -0
- data/app/views/gemgento/shipments/_shipment.json.jbuilder +12 -0
- data/app/views/gemgento/subscribers/create.js.erb +2 -0
- data/app/views/gemgento/subscribers/errors.js.erb +1 -0
- data/app/views/gemgento/user/_user.json.jbuilder +2 -0
- data/app/views/gemgento/user/addresses/_form.haml +39 -0
- data/app/views/gemgento/user/addresses/errors.js.erb +1 -0
- data/app/views/gemgento/user/addresses/index.haml +33 -0
- data/app/views/gemgento/user/addresses/new.haml +11 -0
- data/app/views/gemgento/user/addresses/success.js.erb +1 -0
- data/app/views/gemgento/user/confirmations/new.haml +9 -0
- data/app/views/gemgento/user/home/index.haml +8 -0
- data/app/views/gemgento/user/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/gemgento/user/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/gemgento/user/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/gemgento/user/orders/index.html.haml +29 -0
- data/app/views/gemgento/user/orders/show.html.haml +87 -0
- data/app/views/gemgento/user/passwords/edit.html.erb +18 -0
- data/app/views/gemgento/user/passwords/new.html.haml +21 -0
- data/app/views/gemgento/user/registration_session/new.haml +67 -0
- data/app/views/gemgento/user/registrations/new.html.haml +28 -0
- data/app/views/gemgento/user/saved_credit_cards/_form.haml +69 -0
- data/app/views/gemgento/user/saved_credit_cards/index.haml +25 -0
- data/app/views/gemgento/user/saved_credit_cards/new.haml +13 -0
- data/app/views/gemgento/user/sessions/new.html.haml +29 -0
- data/app/views/gemgento/user/shared/_links.erb +25 -0
- data/app/views/gemgento/user/shared/_user_header.haml +8 -0
- data/app/views/gemgento/user/wishlist_items/index.html.haml +20 -0
- data/app/views/kaminari/_first_page.html.haml +9 -0
- data/app/views/kaminari/_gap.html.haml +8 -0
- data/app/views/kaminari/_last_page.html.haml +9 -0
- data/app/views/kaminari/_next_page.html.haml +9 -0
- data/app/views/kaminari/_page.html.haml +10 -0
- data/app/views/kaminari/_paginator.html.haml +18 -0
- data/app/views/kaminari/_prev_page.html.haml +9 -0
- data/app/views/layouts/_footer.html.haml +5 -0
- data/app/views/layouts/_header.html.haml +39 -0
- data/app/views/layouts/gemgento.html.haml +22 -0
- data/app/workers/gemgento/apply_price_rule.rb +24 -0
- data/app/workers/gemgento/cart/add_item_worker.rb +23 -0
- data/app/workers/gemgento/cart/update_item_worker.rb +18 -0
- data/bin/rails +12 -0
- data/config/gemgento_config.yml +12 -0
- data/config/initializers/active_admin.rb +14 -0
- data/config/initializers/active_touch.rb +3 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/boolean_typecasting.rb +37 -0
- data/config/initializers/devise.rb +49 -0
- data/config/initializers/gemgento_config.rb +67 -0
- data/config/initializers/mime_types.rb +4 -0
- data/config/initializers/state_machine.rb +7 -0
- data/config/locales/en.yml +24 -0
- data/config/routes.rb +138 -0
- data/db/migrate/20151201231300_add_validation_indexes_to_gemgento_products.rb +22 -0
- data/db/migrate/20160122174450_gemgento2.rb +969 -0
- data/db/migrate/20160217142910_create_gemgento_imports.rb +15 -0
- data/db/migrate/20160219235858_add_timestamps_to_gemgento_asset_files.rb +6 -0
- data/gemgento.gemspec +44 -0
- data/lib/devise/models/validatable.rb +76 -0
- data/lib/gemgento.rb +24 -0
- data/lib/gemgento/admin/admin_user.rb +29 -0
- data/lib/gemgento/admin/api_jobs.rb +30 -0
- data/lib/gemgento/admin/image_import.rb +87 -0
- data/lib/gemgento/admin/inventory_import.rb +81 -0
- data/lib/gemgento/admin/product_import.rb +138 -0
- data/lib/gemgento/admin/product_positions.rb +49 -0
- data/lib/gemgento/admin/stores.rb +33 -0
- data/lib/gemgento/admin/subscribers.rb +31 -0
- data/lib/gemgento/admin/syncs.rb +26 -0
- data/lib/gemgento/api/soap/authnetcim/payment.rb +127 -0
- data/lib/gemgento/api/soap/catalog/category.rb +237 -0
- data/lib/gemgento/api/soap/catalog/product.rb +481 -0
- data/lib/gemgento/api/soap/catalog/product_attribute.rb +147 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_media.rb +202 -0
- data/lib/gemgento/api/soap/catalog/product_attribute_set.rb +80 -0
- data/lib/gemgento/api/soap/catalog/product_tag.rb +146 -0
- data/lib/gemgento/api/soap/catalog/product_tier_price.rb +21 -0
- data/lib/gemgento/api/soap/catalog/search.rb +27 -0
- data/lib/gemgento/api/soap/catalog_inventory/stock_item.rb +87 -0
- data/lib/gemgento/api/soap/catalog_rule/rule.rb +54 -0
- data/lib/gemgento/api/soap/checkout/cart.rb +85 -0
- data/lib/gemgento/api/soap/checkout/coupon.rb +37 -0
- data/lib/gemgento/api/soap/checkout/customer.rb +87 -0
- data/lib/gemgento/api/soap/checkout/payment.rb +59 -0
- data/lib/gemgento/api/soap/checkout/product.rb +138 -0
- data/lib/gemgento/api/soap/checkout/shipping.rb +37 -0
- data/lib/gemgento/api/soap/customer/address.rb +143 -0
- data/lib/gemgento/api/soap/customer/customer.rb +200 -0
- data/lib/gemgento/api/soap/directory/country.rb +49 -0
- data/lib/gemgento/api/soap/directory/region.rb +50 -0
- data/lib/gemgento/api/soap/enterprise_gift_message/gift_message.rb +26 -0
- data/lib/gemgento/api/soap/gift_card.rb +35 -0
- data/lib/gemgento/api/soap/globalcollect/saved_cc.rb +58 -0
- data/lib/gemgento/api/soap/miscellaneous/store.rb +47 -0
- data/lib/gemgento/api/soap/sales/order.rb +249 -0
- data/lib/gemgento/api/soap/sales/order_shipment.rb +122 -0
- data/lib/gemgento/api/soap/sales/recurring_profile.rb +88 -0
- data/lib/gemgento/api/soap/stock_notification.rb +27 -0
- data/lib/gemgento/engine.rb +61 -0
- data/lib/gemgento/version.rb +3 -0
- data/lib/generators/gemgento/assets_generator.rb +11 -0
- data/lib/generators/gemgento/install_generator.rb +34 -0
- data/lib/generators/gemgento/templates/active_admin.css.scss +1 -0
- data/lib/generators/gemgento/templates/active_admin.js.coffee +1 -0
- data/lib/generators/gemgento/templates/active_admin.rb +3 -0
- data/lib/generators/gemgento/views_generator.rb +10 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +20 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/gemgento_config.yml +22 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/gemgento/price_tiers.rb +8 -0
- data/spec/factories/gemgento/product_attribute_sets.rb +22 -0
- data/spec/factories/gemgento/product_attributes.rb +5 -0
- data/spec/factories/gemgento/products.rb +14 -0
- data/spec/factories/gemgento/stores.rb +12 -0
- data/spec/factories/gemgento/user_groups.rb +6 -0
- data/spec/factories/gemgento/users.rb +13 -0
- data/spec/factories/gemgento_imports.rb +12 -0
- data/spec/model/gemgento/price_tier_spec.rb +45 -0
- data/spec/rails_helper.rb +55 -0
- data/spec/services/gemgento/price_spec.rb +152 -0
- data/spec/spec_helper.rb +87 -0
- metadata +919 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 8c87b62057a2eaecc9944bbb57814cb1492e5044b305df9ccab4e5f07fca93b97db175a540c927a24980fda4102acb9f8164fd5dcdc23c65f6c0c6e28ff8b43a
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: d61fe4f5bfcd4e20f3219b84f7c8c186f2b84a349910c2b348378b676217f28fe615026810e1d73575e599a2e1c8b8e1704f2b7037a161b4212b0c01d18cd5ae
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :gemgento_product_attribute_set, class: 'Gemgento::ProductAttributeSet' do
|
3
|
+
name 'default attribute set'
|
4
|
+
|
5
|
+
factory :gemgento_product_attribute_set_with_attributes do
|
6
|
+
after(:create) do |attribute_set|
|
7
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'price', frontend_input: 'price')
|
8
|
+
|
9
|
+
# giftvoucher attributes
|
10
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'gift_price_type', frontend_input: 'text')
|
11
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'gift_price', frontend_input: 'price')
|
12
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'gift_value', frontend_input: 'price')
|
13
|
+
|
14
|
+
# special price attributes
|
15
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'special_price', frontend_input: 'price')
|
16
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'special_from_date', frontend_input: 'price')
|
17
|
+
attribute_set.product_attributes << Gemgento::ProductAttribute.new(code: 'special_to_date', frontend_input: 'price')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :gemgento_product, class: 'Gemgento::Product' do
|
3
|
+
sku { Faker::Code.isbn }
|
4
|
+
association :product_attribute_set, factory: :gemgento_product_attribute_set
|
5
|
+
sync_needed false
|
6
|
+
status true
|
7
|
+
stores {[FactoryGirl.create(:gemgento_store)]}
|
8
|
+
|
9
|
+
factory :gemgento_product_with_attributes do
|
10
|
+
association :product_attribute_set, factory: :gemgento_product_attribute_set_with_attributes
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :gemgento_store, class: 'Gemgento::Store' do
|
3
|
+
id 1
|
4
|
+
magento_id 1
|
5
|
+
code 'default'
|
6
|
+
currency_code 'usd'
|
7
|
+
is_active true
|
8
|
+
name 'Default Store'
|
9
|
+
initialize_with { Gemgento::Store.find_or_initialize_by(id: id) }
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :gemgento_user, class: 'Gemgento::User' do
|
3
|
+
email { Faker::Internet.email }
|
4
|
+
first_name { Faker::Name.first_name }
|
5
|
+
last_name { Faker::Name.last_name }
|
6
|
+
password 'Password123'
|
7
|
+
sync_needed false
|
8
|
+
association :user_group, factory: :gemgento_user_group
|
9
|
+
|
10
|
+
after(:build) { |user| user.class.skip_callback(:create, :before, :magento_create) }
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gemgento::PriceTier, type: :model do
|
4
|
+
|
5
|
+
describe '#is_valid?' do
|
6
|
+
|
7
|
+
let(:price_tier) { FactoryGirl.build(:gemgento_price_tier, quantity: 10, price: 10) }
|
8
|
+
|
9
|
+
context 'when quantity is greater than price tier' do
|
10
|
+
it { expect(price_tier.is_valid?(11, nil)).to eq(true) }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when quantity is less than price tier' do
|
14
|
+
it { expect(price_tier.is_valid?(9, nil)).to eq(false) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when user group differs from price tier' do
|
18
|
+
it { expect(price_tier.is_valid?(9, FactoryGirl.create(:gemgento_user_group))).to eq(false) }
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#calculate_price' do
|
24
|
+
|
25
|
+
let(:product) { FactoryGirl.create(:gemgento_product_with_attributes) }
|
26
|
+
let!(:price_tier_1) { FactoryGirl.create(:gemgento_price_tier, quantity: 10, price: 10, product: product) }
|
27
|
+
let!(:price_tier_2) { FactoryGirl.create(:gemgento_price_tier, quantity: 5, price: 5, product: product) }
|
28
|
+
|
29
|
+
before { product.set_attribute_value('price', 100) }
|
30
|
+
|
31
|
+
context 'when quantity less then any price tier' do
|
32
|
+
it 'returns product price' do
|
33
|
+
expect(Gemgento::PriceTier.calculate_price(product)).to eq(100)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when there are multiple valid price tiers' do
|
38
|
+
it 'returns the cheapest price tier' do
|
39
|
+
expect(Gemgento::PriceTier.calculate_price(product, 10)).to eq(5)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV['RAILS_ENV'] ||= 'test'
|
3
|
+
require 'spec_helper'
|
4
|
+
require File.expand_path('../dummy/config/environment', __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
8
|
+
require 'factory_girl_rails'
|
9
|
+
require 'faker'
|
10
|
+
|
11
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
12
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
13
|
+
# run as spec files by default. This means that files in spec/support that end
|
14
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
15
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
16
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
17
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
18
|
+
#
|
19
|
+
# The following line is provided for convenience purposes. It has the downside
|
20
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
21
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
22
|
+
# require only the support files necessary.
|
23
|
+
#
|
24
|
+
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
25
|
+
|
26
|
+
# Checks for pending migrations before tests are run.
|
27
|
+
# If you are not using ActiveRecord, you can remove this line.
|
28
|
+
ActiveRecord::Migration.maintain_test_schema!
|
29
|
+
|
30
|
+
I18n.reload!
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
34
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
35
|
+
|
36
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
37
|
+
# examples within a transaction, remove the following line or assign false
|
38
|
+
# instead of true.
|
39
|
+
config.use_transactional_fixtures = true
|
40
|
+
|
41
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
42
|
+
# based on their file location, for example enabling you to call `get` and
|
43
|
+
# `post` in specs under `spec/controllers`.
|
44
|
+
#
|
45
|
+
# You can disable this behaviour by removing the line below, and instead
|
46
|
+
# explicitly tag your specs with their type, e.g.:
|
47
|
+
#
|
48
|
+
# RSpec.describe UsersController, :type => :controller do
|
49
|
+
# # ...
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# The different available types are documented in the features, such as in
|
53
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
54
|
+
config.infer_spec_type_from_file_location!
|
55
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gemgento::Price do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@user_group = FactoryGirl.create(:gemgento_user_group)
|
7
|
+
@product = FactoryGirl.create(:gemgento_product_with_attributes)
|
8
|
+
@price = Gemgento::Price.new(@product, @user_group)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#has_special?' do
|
12
|
+
|
13
|
+
context 'when there is no special price' do
|
14
|
+
before { @product.set_attribute_value('special_price', nil) }
|
15
|
+
it { expect(@price.has_special?).to be false }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when there is a special price' do
|
19
|
+
before { @product.set_attribute_value('special_price', 10) }
|
20
|
+
|
21
|
+
context 'with no special_form_date and special_to_date' do
|
22
|
+
before do
|
23
|
+
@product.set_attribute_value('special_from_date', nil)
|
24
|
+
@product.set_attribute_value('special_to_date', nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
it { expect(@price.has_special?).to be true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with only a special_to_date' do
|
31
|
+
before { @product.set_attribute_value('special_from_date', nil) }
|
32
|
+
|
33
|
+
context 'in the past' do
|
34
|
+
before { @product.set_attribute_value('special_to_date', Date.yesterday.strftime('%F')) }
|
35
|
+
it { expect(@price.has_special?).to be false }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'in the present' do
|
39
|
+
before { @product.set_attribute_value('special_to_date', Date.today.strftime('%F')) }
|
40
|
+
it { expect(@price.has_special?).to be true }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'in the future' do
|
44
|
+
before { @product.set_attribute_value('special_to_date', Date.tomorrow.strftime('%F')) }
|
45
|
+
it { expect(@price.has_special?).to be true }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with only a special_from_date' do
|
50
|
+
before { @product.set_attribute_value('special_to_date', nil) }
|
51
|
+
|
52
|
+
context 'in the past' do
|
53
|
+
before { @product.set_attribute_value('special_from_date', Date.yesterday.strftime('%F')) }
|
54
|
+
it { expect(@price.has_special?).to be true }
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'in the present' do
|
58
|
+
before { @product.set_attribute_value('special_from_date', Date.today.strftime('%F')) }
|
59
|
+
it { expect(@price.has_special?).to be true }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'in the future' do
|
63
|
+
before { @product.set_attribute_value('special_from_date', Date.tomorrow.strftime('%F')) }
|
64
|
+
it { expect(@price.has_special?).to be false }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with a special_from_date and a special_to_date range' do
|
69
|
+
context 'including today' do
|
70
|
+
before do
|
71
|
+
@product.set_attribute_value('special_from_date', Date.yesterday.strftime('%F'))
|
72
|
+
@product.set_attribute_value('special_to_date', Date.tomorrow.strftime('%F'))
|
73
|
+
end
|
74
|
+
|
75
|
+
it { expect(@price.has_special?).to be true }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'excluding today' do
|
79
|
+
before do
|
80
|
+
@product.set_attribute_value('special_from_date', Date.tomorrow.strftime('%F'))
|
81
|
+
@product.set_attribute_value('special_to_date', Date.yesterday.strftime('%F'))
|
82
|
+
end
|
83
|
+
|
84
|
+
it { expect(@price.has_special?).to be false }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#gift_price' do
|
91
|
+
before do
|
92
|
+
@product.set_attribute_value('gift_price', 10)
|
93
|
+
@product.set_attribute_value('gift_value', 5)
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when gift_price_type is "Fixed number"' do
|
97
|
+
before { @product.set_attribute_value('gift_price_type', 'Fixed number') }
|
98
|
+
it { expect(@price.gift_price).to eq(10) }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when gift_price_type is "Percent of Gift Card value"' do
|
102
|
+
before { @product.set_attribute_value('gift_price_type', 'Percent of Gift Card value') }
|
103
|
+
it { expect(@price.gift_price).to eq(0.5) }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when gift_price_type is unknown' do
|
107
|
+
before { @product.set_attribute_value('gift_price_type', 'random') }
|
108
|
+
it { expect(@price.gift_price).to eq(5) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#calculate' do
|
113
|
+
|
114
|
+
context 'when product is a giftvoucher' do
|
115
|
+
before do
|
116
|
+
@product.update(magento_type: 'giftvoucher')
|
117
|
+
@product.set_attribute_value('gift_price', 10)
|
118
|
+
@product.set_attribute_value('gift_value', 5)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'returns gift_price' do
|
122
|
+
expect(@price.calculate).to eq(5)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when product is not a giftvoucher' do
|
127
|
+
before do
|
128
|
+
@product.set_attribute_value('price', 100)
|
129
|
+
@product.set_attribute_value('special_price', 75)
|
130
|
+
@product.set_attribute_value('special_from_date', nil)
|
131
|
+
@product.set_attribute_value('special_to_date', nil)
|
132
|
+
FactoryGirl.create(:gemgento_price_tier, quantity: 10, price: 50, product: @product, store: @product.stores.first)
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when original product price is cheapest' do
|
136
|
+
before { @product.set_attribute_value('price', 10) }
|
137
|
+
it { expect(@price.calculate).to eq(10) }
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when special price is cheapest' do
|
141
|
+
before { @product.set_attribute_value('special_price', 75) }
|
142
|
+
it { expect(@price.calculate).to eq(75) }
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when PriceTier is cheapest' do
|
146
|
+
before { @price.quantity = 11 }
|
147
|
+
it { expect(@price.calculate).to eq(50) }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|