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
@@ -6,13 +6,13 @@ require 'spec/helpers/nested_tag_helper'
|
|
6
6
|
#
|
7
7
|
describe Shop::Tags::Item do
|
8
8
|
|
9
|
-
dataset :pages
|
9
|
+
dataset :pages, :shop_orders, :shop_line_items
|
10
10
|
|
11
11
|
it 'should describe these tags' do
|
12
12
|
Shop::Tags::Item.tags.sort.should == [
|
13
|
-
'shop:cart:if_items',
|
14
|
-
'shop:cart:unless_items',
|
15
13
|
'shop:cart:items',
|
14
|
+
'shop:cart:items:if_items',
|
15
|
+
'shop:cart:items:unless_items',
|
16
16
|
'shop:cart:items:each',
|
17
17
|
'shop:cart:item',
|
18
18
|
'shop:cart:item:id',
|
@@ -21,143 +21,148 @@ describe Shop::Tags::Item do
|
|
21
21
|
'shop:cart:item:sku',
|
22
22
|
'shop:cart:item:link',
|
23
23
|
'shop:cart:item:price',
|
24
|
-
'shop:cart:item:weight'
|
25
|
-
'shop:cart:item:remove'].sort
|
26
|
-
end
|
27
|
-
|
28
|
-
before :all do
|
29
|
-
@page = pages(:home)
|
30
|
-
end
|
31
|
-
|
32
|
-
before :each do
|
33
|
-
order = Object.new
|
34
|
-
stub(order).id { 1 }
|
35
|
-
@shop_order = order
|
36
|
-
|
37
|
-
item = Object.new
|
38
|
-
stub(item).id { 1 }
|
39
|
-
@shop_line_item = item
|
40
|
-
|
41
|
-
product = Object.new
|
42
|
-
stub(product).id { 1 }
|
43
|
-
@shop_product = product
|
44
|
-
|
45
|
-
stub(@shop_line_item).item { @shop_product }
|
46
|
-
stub(@shop_line_item).order { @shop_order }
|
47
|
-
|
48
|
-
@shop_line_items = [ @shop_line_item, @shop_line_item, @shop_line_item ]
|
49
|
-
stub(@shop_order).line_items { @shop_line_items }
|
24
|
+
'shop:cart:item:weight'].sort
|
50
25
|
end
|
51
26
|
|
52
27
|
context 'within a cart' do
|
53
28
|
|
54
|
-
before :
|
55
|
-
|
29
|
+
before :all do
|
30
|
+
@page = pages(:home)
|
56
31
|
end
|
57
32
|
|
58
|
-
context '
|
59
|
-
describe '<r:shop:cart:
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
33
|
+
context 'order does not exist' do
|
34
|
+
describe '<r:shop:cart:items>' do
|
35
|
+
it 'should not render' do
|
36
|
+
tag = %{<r:shop:cart:items>failure</r:shop:cart:items>}
|
37
|
+
exp = %{}
|
38
|
+
|
39
|
+
@page.should render(tag).as(exp)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'order exists' do
|
45
|
+
before :each do
|
46
|
+
@order = shop_orders(:several_items)
|
47
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
48
|
+
end
|
49
|
+
describe '<r:shop:cart:items>' do
|
50
|
+
context 'items exist in cart' do
|
51
|
+
context 'no parameters sent to tag' do
|
52
|
+
it 'should render' do
|
53
|
+
tag = %{<r:shop:cart:items>success</r:shop:cart:items>}
|
54
|
+
exp = %{success}
|
55
|
+
|
56
|
+
@page.should render(tag).as(exp)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
context 'parameters sent to tag' do
|
60
|
+
it 'should render' do
|
61
|
+
tag = %{<r:shop:cart:items key='id' value='#{@order.line_items.first.id}'>success</r:shop:cart:items>}
|
62
|
+
exp = %{success}
|
63
|
+
|
64
|
+
@page.should render(tag).as(exp)
|
65
|
+
end
|
65
66
|
end
|
66
67
|
end
|
67
|
-
|
68
|
+
|
69
|
+
context 'items dont exist in cart' do
|
68
70
|
it 'should render' do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@page.should render(tag).as(expected)
|
71
|
+
tag = %{<r:shop:cart:items>success</r:shop:cart:items>}
|
72
|
+
exp = %{success}
|
73
|
+
|
74
|
+
@page.should render(tag).as(exp)
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
|
-
describe '<r:shop:cart:
|
79
|
+
describe '<r:shop:cart:items:if_items>' do
|
79
80
|
context 'success' do
|
80
81
|
it 'should render' do
|
81
|
-
|
82
|
-
|
83
|
-
tag
|
84
|
-
expected = %{success}
|
85
|
-
@page.should render(tag).as(expected)
|
82
|
+
tag = %{<r:shop:cart:items:if_items>success</r:shop:cart:items:if_items>}
|
83
|
+
exp = %{success}
|
84
|
+
@page.should render(tag).as(exp)
|
86
85
|
end
|
87
86
|
end
|
88
87
|
context 'failure' do
|
89
88
|
it 'should render' do
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
stub(@order).line_items { [] }
|
90
|
+
|
91
|
+
tag = %{<r:shop:cart:items:if_items>failure</r:shop:cart:items:if_items>}
|
92
|
+
exp = %{}
|
93
|
+
@page.should render(tag).as(exp)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
97
|
-
describe '<r:shop:cart:items>' do
|
98
|
-
context '
|
98
|
+
describe '<r:shop:cart:items:unless_items>' do
|
99
|
+
context 'success' do
|
99
100
|
it 'should render' do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
stub(@order).line_items { [] }
|
102
|
+
|
103
|
+
tag = %{<r:shop:cart:items:unless_items>success</r:shop:cart:items:unless_items>}
|
104
|
+
exp = %{success}
|
105
|
+
@page.should render(tag).as(exp)
|
104
106
|
end
|
105
107
|
end
|
106
|
-
|
107
|
-
context 'items dont exist' do
|
108
|
+
context 'failure' do
|
108
109
|
it 'should render' do
|
109
|
-
tag = %{<r:shop:cart:items>
|
110
|
-
|
111
|
-
|
112
|
-
@page.should render(tag).as(expected)
|
110
|
+
tag = %{<r:shop:cart:items:unless_items>failure</r:shop:cart:items:unless_items>}
|
111
|
+
exp = %{}
|
112
|
+
@page.should render(tag).as(exp)
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
describe '<r:shop:cart:items:each' do
|
117
|
+
describe '<r:shop:cart:items:each>' do
|
118
118
|
context 'success' do
|
119
119
|
it 'should render' do
|
120
|
-
tag = %{<r:shop:cart:items:each>.a.</r:shop:cart:items:each>}
|
121
|
-
|
120
|
+
tag = %{<r:shop:cart:items:each:item>.a.</r:shop:cart:items:each:item>}
|
121
|
+
exp = @order.line_items.map{ '.a.' }.join('')
|
122
122
|
|
123
|
-
@page.should render(tag).as(
|
123
|
+
@page.should render(tag).as(exp)
|
124
124
|
end
|
125
125
|
it 'should assign the local item' do
|
126
|
-
tag = %{<r:shop:cart:items:each><r:
|
127
|
-
|
126
|
+
tag = %{<r:shop:cart:items:each:item><r:id /></r:shop:cart:items:each:item>}
|
127
|
+
exp = @order.line_items.map{ |i| i.id }.join('')
|
128
128
|
|
129
|
-
@page.should render(tag).as(
|
129
|
+
@page.should render(tag).as(exp)
|
130
130
|
end
|
131
|
-
it 'should assign the local
|
132
|
-
tag = %{<r:shop:cart:items:each><r:product:
|
133
|
-
|
131
|
+
it 'should assign the local item' do
|
132
|
+
tag = %{<r:shop:cart:items:each:item><r:product:name /></r:shop:cart:items:each:item>}
|
133
|
+
exp = @order.line_items.map{ |i| i.item.name }.join('')
|
134
134
|
|
135
|
-
@page.should render(tag).as(
|
135
|
+
@page.should render(tag).as(exp)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
context 'failure' do
|
139
139
|
it 'should not render' do
|
140
|
-
stub(@
|
140
|
+
stub(@order).line_items { [] }
|
141
141
|
|
142
142
|
tag = %{<r:shop:cart:items:each></r:shop:cart:items:each>}
|
143
|
-
|
143
|
+
exp = %{}
|
144
144
|
|
145
|
-
@page.should render(tag).as(
|
145
|
+
@page.should render(tag).as(exp)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
151
|
context 'a single item' do
|
152
|
+
before :each do
|
153
|
+
@order = shop_orders(:several_items)
|
154
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
155
|
+
@line_item = @order.line_items.first
|
156
|
+
end
|
152
157
|
describe '<r:shop:cart:item>' do
|
153
158
|
context 'success' do
|
154
159
|
it 'should render' do
|
155
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @
|
160
|
+
mock(Shop::Tags::Helpers).current_line_item(anything) { @line_item }
|
156
161
|
|
157
162
|
tag = %{<r:shop:cart:item>success</r:shop:cart:item>}
|
158
|
-
|
163
|
+
exp = %{success}
|
159
164
|
|
160
|
-
@page.should render(tag).as(
|
165
|
+
@page.should render(tag).as(exp)
|
161
166
|
end
|
162
167
|
end
|
163
168
|
|
@@ -165,154 +170,107 @@ describe Shop::Tags::Item do
|
|
165
170
|
it 'should not render' do
|
166
171
|
mock(Shop::Tags::Helpers).current_line_item(anything) { nil }
|
167
172
|
tag = %{<r:shop:cart:item>failure</r:shop:cart:item>}
|
168
|
-
|
173
|
+
exp = %{}
|
169
174
|
|
170
|
-
@page.should render(tag).as(
|
175
|
+
@page.should render(tag).as(exp)
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
174
179
|
describe 'simple attributes' do
|
175
180
|
before :each do
|
176
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @
|
181
|
+
mock(Shop::Tags::Helpers).current_line_item(anything) { @line_item }
|
177
182
|
end
|
178
183
|
it 'should render <r:id />' do
|
179
|
-
stub(@shop_line_item).id { 1 }
|
180
|
-
|
181
184
|
tag = %{<r:shop:cart:item:id />}
|
182
|
-
|
185
|
+
exp = @line_item.id.to_s
|
183
186
|
|
184
|
-
@page.should render(tag).as(
|
187
|
+
@page.should render(tag).as(exp)
|
185
188
|
end
|
186
189
|
it 'should render <r:quantity />' do
|
187
|
-
stub(@shop_line_item).quantity { 1 }
|
188
|
-
|
189
190
|
tag = %{<r:shop:cart:item:quantity />}
|
190
|
-
|
191
|
+
exp = @line_item.quantity.to_s
|
191
192
|
|
192
|
-
@page.should render(tag).as(
|
193
|
+
@page.should render(tag).as(exp)
|
193
194
|
end
|
194
195
|
end
|
195
196
|
|
196
197
|
describe 'item attributes' do
|
197
198
|
before :each do
|
198
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @
|
199
|
+
mock(Shop::Tags::Helpers).current_line_item(anything) { @line_item }
|
199
200
|
end
|
200
201
|
it 'should render <r:name />' do
|
201
|
-
stub(@shop_line_item).item.stub!.name { 'name' }
|
202
|
-
|
203
202
|
tag = %{<r:shop:cart:item:name />}
|
204
|
-
|
203
|
+
exp = @line_item.item.name
|
205
204
|
|
206
|
-
@page.should render(tag).as(
|
205
|
+
@page.should render(tag).as(exp)
|
207
206
|
end
|
208
207
|
it 'should render <r:sku />' do
|
209
|
-
stub(@shop_line_item).item.stub!.sku { 'sku' }
|
210
|
-
|
211
208
|
tag = %{<r:shop:cart:item:sku />}
|
212
|
-
|
209
|
+
exp = @line_item.item.sku
|
213
210
|
|
214
|
-
@page.should render(tag).as(
|
211
|
+
@page.should render(tag).as(exp)
|
215
212
|
end
|
216
213
|
it 'should render <r:weight />' do
|
217
|
-
stub(@shop_line_item).item.stub!.weight { 100 }
|
218
|
-
|
219
214
|
tag = %{<r:shop:cart:item:weight />}
|
220
|
-
|
215
|
+
exp = @line_item.item.weight.to_s
|
221
216
|
|
222
|
-
@page.should render(tag).as(
|
217
|
+
@page.should render(tag).as(exp)
|
223
218
|
end
|
224
219
|
end
|
225
220
|
|
226
221
|
describe '<r:shop:cart:item:link />' do
|
227
222
|
before :each do
|
228
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @
|
223
|
+
mock(Shop::Tags::Helpers).current_line_item(anything) { @line_item }
|
229
224
|
end
|
230
225
|
|
231
226
|
context 'standalone' do
|
232
|
-
before :each do
|
233
|
-
item = Object.new
|
234
|
-
stub(@shop_line_item).item { item }
|
235
|
-
stub(item).slug { 'slug' }
|
236
|
-
stub(item).name { 'name' }
|
237
|
-
end
|
238
227
|
it 'should render an anchor element' do
|
239
228
|
tag = %{<r:shop:cart:item:link />}
|
240
|
-
|
241
|
-
pages(:home).should render(tag).as(
|
229
|
+
exp = %{<a href="#{@line_item.item.slug}">#{@line_item.item.name}</a>}
|
230
|
+
pages(:home).should render(tag).as(exp)
|
242
231
|
end
|
243
232
|
it 'should assign attributes' do
|
244
233
|
tag = %{<r:shop:cart:item:link title="title" data-title="data-title"/>}
|
245
|
-
|
246
|
-
pages(:home).should render(tag).as(
|
234
|
+
exp = %{<a href="#{@line_item.item.slug}" data-title="data-title" title="title">#{@line_item.item.name}</a>}
|
235
|
+
pages(:home).should render(tag).as(exp)
|
247
236
|
end
|
248
237
|
end
|
249
238
|
|
250
239
|
context 'wrapped' do
|
251
240
|
it 'should render an anchor element' do
|
252
|
-
item = Object.new
|
253
|
-
stub(@shop_line_item).item { item }
|
254
|
-
stub(item).slug { 'slug' }
|
255
|
-
|
256
241
|
tag = %{<r:shop:cart:item:link>title</r:shop:cart:item:link>}
|
257
|
-
|
258
|
-
pages(:home).should render(tag).as(
|
242
|
+
exp = %{<a href="#{@line_item.item.slug}">title</a>}
|
243
|
+
pages(:home).should render(tag).as(exp)
|
259
244
|
end
|
260
245
|
end
|
261
246
|
end
|
262
247
|
|
263
248
|
describe '<r:shop:cart:item:price />' do
|
264
249
|
before :each do
|
265
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @
|
250
|
+
mock(Shop::Tags::Helpers).current_line_item(anything) { @line_item }
|
266
251
|
|
267
|
-
stub(@
|
252
|
+
stub(@line_item).price { 1234.34567890 }
|
268
253
|
end
|
269
254
|
|
270
255
|
it 'should render a standard price' do
|
271
256
|
tag = %{<r:shop:cart:item:price />}
|
272
|
-
|
257
|
+
exp = %{$1,234.35}
|
273
258
|
|
274
|
-
@page.should render(tag).as(
|
259
|
+
@page.should render(tag).as(exp)
|
275
260
|
end
|
276
261
|
|
277
262
|
it 'should render a high precision price' do
|
278
263
|
tag = %{<r:shop:cart:item:price precision="8"/>}
|
279
|
-
|
264
|
+
exp = %{$1,234.34567890}
|
280
265
|
|
281
|
-
@page.should render(tag).as(
|
266
|
+
@page.should render(tag).as(exp)
|
282
267
|
end
|
283
268
|
|
284
269
|
it 'should render a custom format' do
|
285
270
|
tag = %{<r:shop:cart:item:price unit="%" separator="-" delimiter="+" />}
|
286
|
-
|
271
|
+
exp = %{%1+234-35}
|
287
272
|
|
288
|
-
@page.should render(tag).as(
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe '<r:shop:cart:item:remove />' do
|
293
|
-
before :each do
|
294
|
-
mock(Shop::Tags::Helpers).current_line_item(anything) { @shop_line_item }
|
295
|
-
end
|
296
|
-
|
297
|
-
context 'standalone' do
|
298
|
-
it 'should render an anchor element' do
|
299
|
-
tag = %{<r:shop:cart:item:remove />}
|
300
|
-
expected = %{<a href="/#{Radiant::Config['shop.url_prefix']}/cart/items/#{@shop_line_item.id}/destroy">remove</a>}
|
301
|
-
pages(:home).should render(tag).as(expected)
|
302
|
-
end
|
303
|
-
it 'should assign attributes' do
|
304
|
-
tag = %{<r:shop:cart:item:remove title="title" data-title="data-title"/>}
|
305
|
-
expected = %{<a href="/#{Radiant::Config['shop.url_prefix']}/cart/items/#{@shop_line_item.id}/destroy" data-title="data-title" title="title">remove</a>}
|
306
|
-
pages(:home).should render(tag).as(expected)
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
context 'wrapped' do
|
311
|
-
it 'should render an anchor element' do
|
312
|
-
tag = %{<r:shop:cart:item:remove>get rid of me</r:shop:cart:item:remove>}
|
313
|
-
expected = %{<a href="/#{Radiant::Config['shop.url_prefix']}/cart/items/#{@shop_line_item.id}/destroy">get rid of me</a>}
|
314
|
-
pages(:home).should render(tag).as(expected)
|
315
|
-
end
|
273
|
+
@page.should render(tag).as(exp)
|
316
274
|
end
|
317
275
|
end
|
318
276
|
|
@@ -0,0 +1,342 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Shop::Tags::Package do
|
4
|
+
|
5
|
+
dataset :pages, :shop_packages
|
6
|
+
|
7
|
+
it 'should describe these tags' do
|
8
|
+
Shop::Tags::Package.tags.sort.should == [
|
9
|
+
'shop:packages',
|
10
|
+
'shop:packages:if_packages',
|
11
|
+
'shop:packages:unless_packages',
|
12
|
+
'shop:packages:each',
|
13
|
+
'shop:package',
|
14
|
+
'shop:package:id',
|
15
|
+
'shop:package:name',
|
16
|
+
'shop:package:sku',
|
17
|
+
'shop:package:description',
|
18
|
+
'shop:package:price',
|
19
|
+
'shop:package:value',
|
20
|
+
'shop:package:if_products',
|
21
|
+
'shop:package:unless_products',
|
22
|
+
'shop:package:products',
|
23
|
+
'shop:package:products:each',
|
24
|
+
'shop:package:product:quantity'].sort
|
25
|
+
end
|
26
|
+
|
27
|
+
before :all do
|
28
|
+
@page = pages(:home)
|
29
|
+
end
|
30
|
+
|
31
|
+
before :each do
|
32
|
+
@package = shop_packages(:all_bread)
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'outside a package' do
|
36
|
+
describe '<r:shop:packages>' do
|
37
|
+
context 'packages' do
|
38
|
+
it 'should render' do
|
39
|
+
tag = %{<r:shop:packages>success</r:shop:packages>}
|
40
|
+
exp = %{success}
|
41
|
+
|
42
|
+
@page.should render(tag).as(exp)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context 'no packages' do
|
46
|
+
it 'should render' do
|
47
|
+
tag = %{<r:shop:packages>success</r:shop:packages>}
|
48
|
+
exp = %{success}
|
49
|
+
|
50
|
+
@page.should render(tag).as(exp)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '<r:shop:packages:if_packages>' do
|
56
|
+
context 'success' do
|
57
|
+
it 'should render' do
|
58
|
+
tag = %{<r:shop:packages:if_packages>success</r:shop:packages:if_packages>}
|
59
|
+
exp = %{success}
|
60
|
+
|
61
|
+
@page.should render(tag).as(exp)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
context 'failure' do
|
65
|
+
it 'should render' do
|
66
|
+
mock(Shop::Tags::Helpers).current_packages(anything) { [] }
|
67
|
+
tag = %{<r:shop:packages:if_packages>failure</r:shop:packages:if_packages>}
|
68
|
+
exp = %{}
|
69
|
+
|
70
|
+
@page.should render(tag).as(exp)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '<r:shop:packages:unless_packages>' do
|
76
|
+
context 'success' do
|
77
|
+
it 'should not render' do
|
78
|
+
mock(Shop::Tags::Helpers).current_packages(anything) { [] }
|
79
|
+
|
80
|
+
tag = %{<r:shop:packages:unless_packages>success</r:shop:packages:unless_packages>}
|
81
|
+
exp = %{success}
|
82
|
+
|
83
|
+
@page.should render(tag).as(exp)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
context 'failure' do
|
87
|
+
it 'should render' do
|
88
|
+
mock(Shop::Tags::Helpers).current_packages(anything) { ShopPackage.all }
|
89
|
+
|
90
|
+
tag = %{<r:shop:packages:unless_packages>failure</r:shop:packages:unless_packages>}
|
91
|
+
exp = %{}
|
92
|
+
|
93
|
+
@page.should render(tag).as(exp)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '<r:shop:packages:each>' do
|
99
|
+
context 'success' do
|
100
|
+
it 'should render' do
|
101
|
+
mock(Shop::Tags::Helpers).current_packages(anything) { ShopPackage.all }
|
102
|
+
|
103
|
+
tag = %{<r:shop:packages:each>.a.</r:shop:packages:each>}
|
104
|
+
exp = ShopPackage.all.map{ '.a.' }.join('')
|
105
|
+
|
106
|
+
@page.should render(tag).as(exp)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'failure' do
|
111
|
+
it 'should not render' do
|
112
|
+
mock(Shop::Tags::Helpers).current_packages(anything) { [] }
|
113
|
+
|
114
|
+
tag = %{<r:shop:packages:each>failure</r:shop:packages:each>}
|
115
|
+
exp = %{}
|
116
|
+
|
117
|
+
@page.should render(tag).as(exp)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '<r:shop:package>' do
|
123
|
+
context 'success' do
|
124
|
+
it 'should render' do
|
125
|
+
mock(Shop::Tags::Helpers).current_package(anything) { @package }
|
126
|
+
|
127
|
+
tag = %{<r:shop:package>success</r:shop:package>}
|
128
|
+
exp = %{success}
|
129
|
+
|
130
|
+
@page.should render(tag).as(exp)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'failure' do
|
135
|
+
it 'should not render' do
|
136
|
+
mock(Shop::Tags::Helpers).current_package(anything) { nil }
|
137
|
+
|
138
|
+
tag = %{<r:shop:package>failure</r:shop:package>}
|
139
|
+
exp = %{}
|
140
|
+
|
141
|
+
@page.should render(tag).as(exp)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'within a package' do
|
149
|
+
|
150
|
+
before :each do
|
151
|
+
mock(Shop::Tags::Helpers).current_package(anything) { @package }
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'simple attributes' do
|
155
|
+
describe '<r:shop:package:id />' do
|
156
|
+
it 'should render the id' do
|
157
|
+
tag = %{<r:shop:package:id />}
|
158
|
+
exp = @package.id.to_s
|
159
|
+
|
160
|
+
@page.should render(tag).as(exp)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe '<r:shop:package:name />' do
|
165
|
+
it 'should render the name' do
|
166
|
+
tag = %{<r:shop:package:name />}
|
167
|
+
exp = @package.name.to_s
|
168
|
+
|
169
|
+
@page.should render(tag).as(exp)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '<r:shop:package:sku />' do
|
174
|
+
it 'should render the sku' do
|
175
|
+
tag = %{<r:shop:package:sku />}
|
176
|
+
exp = @package.sku.to_s
|
177
|
+
|
178
|
+
@page.should render(tag).as(exp)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe '<r:package:description />' do
|
184
|
+
it 'should render a textile filtered result' do
|
185
|
+
@package.description = '*bold*'
|
186
|
+
|
187
|
+
tag = %{<r:shop:package:description />}
|
188
|
+
exp = %{<p><strong>bold</strong></p>}
|
189
|
+
|
190
|
+
@page.should render(tag).as(exp)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'currency attributes' do
|
195
|
+
describe '<r:shop:package:price />' do
|
196
|
+
before :each do
|
197
|
+
@package.price = 1234.34567890
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'should render a standard price' do
|
201
|
+
tag = %{<r:shop:package:price />}
|
202
|
+
exp = %{$1,234.35}
|
203
|
+
@page.should render(tag).as(exp)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should render a high precision price' do
|
207
|
+
tag = %{<r:shop:package:price precision="8"/>}
|
208
|
+
exp = %{$1,234.34567890}
|
209
|
+
|
210
|
+
@page.should render(tag).as(exp)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should render a custom format' do
|
214
|
+
tag = %{<r:shop:package:price unit="%" separator="-" delimiter="+" />}
|
215
|
+
exp = %{%1+234-35}
|
216
|
+
|
217
|
+
@page.should render(tag).as(exp)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe '<r:shop:package:name />' do
|
222
|
+
before :each do
|
223
|
+
stub(@package).value { 1234.34567890 }
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'should render a standard price' do
|
227
|
+
tag = %{<r:shop:package:value />}
|
228
|
+
exp = %{$1,234.35}
|
229
|
+
|
230
|
+
@page.should render(tag).as(exp)
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'should render a high precision price' do
|
234
|
+
tag = %{<r:shop:package:value precision="8"/>}
|
235
|
+
exp = %{$1,234.34567890}
|
236
|
+
|
237
|
+
@page.should render(tag).as(exp)
|
238
|
+
end
|
239
|
+
|
240
|
+
it 'should render a custom format' do
|
241
|
+
tag = %{<r:shop:package:value unit="%" separator="-" delimiter="+" />}
|
242
|
+
exp = %{%1+234-35}
|
243
|
+
|
244
|
+
@page.should render(tag).as(exp)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
context 'products in a package' do
|
252
|
+
|
253
|
+
before :each do
|
254
|
+
mock(Shop::Tags::Helpers).current_package(anything) { @package }
|
255
|
+
end
|
256
|
+
|
257
|
+
describe '<r:shop:package:if_products>' do
|
258
|
+
context 'success' do
|
259
|
+
it 'should render' do
|
260
|
+
tag = %{<r:shop:package:if_products>success</r:shop:package:if_products>}
|
261
|
+
exp = %{success}
|
262
|
+
|
263
|
+
@page.should render(tag).as(exp)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context 'failure' do
|
268
|
+
it 'should not render' do
|
269
|
+
stub(@package).products { [] }
|
270
|
+
|
271
|
+
tag = %{<r:shop:package:if_products>failure</r:shop:package:if_products>}
|
272
|
+
exp = %{}
|
273
|
+
|
274
|
+
@page.should render(tag).as(exp)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
describe '<r:shop:package:unless_products>' do
|
280
|
+
context 'success' do
|
281
|
+
it 'should render' do
|
282
|
+
stub(@package).products { [] }
|
283
|
+
tag = %{<r:shop:package:unless_products>success</r:shop:package:unless_products>}
|
284
|
+
exp = %{success}
|
285
|
+
|
286
|
+
@page.should render(tag).as(exp)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
context 'failure' do
|
291
|
+
it 'should not render' do
|
292
|
+
tag = %{<r:shop:package:unless_products>failure</r:shop:package:unless_products>}
|
293
|
+
exp = %{}
|
294
|
+
|
295
|
+
@page.should render(tag).as(exp)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
describe '<r:shop:package:products>' do
|
301
|
+
it 'should render' do
|
302
|
+
tag = %{<r:shop:package:products>success</r:shop:package:products>}
|
303
|
+
exp = %{success}
|
304
|
+
|
305
|
+
@page.should render(tag).as(exp)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe '<r:shop:package:products:each>' do
|
310
|
+
context 'success' do
|
311
|
+
it 'should render' do
|
312
|
+
tag = %{<r:shop:package:products:each>.a.</r:shop:package:products:each>}
|
313
|
+
exp = @package.products.map{'.a.'}.join('')
|
314
|
+
|
315
|
+
@page.should render(tag).as(exp)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
context 'failure' do
|
320
|
+
it 'should not render' do
|
321
|
+
stub(@package).packings { [] }
|
322
|
+
|
323
|
+
tag = %{<r:shop:package:products:each>failure</r:shop:package:products:each>}
|
324
|
+
exp = %{}
|
325
|
+
|
326
|
+
@page.should render(tag).as(exp)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe '<r:shop:package:product:quantity>' do
|
332
|
+
it 'should render the quantity of the current packing' do
|
333
|
+
tag = %{<r:shop:package:products:each:product:quantity />}
|
334
|
+
exp = @package.packings.map{|p| p.quantity}.join('')
|
335
|
+
|
336
|
+
@page.should render(tag).as(exp)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
end
|
341
|
+
|
342
|
+
end
|