radiant-shop-extension 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +32 -65
- data/app/controllers/admin/shop/customers_controller.rb +8 -7
- data/app/controllers/admin/shop/orders_controller.rb +37 -159
- data/app/controllers/admin/shop/packages/packings_controller.rb +90 -0
- data/app/controllers/admin/shop/packages_controller.rb +65 -0
- data/app/controllers/admin/shop/products/images_controller.rb +5 -8
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +27 -0
- data/app/controllers/admin/shop/products/variants_controller.rb +60 -0
- data/app/controllers/admin/shop/products_controller.rb +67 -64
- data/app/controllers/admin/shop/variants_controller.rb +49 -0
- data/app/helpers/shop_helper.rb +5 -0
- data/app/models/form_address.rb +144 -0
- data/app/models/form_checkout.rb +200 -307
- data/app/models/form_line_item.rb +60 -0
- data/app/models/shop_address.rb +2 -2
- data/app/models/shop_category.rb +48 -51
- data/app/models/shop_customer.rb +25 -5
- data/app/models/shop_group.rb +15 -0
- data/app/models/shop_grouping.rb +6 -0
- data/app/models/shop_line_item.rb +7 -6
- data/app/models/shop_order.rb +44 -16
- data/app/models/shop_package.rb +74 -0
- data/app/models/shop_packing.rb +22 -0
- data/app/models/shop_page.rb +7 -0
- data/app/models/shop_payment.rb +5 -1
- data/app/models/shop_product.rb +86 -48
- data/app/models/shop_product_attachment.rb +5 -2
- data/app/models/shop_product_variant.rb +31 -0
- data/app/models/shop_variant.rb +25 -0
- data/app/views/admin/shop/categories/edit.html.haml +9 -10
- data/app/views/admin/shop/categories/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_form.html.haml +14 -0
- data/app/views/admin/shop/categories/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/categories/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/categories/edit/_meta.html.haml +8 -7
- data/app/views/admin/shop/categories/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_page.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/categories/index/_category.html.haml +11 -10
- data/app/views/admin/shop/categories/new.html.haml +10 -9
- data/app/views/admin/shop/customers/edit.html.haml +8 -10
- data/app/views/admin/shop/customers/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/customers/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/customers/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/customers/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/customers/edit/_parts.html.haml +9 -4
- data/app/views/admin/shop/customers/edit/inputs/_email.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/parts/_orders.html.haml +10 -6
- data/app/views/admin/shop/customers/index.html.haml +4 -1
- data/app/views/admin/shop/customers/index/_customer.html.haml +3 -3
- data/app/views/admin/shop/customers/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/customers/index/_head.html.haml +4 -0
- data/app/views/admin/shop/customers/new.html.haml +9 -9
- data/app/views/admin/shop/orders/edit.html.haml +11 -0
- data/app/views/admin/shop/orders/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/orders/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/orders/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/orders/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/parts/_address.html.haml +7 -0
- data/app/views/admin/shop/orders/edit/parts/_addresses.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/parts/_customer.html.haml +3 -0
- data/app/views/admin/shop/orders/edit/parts/_items.html.haml +8 -0
- data/app/views/admin/shop/orders/index.html.haml +10 -30
- data/app/views/admin/shop/orders/index/_foot.html.haml +3 -0
- data/app/views/admin/shop/orders/index/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/index/_order.html.haml +13 -0
- data/app/views/admin/shop/orders/index/buttons/_all.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_new.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_paid.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_shipped.html.haml +1 -0
- data/app/views/admin/shop/packages/edit.html.haml +11 -0
- data/app/views/admin/shop/packages/edit/_foot.html.haml +17 -0
- data/app/views/admin/shop/packages/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/packages/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/packages/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/packages/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/packages/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +5 -0
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +7 -0
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +8 -0
- data/app/views/admin/shop/packages/index.html.haml +13 -0
- data/app/views/admin/shop/packages/index/_foot.html.haml +7 -0
- data/app/views/admin/shop/packages/index/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/index/_package.html.haml +9 -0
- data/app/views/admin/shop/packages/new.html.haml +11 -0
- data/app/views/admin/shop/packages/remove.html.haml +12 -0
- data/app/views/admin/shop/products/edit.html.haml +9 -12
- data/app/views/admin/shop/products/edit/_foot.html.haml +19 -0
- data/app/views/admin/shop/products/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/products/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/products/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/products/edit/_meta.html.haml +8 -8
- data/app/views/admin/shop/products/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/products/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +1 -0
- data/app/views/admin/shop/products/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/products/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/products/edit/meta/_category.html.haml +6 -5
- data/app/views/admin/shop/products/edit/meta/_page.html.haml +2 -0
- data/app/views/admin/shop/products/edit/meta/_sku.html.haml +6 -5
- data/app/views/admin/shop/products/edit/parts/_customers.html.haml +5 -0
- data/app/views/admin/shop/products/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/products/edit/parts/_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +3 -0
- data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +4 -4
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +16 -0
- data/app/views/admin/shop/products/edit/{_image.html.haml → shared/_image.html.haml} +0 -0
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +6 -0
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +10 -0
- data/app/views/admin/shop/products/index.html.haml +6 -3
- data/app/views/admin/shop/products/index/_foot.html.haml +10 -0
- data/app/views/admin/shop/products/index/_head.html.haml +4 -0
- data/app/views/admin/shop/products/index/_product.html.haml +18 -10
- data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_packages.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -0
- data/app/views/admin/shop/products/new.html.haml +10 -9
- data/app/views/admin/shop/variants/edit.html.haml +11 -0
- data/app/views/admin/shop/variants/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/variants/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/variants/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/variants/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +3 -0
- data/app/views/admin/shop/variants/index.html.haml +13 -0
- data/app/views/admin/shop/variants/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_variant.html.haml +9 -0
- data/app/views/admin/shop/variants/new.html.haml +11 -0
- data/app/views/admin/shop/variants/remove.html.haml +12 -0
- data/config/locales/en.yml +8 -1
- data/config/routes.rb +11 -22
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +101 -0
- data/db/migrate/20100929011607_drop_shop_addressables.rb +25 -0
- data/db/migrate/20100929030510_create_shop_groups.rb +19 -0
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +11 -0
- data/db/migrate/20100929081200_create_variants.rb +20 -0
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +25 -0
- data/db/migrate/20100929145641_change_created_by_to_id.rb +75 -0
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +9 -0
- data/db/migrate/20100930235221_create_packages.rb +31 -0
- data/db/migrate/20101005231713_create_page_ids.rb +11 -0
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +73 -0
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +9 -0
- data/lib/shop/controllers/application_controller.rb +1 -1
- data/lib/shop/interface/categories.rb +29 -0
- data/lib/shop/interface/customers.rb +15 -15
- data/lib/shop/interface/orders.rb +34 -0
- data/lib/shop/interface/packages.rb +34 -0
- data/lib/shop/interface/products.rb +18 -31
- data/lib/shop/interface/variants.rb +34 -0
- data/lib/shop/models/form_extension.rb +23 -0
- data/lib/shop/models/page.rb +3 -2
- data/lib/shop/tags/address.rb +3 -3
- data/lib/shop/tags/cart.rb +12 -16
- data/lib/shop/tags/category.rb +4 -6
- data/lib/shop/tags/helpers.rb +131 -30
- data/lib/shop/tags/item.rb +16 -33
- data/lib/shop/tags/package.rb +95 -0
- data/lib/shop/tags/product.rb +11 -16
- data/lib/shop/tags/product_variant.rb +52 -0
- data/mockups/discounts/new-edit.bmml +492 -0
- data/public/javascripts/admin/extensions/shop/edit.js +20 -0
- data/public/javascripts/admin/extensions/shop/packages/edit.js +109 -0
- data/public/javascripts/admin/extensions/shop/products/edit.js +64 -65
- data/public/javascripts/admin/extensions/shop/products/index.js +31 -36
- data/public/stylesheets/sass/admin/extensions/shop/edit.sass +58 -11
- data/public/stylesheets/sass/admin/extensions/shop/index.sass +104 -53
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +162 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +115 -36
- data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +12 -20
- data/radiant-shop-extension.gemspec +182 -38
- data/shop_extension.rb +29 -25
- data/spec/controllers/admin/shop/categories_controller_spec.rb +76 -191
- data/spec/controllers/admin/shop/customers_controller_spec.rb +67 -0
- data/spec/controllers/admin/shop/orders_controller_spec.rb +85 -0
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +188 -0
- data/spec/controllers/admin/shop/packages_controller_spec.rb +32 -0
- data/spec/controllers/admin/shop/products/images_controller_spec.rb +10 -15
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +53 -0
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +116 -0
- data/spec/controllers/admin/shop/products_controller_spec.rb +80 -148
- data/spec/controllers/admin/shop/variants_controller_spec.rb +67 -0
- data/spec/datasets/forms.rb +23 -8
- data/spec/datasets/shop_addresses.rb +1 -4
- data/spec/datasets/shop_categories.rb +25 -4
- data/spec/datasets/shop_groups.rb +15 -0
- data/spec/datasets/shop_line_items.rb +4 -3
- data/spec/datasets/shop_orders.rb +6 -15
- data/spec/datasets/shop_packages.rb +25 -0
- data/spec/datasets/shop_payments.rb +12 -0
- data/spec/datasets/{images.rb → shop_product_attachments.rb} +9 -1
- data/spec/datasets/shop_product_variants.rb +22 -0
- data/spec/datasets/shop_products.rb +28 -18
- data/spec/datasets/shop_variants.rb +17 -0
- data/spec/lib/shop/models/image_spec.rb +4 -4
- data/spec/lib/shop/tags/address_spec.rb +3 -3
- data/spec/lib/shop/tags/cart_spec.rb +32 -43
- data/spec/lib/shop/tags/category_spec.rb +58 -93
- data/spec/lib/shop/tags/helpers_spec.rb +162 -69
- data/spec/lib/shop/tags/item_spec.rb +116 -158
- data/spec/lib/shop/tags/package_spec.rb +342 -0
- data/spec/lib/shop/tags/product_spec.rb +29 -26
- data/spec/lib/shop/tags/product_variant_spec.rb +175 -0
- data/spec/models/form_address_spec.rb +166 -0
- data/spec/models/form_checkout_spec.rb +27 -157
- data/spec/models/shop_address_spec.rb +81 -0
- data/spec/models/shop_category_spec.rb +114 -31
- data/spec/models/shop_customer_spec.rb +105 -0
- data/spec/models/shop_group_spec.rb +38 -0
- data/spec/models/shop_line_item_spec.rb +5 -5
- data/spec/models/shop_order_spec.rb +89 -83
- data/spec/models/shop_package_spec.rb +117 -0
- data/spec/models/shop_packing_spec.rb +67 -0
- data/spec/models/shop_payment_spec.rb +19 -0
- data/spec/models/shop_product_attachment_spec.rb +4 -3
- data/spec/models/shop_product_spec.rb +171 -92
- data/spec/models/shop_product_variant_spec.rb +92 -0
- data/spec/models/shop_variant_spec.rb +47 -0
- metadata +183 -39
- data/app/controllers/shop/categories_controller.rb +0 -45
- data/app/controllers/shop/line_items_controller.rb +0 -165
- data/app/controllers/shop/orders_controller.rb +0 -16
- data/app/controllers/shop/products_controller.rb +0 -48
- data/app/models/shop_addressable.rb +0 -11
- data/app/views/admin/shop/categories/edit/_fields.html.haml +0 -28
- data/app/views/admin/shop/categories/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/categories/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/customers/edit/_fields.html.haml +0 -33
- data/app/views/admin/shop/customers/index/_bottom.html.haml +0 -4
- data/app/views/admin/shop/products/edit/_fields.html.haml +0 -38
- data/app/views/admin/shop/products/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/products/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/products/index/_bottom.html.haml +0 -5
- data/spec/controllers/shop/categories_controller_spec.rb +0 -42
- data/spec/controllers/shop/line_items_controller_spec.rb +0 -256
- data/spec/controllers/shop/orders_controller_specs.rb +0 -37
- data/spec/controllers/shop/products_controller_spec.rb +0 -51
- data/vendor/plugins/json_fields/.gitignore +0 -3
- data/vendor/plugins/json_fields/MIT-LICENSE +0 -20
- data/vendor/plugins/json_fields/README.rdoc +0 -65
- data/vendor/plugins/json_fields/Rakefile +0 -55
- data/vendor/plugins/json_fields/init.rb +0 -2
- data/vendor/plugins/json_fields/lib/json_fields.rb +0 -99
- data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +0 -124
- data/vendor/plugins/json_fields/spec/spec.opts +0 -6
- data/vendor/plugins/json_fields/spec/spec_helper.rb +0 -29
- data/vendor/plugins/json_fields/spec/test_models.rb +0 -12
data/shop_extension.rb
CHANGED
@@ -4,33 +4,38 @@ class ShopExtension < Radiant::Extension
|
|
4
4
|
url "http://github.com/squaretalent/radiant-shop-extension"
|
5
5
|
|
6
6
|
extension_config do |config|
|
7
|
-
config.gem 'activemerchant',
|
8
|
-
config.gem 'will_paginate',
|
9
|
-
config.gem 'radiant-layouts-extension', :version => '0.9.1', :lib => false
|
7
|
+
config.gem 'activemerchant', :version => '1.7.3', :lib => 'active_merchant'
|
8
|
+
config.gem 'will_paginate', :version => '2.3.14'
|
10
9
|
end
|
11
10
|
|
12
11
|
UserActionObserver.instance.send :add_observer!, ShopProduct
|
13
12
|
UserActionObserver.instance.send :add_observer!, ShopCategory
|
14
13
|
UserActionObserver.instance.send :add_observer!, ShopOrder
|
14
|
+
UserActionObserver.instance.send :add_observer!, ShopProductAttachment
|
15
|
+
UserActionObserver.instance.send :add_observer!, ShopProductVariant
|
16
|
+
UserActionObserver.instance.send :add_observer!, ShopVariant
|
17
|
+
UserActionObserver.instance.send :add_observer!, ShopPackage
|
15
18
|
|
16
|
-
def activate
|
17
|
-
|
19
|
+
def activate
|
18
20
|
# View Hooks
|
19
21
|
unless defined? admin.products
|
20
|
-
Radiant::AdminUI.send :include, Shop::Interface::Products, Shop::Interface::
|
21
|
-
|
22
|
-
admin.
|
23
|
-
admin.
|
24
|
-
admin.
|
22
|
+
Radiant::AdminUI.send :include, Shop::Interface::Categories, Shop::Interface::Customers, Shop::Interface::Orders, Shop::Interface::Packages, Shop::Interface::Products, Shop::Interface::Variants
|
23
|
+
|
24
|
+
admin.categories= Radiant::AdminUI.load_default_shop_categories_regions
|
25
|
+
admin.customers = Radiant::AdminUI.load_default_shop_customers_regions
|
26
|
+
admin.orders = Radiant::AdminUI.load_default_shop_orders_regions
|
27
|
+
admin.packages = Radiant::AdminUI.load_default_shop_packages_regions
|
28
|
+
admin.products = Radiant::AdminUI.load_default_shop_products_regions
|
29
|
+
admin.variants = Radiant::AdminUI.load_default_shop_variants_regions
|
25
30
|
end
|
26
31
|
|
27
|
-
if admin.respond_to? :page
|
28
|
-
|
29
|
-
|
30
|
-
end
|
32
|
+
# if admin.respond_to? :page
|
33
|
+
# admin.page.edit.add :layout_row, 'shop_category'
|
34
|
+
# admin.page.edit.add :layout_row, 'shop_product'
|
35
|
+
# end
|
31
36
|
|
32
37
|
# Tags
|
33
|
-
Page.send :include, Shop::Tags::Core, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::
|
38
|
+
Page.send :include, Shop::Tags::Core, Shop::Tags::Address, Shop::Tags::Card, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Package, Shop::Tags::Product, Shop::Tags::ProductVariant, Shop::Tags::Responses
|
34
39
|
|
35
40
|
# Model Includes
|
36
41
|
Page.send :include, Shop::Models::Page
|
@@ -41,23 +46,22 @@ class ShopExtension < Radiant::Extension
|
|
41
46
|
SiteController.send :include, Shop::Controllers::SiteController
|
42
47
|
|
43
48
|
# Tabs3
|
49
|
+
|
44
50
|
tab "Shop" do
|
45
|
-
add_item "Products",
|
46
|
-
add_item "
|
51
|
+
add_item "Products", "/admin/shop"
|
52
|
+
add_item "Orders", "/admin/shop/orders"
|
53
|
+
add_item "Customers", "/admin/shop/customers"
|
47
54
|
end
|
48
55
|
|
49
|
-
|
50
|
-
Radiant::Config['shop.
|
51
|
-
Radiant::Config['shop.product_layout'] ||= 'Product'
|
52
|
-
Radiant::Config['shop.category_layout'] ||= 'Products'
|
53
|
-
Radiant::Config['shop.order_layout'] ||= 'Cart'
|
56
|
+
Radiant::Config['shop.root_page_id'] ||= (Page.first(:conditions => { :slug => 'shop'}).id rescue (Page.first.id rescue nil))
|
57
|
+
Radiant::Config['shop.root_page_slug'] ||= 'shop'
|
54
58
|
|
55
|
-
Radiant::Config['shop.
|
56
|
-
Radiant::Config['shop.
|
59
|
+
Radiant::Config['shop.layout_product'] ||= 'Product'
|
60
|
+
Radiant::Config['shop.layout_category'] ||= 'Products'
|
57
61
|
|
58
62
|
Radiant::Config['shop.price_unit'] ||= '$'
|
59
63
|
Radiant::Config['shop.price_precision'] ||= 2
|
60
|
-
Radiant::Config['shop.
|
64
|
+
Radiant::Config['shop.price_separator'] ||= '.'
|
61
65
|
Radiant::Config['shop.price_delimiter'] ||= ','
|
62
66
|
|
63
67
|
# Scoped Customer Welcome Page
|
@@ -2,121 +2,40 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Admin::Shop::CategoriesController do
|
4
4
|
|
5
|
-
dataset :users
|
5
|
+
dataset :users, :shop_categories, :shop_products, :pages
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
login_as :admin
|
9
9
|
|
10
|
-
@
|
11
|
-
@
|
12
|
-
|
13
|
-
@shop_product = ShopProduct.new
|
14
|
-
@shop_products = [ @shop_product ]
|
15
|
-
|
16
|
-
stub(@shop_category).id { 1 }
|
17
|
-
stub(@shop_category).products { @shop_products }
|
10
|
+
@category = shop_categories(:bread)
|
11
|
+
@products = @category.products
|
18
12
|
end
|
19
13
|
|
20
14
|
describe '#index' do
|
21
|
-
before :each do
|
22
|
-
mock(ShopCategory).find(:all) { @shop_categories } # Resource Controller
|
23
|
-
mock(ShopCategory).search('search') { @shop_categories }
|
24
|
-
end
|
25
|
-
|
26
15
|
context 'html' do
|
27
|
-
|
28
|
-
get :index
|
29
|
-
|
30
|
-
|
31
|
-
it 'should not assign an error or notice and redirect to shop_products path' do
|
32
|
-
response.should redirect_to(admin_shop_products_path)
|
16
|
+
it 'should redirect to shop_products path' do
|
17
|
+
get :index
|
18
|
+
|
33
19
|
flash.now[:error].should be_nil
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should assign the shop_product_images instance variable' do
|
38
|
-
assigns(:shop_categories).should === @shop_categories
|
20
|
+
response.should redirect_to(admin_shop_products_path)
|
39
21
|
end
|
40
22
|
end
|
41
23
|
|
42
24
|
context 'js' do
|
43
|
-
before :each do
|
44
|
-
get :index, :search => 'search', :format => 'js'
|
45
|
-
end
|
46
|
-
|
47
25
|
it 'should render the collection partial and success status' do
|
26
|
+
get :index, :format => 'js'
|
27
|
+
|
48
28
|
response.should be_success
|
49
29
|
response.should render_template('/admin/shop/categories/index/_category')
|
50
30
|
end
|
51
|
-
|
52
|
-
it 'should assign the shop_categories instance variable' do
|
53
|
-
assigns(:shop_categories).should === @shop_categories
|
54
|
-
end
|
55
31
|
end
|
56
32
|
|
57
|
-
context 'json' do
|
58
|
-
before :each do
|
59
|
-
get :index, :search => 'search', :format => 'json'
|
60
|
-
end
|
61
|
-
|
33
|
+
context 'json' do
|
62
34
|
it 'should return a json object of the array and success status' do
|
35
|
+
get :index, :format => 'json'
|
36
|
+
|
63
37
|
response.should be_success
|
64
|
-
response.body.should ===
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should assign the shop_product_images instance variable' do
|
68
|
-
assigns(:shop_categories).should === @shop_categories
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#products' do
|
75
|
-
before :each do
|
76
|
-
mock(ShopCategory).find('1') { @shop_category }
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'html' do
|
80
|
-
before :each do
|
81
|
-
get :products, :id => @shop_category.id
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should render successfully' do
|
85
|
-
response.should render_template( '/admin/shop/products/index' )
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should assign the shop_products instance variable' do
|
89
|
-
assigns(:shop_products).should === @shop_products
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'js' do
|
94
|
-
before :each do
|
95
|
-
get :products, :id => @shop_category.id, :format => 'js'
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should render the collection template' do
|
99
|
-
response.should be_success
|
100
|
-
response.should render_template( '/admin/shop/products/index/_product' )
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should assign the shop_products instance variable' do
|
104
|
-
assigns(:shop_products).should === @shop_products
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'json' do
|
109
|
-
before :each do
|
110
|
-
get :products, :id => @shop_category.id, :format => 'json'
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should assign the shop_products and render the collection template' do
|
114
|
-
response.should be_success
|
115
|
-
response.body.should === @shop_products.to_json(ShopProduct.params)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should assign the shop_products instance variable' do
|
119
|
-
assigns(:shop_products).should === @shop_products
|
38
|
+
response.body.should === assigns(:shop_categories).to_json
|
120
39
|
end
|
121
40
|
end
|
122
41
|
|
@@ -124,9 +43,9 @@ describe Admin::Shop::CategoriesController do
|
|
124
43
|
|
125
44
|
describe '#sort' do
|
126
45
|
before :each do
|
127
|
-
@
|
128
|
-
|
129
|
-
|
46
|
+
@params = [
|
47
|
+
"categories[]=2",
|
48
|
+
"categories[]=1"
|
130
49
|
].join('&')
|
131
50
|
end
|
132
51
|
|
@@ -134,6 +53,7 @@ describe Admin::Shop::CategoriesController do
|
|
134
53
|
context 'html' do
|
135
54
|
it 'should assign an error and redirect to admin_shop_products_path path' do
|
136
55
|
put :sort
|
56
|
+
|
137
57
|
flash.now[:error].should_not be_nil
|
138
58
|
response.should redirect_to(admin_shop_products_path)
|
139
59
|
end
|
@@ -142,6 +62,7 @@ describe Admin::Shop::CategoriesController do
|
|
142
62
|
context 'js' do
|
143
63
|
it 'should return an error string and failure status' do
|
144
64
|
put :sort, :format => 'js'
|
65
|
+
|
145
66
|
response.should_not be_success
|
146
67
|
response.body.should === 'Could not sort Categories.'
|
147
68
|
end
|
@@ -150,6 +71,7 @@ describe Admin::Shop::CategoriesController do
|
|
150
71
|
context 'json' do
|
151
72
|
it 'should return a json error object and failure status' do
|
152
73
|
put :sort, :format => 'json'
|
74
|
+
|
153
75
|
response.should_not be_success
|
154
76
|
JSON.parse(response.body)['error'].should === 'Could not sort Categories.'
|
155
77
|
end
|
@@ -159,12 +81,13 @@ describe Admin::Shop::CategoriesController do
|
|
159
81
|
context 'categories are passed' do
|
160
82
|
context 'could not sort' do
|
161
83
|
before :each do
|
162
|
-
mock(ShopCategory).
|
84
|
+
mock(ShopCategory).sort(anything) { raise ActiveRecord::RecordNotFound }
|
163
85
|
end
|
164
86
|
|
165
87
|
context 'html' do
|
166
88
|
it 'should assign an error and redirect to admin_shop_products_path path' do
|
167
|
-
put :sort, :categories => @
|
89
|
+
put :sort, :categories => @params
|
90
|
+
|
168
91
|
flash.now[:error].should === 'Could not sort Categories.'
|
169
92
|
response.should redirect_to(admin_shop_products_path)
|
170
93
|
end
|
@@ -172,7 +95,8 @@ describe Admin::Shop::CategoriesController do
|
|
172
95
|
|
173
96
|
context 'js' do
|
174
97
|
it 'should return an error string and failure status' do
|
175
|
-
put :sort, :categories => @
|
98
|
+
put :sort, :categories => @params, :format => 'js'
|
99
|
+
|
176
100
|
response.should_not be_success
|
177
101
|
response.body.should === 'Could not sort Categories.'
|
178
102
|
end
|
@@ -180,7 +104,8 @@ describe Admin::Shop::CategoriesController do
|
|
180
104
|
|
181
105
|
context 'json' do
|
182
106
|
it 'should return a json error object and failure status' do
|
183
|
-
put :sort, :categories => @
|
107
|
+
put :sort, :categories => @params, :format => 'json'
|
108
|
+
|
184
109
|
response.should_not be_success
|
185
110
|
JSON.parse(response.body)['error'].should === 'Could not sort Categories.'
|
186
111
|
end
|
@@ -189,21 +114,22 @@ describe Admin::Shop::CategoriesController do
|
|
189
114
|
|
190
115
|
context 'successfully sorted' do
|
191
116
|
before :each do
|
192
|
-
mock(ShopCategory).
|
193
|
-
mock(ShopCategory).find('1').stub!.update_attributes!({:position => 2}) { true }
|
117
|
+
mock(ShopCategory).sort(anything) { true }
|
194
118
|
end
|
195
119
|
|
196
120
|
context 'html' do
|
197
121
|
it 'should assign a notice and redirect to admin_shop_products_path path' do
|
198
|
-
put :sort, :categories => @
|
199
|
-
|
122
|
+
put :sort, :categories => @params
|
123
|
+
|
124
|
+
flash.now[:error].should be_nil
|
200
125
|
response.should redirect_to(admin_shop_products_path)
|
201
126
|
end
|
202
127
|
end
|
203
128
|
|
204
129
|
context 'js' do
|
205
130
|
it 'should return success string and success status' do
|
206
|
-
put :sort, :categories => @
|
131
|
+
put :sort, :categories => @params, :format => 'js'
|
132
|
+
|
207
133
|
response.should be_success
|
208
134
|
response.body.should === 'Categories successfully sorted.'
|
209
135
|
end
|
@@ -211,7 +137,8 @@ describe Admin::Shop::CategoriesController do
|
|
211
137
|
|
212
138
|
context 'json' do
|
213
139
|
it 'should return a json success object and success status' do
|
214
|
-
put :sort, :categories => @
|
140
|
+
put :sort, :categories => @params, :format => 'json'
|
141
|
+
|
215
142
|
response.should be_success
|
216
143
|
JSON.parse(response.body)['notice'].should === 'Categories successfully sorted.'
|
217
144
|
end
|
@@ -221,14 +148,7 @@ describe Admin::Shop::CategoriesController do
|
|
221
148
|
end
|
222
149
|
|
223
150
|
describe '#create' do
|
224
|
-
before :each do
|
225
|
-
mock(ShopCategory).new { @shop_category }
|
226
|
-
end
|
227
151
|
context 'category could not be created' do
|
228
|
-
before :each do
|
229
|
-
mock(@shop_category).save! { raise ActiveRecord::RecordNotSaved }
|
230
|
-
end
|
231
|
-
|
232
152
|
context 'html' do
|
233
153
|
it 'should assign a flash error and render new' do
|
234
154
|
post :create, :shop_category => {}
|
@@ -259,58 +179,60 @@ describe Admin::Shop::CategoriesController do
|
|
259
179
|
|
260
180
|
context 'category successfully created' do
|
261
181
|
before :each do
|
262
|
-
|
182
|
+
@params = {
|
183
|
+
:page_attributes => {
|
184
|
+
:title => 'name',
|
185
|
+
:parent_id => pages(:home).id,
|
186
|
+
:parts_attributes => [{
|
187
|
+
:name => 'description',
|
188
|
+
:content => '*name*'
|
189
|
+
}]
|
190
|
+
}
|
191
|
+
}
|
263
192
|
end
|
264
|
-
|
265
193
|
context 'html' do
|
266
194
|
context 'not continue' do
|
267
195
|
it 'should assign a notice and redirect to edit_shop_product path' do
|
268
|
-
post :create, :shop_category =>
|
269
|
-
|
196
|
+
post :create, :shop_category => @params
|
197
|
+
|
270
198
|
response.should redirect_to(admin_shop_categories_path)
|
271
199
|
end
|
272
200
|
end
|
273
201
|
context 'continue' do
|
274
202
|
it 'should assign a notice and redirect to edit_shop_product path' do
|
275
|
-
post :create, :shop_category =>
|
276
|
-
|
277
|
-
response.should redirect_to(edit_admin_shop_category_path(
|
203
|
+
post :create, :shop_category => @params, :continue => true
|
204
|
+
|
205
|
+
response.should redirect_to(edit_admin_shop_category_path(assigns(:shop_category)))
|
278
206
|
end
|
279
207
|
end
|
280
208
|
end
|
281
209
|
|
282
210
|
context 'js' do
|
283
211
|
it 'should render the collection partial and success status' do
|
284
|
-
post :create, :shop_category =>
|
212
|
+
post :create, :shop_category => @params, :format => 'js'
|
213
|
+
|
285
214
|
response.should be_success
|
286
|
-
assigns(:shop_category).should === @shop_category
|
287
215
|
response.should render_template('/admin/shop/categories/index/_category')
|
288
216
|
end
|
289
217
|
end
|
290
218
|
|
291
219
|
context 'json' do
|
292
220
|
it 'should render the json object and redirect to json show' do
|
293
|
-
post :create ,:shop_category =>
|
221
|
+
post :create ,:shop_category => @params, :format => 'json'
|
222
|
+
|
294
223
|
response.should be_success
|
295
|
-
response.body.should ===
|
224
|
+
response.body.should === assigns(:shop_category).to_json
|
296
225
|
end
|
297
226
|
end
|
298
227
|
end
|
299
228
|
end
|
300
229
|
|
301
230
|
describe '#update' do
|
302
|
-
before :each do
|
303
|
-
mock(ShopCategory).find('1') { @shop_category }
|
304
|
-
end
|
305
|
-
|
306
231
|
context 'could not update' do
|
307
|
-
before :each do
|
308
|
-
stub(@shop_category).update_attributes!({}) { raise ActiveRecord::RecordNotSaved }
|
309
|
-
end
|
310
|
-
|
311
232
|
context 'html' do
|
312
233
|
it 'should assign a flash error and render edit' do
|
313
|
-
put :update, :id => @
|
234
|
+
put :update, :id => @category.id, :shop_category => { :title => 'failure' }
|
235
|
+
|
314
236
|
response.should render_template(:edit)
|
315
237
|
flash.now[:error].should === 'Could not update Category.'
|
316
238
|
end
|
@@ -318,7 +240,8 @@ describe Admin::Shop::CategoriesController do
|
|
318
240
|
|
319
241
|
context 'js' do
|
320
242
|
it 'should render the error and failure status' do
|
321
|
-
put :update, :id => @
|
243
|
+
put :update, :id => @category.id, :shop_category => { :title => 'failure' }, :format => 'js'
|
244
|
+
|
322
245
|
response.should_not be_success
|
323
246
|
response.body.should === 'Could not update Category.'
|
324
247
|
end
|
@@ -326,7 +249,8 @@ describe Admin::Shop::CategoriesController do
|
|
326
249
|
|
327
250
|
context 'json' do
|
328
251
|
it 'should assign an error json object and failure status' do
|
329
|
-
put :update, :id => @
|
252
|
+
put :update, :id => @category.id, :shop_category => { :title => 'failure' }, :format => 'json'
|
253
|
+
|
330
254
|
response.should_not be_success
|
331
255
|
JSON.parse(response.body)['error'].should === 'Could not update Category.'
|
332
256
|
end
|
@@ -334,30 +258,27 @@ describe Admin::Shop::CategoriesController do
|
|
334
258
|
end
|
335
259
|
|
336
260
|
context 'successfully updated' do
|
337
|
-
before :each do
|
338
|
-
stub(@shop_category).update_attributes!({}) { true }
|
339
|
-
end
|
340
|
-
|
341
261
|
context 'html' do
|
342
262
|
context 'not continue' do
|
343
263
|
it 'should assign a notice and redirect to edit_shop_product path' do
|
344
|
-
put :update, :id => @
|
345
|
-
|
264
|
+
put :update, :id => @category.id, :shop_category => { :page_attributes => { :title => 'success' } }
|
265
|
+
|
346
266
|
response.should redirect_to(admin_shop_categories_path)
|
347
267
|
end
|
348
268
|
end
|
349
269
|
context 'continue' do
|
350
270
|
it 'should assign a notice and redirect to edit_shop_product path' do
|
351
|
-
put :update, :id => @
|
352
|
-
|
353
|
-
response.should redirect_to(edit_admin_shop_category_path(
|
271
|
+
put :update, :id => @category.id, :shop_category => { :page_attributes => { :title => 'success' } }, :continue => true
|
272
|
+
|
273
|
+
response.should redirect_to(edit_admin_shop_category_path(assigns(:shop_category)))
|
354
274
|
end
|
355
275
|
end
|
356
276
|
end
|
357
277
|
|
358
278
|
context 'js' do
|
359
279
|
it 'should render the partial and success status' do
|
360
|
-
put :update, :id => @
|
280
|
+
put :update, :id => @category.id, :shop_category => { :page_attributes => { :title => 'success' } }, :format => 'js'
|
281
|
+
|
361
282
|
response.should be_success
|
362
283
|
response.should render_template('/admin/shop/categories/index/_category')
|
363
284
|
end
|
@@ -365,66 +286,29 @@ describe Admin::Shop::CategoriesController do
|
|
365
286
|
|
366
287
|
context 'json' do
|
367
288
|
it 'should assign the json object and success status' do
|
368
|
-
put :update, :id => @
|
289
|
+
put :update, :id => @category.id, :shop_category => {}, :format => 'json'
|
290
|
+
|
369
291
|
response.should be_success
|
370
|
-
response.body.should ===
|
292
|
+
response.body.should === assigns(:shop_category).to_json
|
371
293
|
end
|
372
294
|
end
|
373
295
|
end
|
374
296
|
end
|
375
297
|
|
376
298
|
describe '#destroy' do
|
377
|
-
before :each do
|
378
|
-
mock(ShopCategory).find('1') { @shop_category }
|
379
|
-
end
|
380
|
-
|
381
|
-
context 'product not destroyed' do
|
382
|
-
before :each do
|
383
|
-
stub(@shop_category).destroy { raise ActiveRecord::RecordNotFound }
|
384
|
-
end
|
385
|
-
|
386
|
-
context 'html' do
|
387
|
-
it 'should assign a flash error and render remove' do
|
388
|
-
delete :destroy, :id => 1
|
389
|
-
flash.now[:error].should === 'Could not delete Category.'
|
390
|
-
response.should render_template(:remove)
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
context 'js' do
|
395
|
-
it 'should render an error and failure status' do
|
396
|
-
delete :destroy, :id => 1, :format => 'js'
|
397
|
-
response.body.should === 'Could not delete Category.'
|
398
|
-
response.should_not be_success
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
context 'json' do
|
403
|
-
it 'should render an error and failure status' do
|
404
|
-
delete :destroy, :id => 1, :format => 'json'
|
405
|
-
JSON.parse(response.body)['error'].should === 'Could not delete Category.'
|
406
|
-
response.should_not be_success
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
end
|
411
|
-
|
412
299
|
context 'product successfully destroyed' do
|
413
|
-
before :each do
|
414
|
-
stub(@shop_category).destroy { true }
|
415
|
-
end
|
416
|
-
|
417
300
|
context 'html' do
|
418
301
|
it 'should assign a flash notice and redirect to shop_categories path' do
|
419
|
-
delete :destroy, :id =>
|
420
|
-
|
302
|
+
delete :destroy, :id => @category.id
|
303
|
+
|
421
304
|
response.should redirect_to(admin_shop_categories_path)
|
422
305
|
end
|
423
306
|
end
|
424
307
|
|
425
308
|
context 'js' do
|
426
309
|
it 'should render success message and success status' do
|
427
|
-
delete :destroy, :id =>
|
310
|
+
delete :destroy, :id => @category.id, :format => 'js'
|
311
|
+
|
428
312
|
response.body.should === 'Category deleted successfully.'
|
429
313
|
response.should be_success
|
430
314
|
end
|
@@ -432,7 +316,8 @@ describe Admin::Shop::CategoriesController do
|
|
432
316
|
|
433
317
|
context 'json' do
|
434
318
|
it 'should return a success json object and success status' do
|
435
|
-
delete :destroy, :id =>
|
319
|
+
delete :destroy, :id => @category.id, :format => 'json'
|
320
|
+
|
436
321
|
JSON.parse(response.body)['notice'].should === 'Category deleted successfully.'
|
437
322
|
response.should be_success
|
438
323
|
end
|