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
@@ -2,13 +2,13 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Shop::Tags::Product do
|
4
4
|
|
5
|
-
dataset :pages, :shop_products
|
5
|
+
dataset :pages, :shop_products, :shop_product_attachments
|
6
6
|
|
7
7
|
it 'should describe these tags' do
|
8
8
|
Shop::Tags::Product.tags.sort.should == [
|
9
|
-
'shop:if_products',
|
10
|
-
'shop:unless_products',
|
11
9
|
'shop:products',
|
10
|
+
'shop:products:if_products',
|
11
|
+
'shop:products:unless_products',
|
12
12
|
'shop:products:each',
|
13
13
|
'shop:product',
|
14
14
|
'shop:product:id',
|
@@ -36,40 +36,42 @@ describe Shop::Tags::Product do
|
|
36
36
|
@images = [ images(:soft_bread_front), images(:soft_bread_back), images(:soft_bread_top) ]
|
37
37
|
end
|
38
38
|
|
39
|
-
describe '<r:shop:
|
40
|
-
context '
|
39
|
+
describe '<r:shop:products>' do
|
40
|
+
context 'no products exist' do
|
41
41
|
before :each do
|
42
|
-
mock(Shop::Tags::Helpers).current_products(anything) {
|
42
|
+
mock(Shop::Tags::Helpers).current_products(anything) { [] }
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should render' do
|
46
|
-
tag = %{<r:shop:
|
46
|
+
tag = %{<r:shop:products>success</r:shop:products>}
|
47
47
|
exp = %{success}
|
48
|
+
|
48
49
|
@page.should render(tag).as(exp)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
context '
|
53
|
+
context 'products exist' do
|
53
54
|
before :each do
|
54
|
-
mock(Shop::Tags::Helpers).current_products(anything) {
|
55
|
+
mock(Shop::Tags::Helpers).current_products(anything) { @products }
|
55
56
|
end
|
56
57
|
|
57
|
-
it 'should
|
58
|
-
tag = %{<r:shop:
|
59
|
-
exp = %{}
|
58
|
+
it 'should render' do
|
59
|
+
tag = %{<r:shop:products>success</r:shop:products>}
|
60
|
+
exp = %{success}
|
61
|
+
|
60
62
|
@page.should render(tag).as(exp)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
|
-
describe '<r:shop:
|
67
|
+
describe '<r:shop:products:if_products>' do
|
66
68
|
context 'success' do
|
67
69
|
before :each do
|
68
|
-
mock(Shop::Tags::Helpers).current_products(anything) {
|
70
|
+
mock(Shop::Tags::Helpers).current_products(anything) { @products }
|
69
71
|
end
|
70
72
|
|
71
73
|
it 'should render' do
|
72
|
-
tag = %{<r:shop:
|
74
|
+
tag = %{<r:shop:products:if_products>success</r:shop:products:if_products>}
|
73
75
|
exp = %{success}
|
74
76
|
@page.should render(tag).as(exp)
|
75
77
|
end
|
@@ -77,40 +79,38 @@ describe Shop::Tags::Product do
|
|
77
79
|
|
78
80
|
context 'failure' do
|
79
81
|
before :each do
|
80
|
-
mock(Shop::Tags::Helpers).current_products(anything) {
|
82
|
+
mock(Shop::Tags::Helpers).current_products(anything) { [] }
|
81
83
|
end
|
82
84
|
|
83
85
|
it 'should not render' do
|
84
|
-
tag = %{<r:shop:
|
86
|
+
tag = %{<r:shop:products:if_products>failure</r:shop:products:if_products>}
|
85
87
|
exp = %{}
|
86
88
|
@page.should render(tag).as(exp)
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
|
-
describe '<r:shop:
|
92
|
-
context '
|
93
|
+
describe '<r:shop:unless_products>' do
|
94
|
+
context 'success' do
|
93
95
|
before :each do
|
94
96
|
mock(Shop::Tags::Helpers).current_products(anything) { [] }
|
95
97
|
end
|
96
98
|
|
97
99
|
it 'should render' do
|
98
|
-
tag = %{<r:shop:products>success</r:shop:products>}
|
100
|
+
tag = %{<r:shop:products:unless_products>success</r:shop:products:unless_products>}
|
99
101
|
exp = %{success}
|
100
|
-
|
101
102
|
@page.should render(tag).as(exp)
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
|
-
context '
|
106
|
+
context 'failure' do
|
106
107
|
before :each do
|
107
108
|
mock(Shop::Tags::Helpers).current_products(anything) { @products }
|
108
109
|
end
|
109
110
|
|
110
|
-
it 'should render' do
|
111
|
-
tag = %{<r:shop:products>
|
112
|
-
exp = %{
|
113
|
-
|
111
|
+
it 'should not render' do
|
112
|
+
tag = %{<r:shop:products:unless_products>failure</r:shop:products:unless_products>}
|
113
|
+
exp = %{}
|
114
114
|
@page.should render(tag).as(exp)
|
115
115
|
end
|
116
116
|
end
|
@@ -204,6 +204,7 @@ describe Shop::Tags::Product do
|
|
204
204
|
it 'should render a textile filtered description' do
|
205
205
|
tag = %{<r:shop:product:description />}
|
206
206
|
exp = TextileFilter.filter(@product.description)
|
207
|
+
|
207
208
|
@page.should render(tag).as(exp)
|
208
209
|
end
|
209
210
|
end
|
@@ -248,6 +249,8 @@ describe Shop::Tags::Product do
|
|
248
249
|
@page.should render(tag).as(exp)
|
249
250
|
end
|
250
251
|
|
252
|
+
it 'should not be testing precision here'
|
253
|
+
|
251
254
|
it 'should render a high precision price' do
|
252
255
|
tag = %{<r:shop:product:price precision="8"/>}
|
253
256
|
exp = %{$1,234.34567890}
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Shop::Tags::ProductVariant do
|
4
|
+
|
5
|
+
dataset :pages, :shop_product_variants, :shop_products
|
6
|
+
|
7
|
+
it 'should describe these tags' do
|
8
|
+
Shop::Tags::ProductVariant.tags.sort.should == [
|
9
|
+
'shop:product:variants',
|
10
|
+
'shop:product:variants:each',
|
11
|
+
'shop:product:variants:if_variants',
|
12
|
+
'shop:product:variants:unless_variants',
|
13
|
+
'shop:product:variant',
|
14
|
+
'shop:product:variant:id',
|
15
|
+
'shop:product:variant:name',
|
16
|
+
'shop:product:variant:sku',
|
17
|
+
'shop:product:variant:price'].sort
|
18
|
+
end
|
19
|
+
|
20
|
+
before :all do
|
21
|
+
@page = pages(:home)
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'tags' do
|
25
|
+
|
26
|
+
before :each do
|
27
|
+
@product = shop_products(:crusty_bread)
|
28
|
+
@variant = shop_product_variants(:mouldy_crusty_bread)
|
29
|
+
|
30
|
+
stub(Shop::Tags::Helpers).current_product(anything) { @product }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '<r:shop:product:variants>' do
|
34
|
+
context 'variants exist' do
|
35
|
+
it 'should render' do
|
36
|
+
tag = %{<r:shop:product:variants>success</r:shop:product:variants>}
|
37
|
+
exp = %{success}
|
38
|
+
|
39
|
+
@page.should render(tag).as(exp)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'variants do not exist' do
|
44
|
+
it 'should render' do
|
45
|
+
@product.variants = []
|
46
|
+
|
47
|
+
tag = %{<r:shop:product:variants>success</r:shop:product:variants>}
|
48
|
+
exp = %{success}
|
49
|
+
|
50
|
+
@page.should render(tag).as(exp)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '<r:shop:product:variants:if_variants>' do
|
56
|
+
context 'success' do
|
57
|
+
it 'should render' do
|
58
|
+
tag = %{<r:shop:product:variants:if_variants>success</r:shop:product:variants:if_variants>}
|
59
|
+
exp = %{success}
|
60
|
+
@page.should render(tag).as(exp)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'failure' do
|
65
|
+
it 'should not render' do
|
66
|
+
mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
|
67
|
+
|
68
|
+
tag = %{<r:shop:product:variants:if_variants>failure</r:shop:product:variants:if_variants>}
|
69
|
+
exp = %{}
|
70
|
+
@page.should render(tag).as(exp)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '<r:shop:product:variants:unless_variants>' do
|
76
|
+
context 'success' do
|
77
|
+
it 'should render' do
|
78
|
+
mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
|
79
|
+
|
80
|
+
tag = %{<r:shop:product:variants:unless_variants>success</r:shop:product:variants:unless_variants>}
|
81
|
+
exp = %{success}
|
82
|
+
@page.should render(tag).as(exp)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'failure' do
|
87
|
+
it 'should not render' do
|
88
|
+
tag = %{<r:shop:product:variants:unless_variants>failure</r:shop:product:variants:unless_variants>}
|
89
|
+
exp = %{}
|
90
|
+
@page.should render(tag).as(exp)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '<r:shop:product:variants:each>' do
|
96
|
+
context 'success' do
|
97
|
+
it 'should not render' do
|
98
|
+
tag = %{<r:shop:product:variants:each><r:product:id /></r:shop:product:variants:each>}
|
99
|
+
exp = @product.variants.map{ |p| p.product.id }.join('')
|
100
|
+
@page.should render(tag).as(exp)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'failure' do
|
105
|
+
it 'should not render' do
|
106
|
+
mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
|
107
|
+
|
108
|
+
tag = %{<r:shop:product:variants:each>failure</r:shop:product:variants:each>}
|
109
|
+
exp = %{}
|
110
|
+
@page.should render(tag).as(exp)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '<r:shop:product:variant>' do
|
116
|
+
context 'variant exists in the context' do
|
117
|
+
it 'should render' do
|
118
|
+
mock(Shop::Tags::Helpers).current_product_variant(anything) { @variant }
|
119
|
+
|
120
|
+
tag = %{<r:shop:product:variant>success</r:shop:product:variant>}
|
121
|
+
exp = %{success}
|
122
|
+
@page.should render(tag).as(exp)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'product does not exist in the context' do
|
127
|
+
it 'should not render' do
|
128
|
+
mock(Shop::Tags::Helpers).current_product_variant(anything) { nil }
|
129
|
+
|
130
|
+
tag = %{<r:shop:product:variant>failure</r:shop:product:variant>}
|
131
|
+
exp = %{}
|
132
|
+
@page.should render(tag).as(exp)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context '#attributes' do
|
138
|
+
before :each do
|
139
|
+
mock(Shop::Tags::Helpers).current_product_variant(anything) { @variant }
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '<r:id />' do
|
143
|
+
it 'should render the product id' do
|
144
|
+
tag = %{<r:shop:product:variant:id />}
|
145
|
+
exp = @variant.id.to_s
|
146
|
+
@page.should render(tag).as(exp)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
describe '<r:name />' do
|
150
|
+
it 'should render the product name' do
|
151
|
+
tag = %{<r:shop:product:variant:name />}
|
152
|
+
exp = @variant.name
|
153
|
+
@page.should render(tag).as(exp)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
describe '<r:sku />' do
|
157
|
+
it 'should render the product sku' do
|
158
|
+
tag = %{<r:shop:product:variant:sku />}
|
159
|
+
exp = @variant.sku
|
160
|
+
@page.should render(tag).as(exp)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
describe '<r:price />' do
|
164
|
+
it 'should render a standard price' do
|
165
|
+
tag = %{<r:shop:product:variant:price />}
|
166
|
+
exp = Shop::Tags::Helpers.currency(@variant.price,{})
|
167
|
+
|
168
|
+
@page.should render(tag).as(exp)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe FormAddress do
|
4
|
+
|
5
|
+
dataset :shop_orders, :pages, :forms, :shop_addresses
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
mock_page_with_request_and_data
|
9
|
+
end
|
10
|
+
describe '#create' do
|
11
|
+
context 'addresses' do
|
12
|
+
context 'sending ids with user logged in' do
|
13
|
+
before :each do
|
14
|
+
login_as :customer # Will have existing addresses due to several_items
|
15
|
+
@order = shop_orders(:one_item)
|
16
|
+
mock_valid_form_address_request
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'both billing and shipping' do
|
20
|
+
it 'should assign that address to the order billing and shipping' do
|
21
|
+
@data[:billing] = { :id => shop_orders(:several_items).billing.id }
|
22
|
+
@data[:shipping] = { :id => shop_orders(:several_items).shipping.id }
|
23
|
+
|
24
|
+
@address = FormAddress.new(@form, @page)
|
25
|
+
result = @address.create
|
26
|
+
|
27
|
+
shop_orders(:one_item).billing.should === shop_addresses(:billing)
|
28
|
+
shop_orders(:one_item).shipping.should === shop_addresses(:shipping)
|
29
|
+
|
30
|
+
result[:billing].should === shop_addresses(:billing).id
|
31
|
+
result[:shipping].should === shop_addresses(:shipping).id
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'just billing' do
|
36
|
+
it 'should assign shipping to be billing' do
|
37
|
+
# Set the order to have no shipping address
|
38
|
+
@data[:shipping] = {}
|
39
|
+
@form[:extensions][:address] = { :billing => true }
|
40
|
+
|
41
|
+
@address = FormAddress.new(@form, @page)
|
42
|
+
result = @address.create
|
43
|
+
|
44
|
+
shop_orders(:one_item).billing.should === shop_addresses(:billing)
|
45
|
+
shop_orders(:one_item).shipping.should === shop_addresses(:billing)
|
46
|
+
|
47
|
+
result[:billing].should === shop_addresses(:billing).id
|
48
|
+
result[:shipping].should === shop_addresses(:billing).id
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'sending ids without customer logged in' do
|
54
|
+
before :each do
|
55
|
+
@order = shop_orders(:one_item)
|
56
|
+
mock_valid_form_address_request
|
57
|
+
end
|
58
|
+
context 'both billing and shipping' do
|
59
|
+
it 'it should not assign those addresses' do
|
60
|
+
@address = FormAddress.new(@form, @page)
|
61
|
+
result = @address.create
|
62
|
+
|
63
|
+
shop_orders(:one_item).billing.should be_nil
|
64
|
+
shop_orders(:one_item).shipping.should be_nil
|
65
|
+
|
66
|
+
result[:billing].should === false
|
67
|
+
result[:shipping].should === false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'sending ids as a bad customer' do
|
73
|
+
before :each do
|
74
|
+
login_as :bad_customer
|
75
|
+
@order = shop_orders(:one_item)
|
76
|
+
mock_valid_form_address_request
|
77
|
+
end
|
78
|
+
it 'should not assign those addresses' do
|
79
|
+
@address = FormAddress.new(@form, @page)
|
80
|
+
result = @address.create
|
81
|
+
|
82
|
+
shop_orders(:one_item).billing.should be_nil
|
83
|
+
shop_orders(:one_item).shipping.should be_nil
|
84
|
+
|
85
|
+
result[:billing].should === false
|
86
|
+
result[:shipping].should === false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'updating existing addresses' do
|
91
|
+
before :each do
|
92
|
+
login_as :customer
|
93
|
+
@order = shop_orders(:several_items)
|
94
|
+
mock_valid_form_address_request
|
95
|
+
end
|
96
|
+
it 'should keep them assigned and update them' do
|
97
|
+
@data[:billing] = { :name => 'new billing' }
|
98
|
+
@data[:shipping] = { :name => 'new shipping' }
|
99
|
+
|
100
|
+
@address = FormAddress.new(@form, @page)
|
101
|
+
result = @address.create
|
102
|
+
|
103
|
+
shop_addresses(:billing).name.should === 'new billing'
|
104
|
+
shop_addresses(:shipping).name.should === 'new shipping'
|
105
|
+
|
106
|
+
result[:billing].should === shop_addresses(:billing).id
|
107
|
+
result[:shipping].should === shop_addresses(:shipping).id
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'new addresses' do
|
112
|
+
before :each do
|
113
|
+
login_as :customer
|
114
|
+
@order = shop_orders(:one_item)
|
115
|
+
mock_valid_form_address_request
|
116
|
+
|
117
|
+
@data[:billing][:id] = nil
|
118
|
+
@data[:shipping][:id] = nil
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'both billing and shipping sent' do
|
122
|
+
it 'should create new addresses' do
|
123
|
+
@address = FormAddress.new(@form, @page)
|
124
|
+
result = @address.create
|
125
|
+
|
126
|
+
shop_orders(:one_item).billing.name.should === @data[:billing][:name]
|
127
|
+
shop_orders(:one_item).shipping.name.should === @data[:shipping][:name]
|
128
|
+
|
129
|
+
result[:billing].should === shop_orders(:one_item).billing.id
|
130
|
+
result[:shipping].should === shop_orders(:one_item).shipping.id
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'only billing sent' do
|
135
|
+
it 'should copy billing to shipping' do
|
136
|
+
@data[:shipping] = {}
|
137
|
+
|
138
|
+
@address = FormAddress.new(@form, @page)
|
139
|
+
result = @address.create
|
140
|
+
|
141
|
+
shop_orders(:one_item).billing.name.should === @data[:billing][:name]
|
142
|
+
shop_orders(:one_item).shipping.name.should === @data[:billing][:name]
|
143
|
+
|
144
|
+
result[:billing].should === shop_orders(:one_item).billing.id
|
145
|
+
result[:shipping].should === shop_orders(:one_item).shipping.id
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'billing sent with same shipping' do
|
150
|
+
it 'should copy billing to shipping' do
|
151
|
+
@data[:shipping] = @data[:billing]
|
152
|
+
|
153
|
+
@address = FormAddress.new(@form, @page)
|
154
|
+
result = @address.create
|
155
|
+
|
156
|
+
shop_orders(:one_item).shipping.should === shop_orders(:one_item).billing
|
157
|
+
|
158
|
+
result[:billing].should === shop_orders(:one_item).billing.id
|
159
|
+
result[:shipping].should === shop_orders(:one_item).shipping.id
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|