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,12 +6,12 @@ require 'spec/helpers/nested_tag_helper'
|
|
6
6
|
#
|
7
7
|
describe Shop::Tags::Cart do
|
8
8
|
|
9
|
-
dataset :pages
|
9
|
+
dataset :pages, :shop_orders
|
10
10
|
|
11
11
|
it 'should describe these tags' do
|
12
12
|
Shop::Tags::Cart.tags.sort.should == [
|
13
|
-
'shop:if_cart',
|
14
|
-
'shop:unless_cart',
|
13
|
+
'shop:cart:if_cart',
|
14
|
+
'shop:cart:unless_cart',
|
15
15
|
'shop:cart',
|
16
16
|
'shop:cart:id',
|
17
17
|
'shop:cart:status',
|
@@ -25,74 +25,69 @@ describe Shop::Tags::Cart do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
before :each do
|
28
|
-
order =
|
29
|
-
|
30
|
-
@shop_order = order
|
31
|
-
@shop_orders = [ order, order, order ]
|
32
|
-
|
33
|
-
item = Object.new
|
28
|
+
@order = shop_orders(:several_items)
|
34
29
|
end
|
35
30
|
|
36
|
-
context '
|
37
|
-
describe '<r:shop:
|
31
|
+
context 'cart tags' do
|
32
|
+
describe '<r:shop:cart>' do
|
38
33
|
context 'success' do
|
39
34
|
it 'should render' do
|
40
|
-
mock(Shop::Tags::Helpers).current_order(anything) { @
|
35
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
41
36
|
|
42
|
-
tag = %{<r:shop:
|
37
|
+
tag = %{<r:shop:cart>success</r:shop:cart>}
|
43
38
|
expected = %{success}
|
39
|
+
|
44
40
|
@page.should render(tag).as(expected)
|
45
41
|
end
|
46
42
|
end
|
43
|
+
|
47
44
|
context 'failure' do
|
48
45
|
it 'should render' do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
expected = %{}
|
46
|
+
tag = %{<r:shop:cart>success</r:shop:cart>}
|
47
|
+
expected = %{success}
|
48
|
+
|
53
49
|
@page.should render(tag).as(expected)
|
54
50
|
end
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
58
|
-
describe '<r:shop:
|
54
|
+
describe '<r:shop:cart:if_cart>' do
|
59
55
|
context 'success' do
|
60
56
|
it 'should render' do
|
61
|
-
mock(Shop::Tags::Helpers).current_order(anything) {
|
57
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
62
58
|
|
63
|
-
tag = %{<r:shop:
|
59
|
+
tag = %{<r:shop:cart:if_cart>success</r:shop:cart:if_cart>}
|
64
60
|
expected = %{success}
|
65
61
|
@page.should render(tag).as(expected)
|
66
62
|
end
|
67
63
|
end
|
68
64
|
context 'failure' do
|
69
65
|
it 'should render' do
|
70
|
-
mock(Shop::Tags::Helpers).current_order(anything) {
|
66
|
+
mock(Shop::Tags::Helpers).current_order(anything) { nil }
|
71
67
|
|
72
|
-
tag = %{<r:shop:
|
68
|
+
tag = %{<r:shop:cart:if_cart>failure</r:shop:cart:if_cart>}
|
73
69
|
expected = %{}
|
74
70
|
@page.should render(tag).as(expected)
|
75
71
|
end
|
76
72
|
end
|
77
73
|
end
|
78
74
|
|
79
|
-
describe '<r:shop:cart>' do
|
75
|
+
describe '<r:shop:cart:unless_cart>' do
|
80
76
|
context 'success' do
|
81
77
|
it 'should render' do
|
82
|
-
mock(Shop::Tags::Helpers).current_order(anything) {
|
78
|
+
mock(Shop::Tags::Helpers).current_order(anything) { nil }
|
83
79
|
|
84
|
-
tag = %{<r:shop:cart>success</r:shop:cart>}
|
80
|
+
tag = %{<r:shop:cart:unless_cart>success</r:shop:cart:unless_cart>}
|
85
81
|
expected = %{success}
|
86
|
-
|
87
82
|
@page.should render(tag).as(expected)
|
88
83
|
end
|
89
84
|
end
|
90
|
-
|
91
85
|
context 'failure' do
|
92
|
-
it 'should
|
93
|
-
|
86
|
+
it 'should render' do
|
87
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
88
|
+
|
89
|
+
tag = %{<r:shop:cart:unless_cart>failure</r:shop:cart:unless_cart>}
|
94
90
|
expected = %{}
|
95
|
-
|
96
91
|
@page.should render(tag).as(expected)
|
97
92
|
end
|
98
93
|
end
|
@@ -100,21 +95,17 @@ describe Shop::Tags::Cart do
|
|
100
95
|
|
101
96
|
describe 'simple attributes' do
|
102
97
|
before :each do
|
103
|
-
mock(Shop::Tags::Helpers).current_order(anything) { @
|
98
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
104
99
|
end
|
105
100
|
it 'should render <r:id />' do
|
106
|
-
stub(@shop_order).id { 1 }
|
107
|
-
|
108
101
|
tag = %{<r:shop:cart:id />}
|
109
|
-
expected =
|
102
|
+
expected = @order.id.to_s
|
110
103
|
|
111
104
|
@page.should render(tag).as(expected)
|
112
105
|
end
|
113
106
|
it 'should render <r:status />' do
|
114
|
-
stub(@shop_order).status { 'new' }
|
115
|
-
|
116
107
|
tag = %{<r:shop:cart:status />}
|
117
|
-
expected =
|
108
|
+
expected = @order.status
|
118
109
|
|
119
110
|
@page.should render(tag).as(expected)
|
120
111
|
end
|
@@ -122,15 +113,13 @@ describe Shop::Tags::Cart do
|
|
122
113
|
stub(@shop_order).quantity { 1 }
|
123
114
|
|
124
115
|
tag = %{<r:shop:cart:quantity />}
|
125
|
-
expected =
|
116
|
+
expected = @order.quantity.to_s
|
126
117
|
|
127
118
|
@page.should render(tag).as(expected)
|
128
119
|
end
|
129
120
|
it 'should render <r:weight />' do
|
130
|
-
stub(@shop_order).weight { 100 }
|
131
|
-
|
132
121
|
tag = %{<r:shop:cart:weight />}
|
133
|
-
expected =
|
122
|
+
expected = @order.weight.to_s
|
134
123
|
|
135
124
|
@page.should render(tag).as(expected)
|
136
125
|
end
|
@@ -138,8 +127,8 @@ describe Shop::Tags::Cart do
|
|
138
127
|
|
139
128
|
describe '<r:price />' do
|
140
129
|
before :each do
|
141
|
-
mock(Shop::Tags::Helpers).current_order(anything) { @
|
142
|
-
stub(@
|
130
|
+
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
131
|
+
stub(@order).price { 1234.34567890 }
|
143
132
|
end
|
144
133
|
|
145
134
|
it 'should render a standard price' do
|
@@ -2,31 +2,25 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Shop::Tags::Category do
|
4
4
|
|
5
|
-
dataset :pages
|
5
|
+
dataset :pages, :shop_categories, :shop_products
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@page = pages(:home)
|
9
|
+
end
|
6
10
|
|
7
11
|
before(:each) do
|
8
|
-
category =
|
9
|
-
stub(category).id { 1 }
|
10
|
-
|
11
|
-
@shop_category = category
|
12
|
-
@shop_categories = [ category, category, category ]
|
13
|
-
|
14
|
-
product = Object.new
|
15
|
-
stub(product).id { 1 }
|
16
|
-
|
17
|
-
@shop_product = product
|
18
|
-
@shop_products = [ product, product, product ]
|
12
|
+
@category = shop_categories(:bread)
|
19
13
|
end
|
20
14
|
|
21
15
|
describe '<r:shop:if_categories>' do
|
22
16
|
context 'success' do
|
23
17
|
it 'should render' do
|
24
|
-
mock(Shop::Tags::Helpers).current_categories(anything) { @
|
18
|
+
mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
|
25
19
|
|
26
20
|
tag = %{<r:shop:if_categories>success</r:shop:if_categories>}
|
27
|
-
|
21
|
+
exp = %{success}
|
28
22
|
|
29
|
-
|
23
|
+
@page.should render(tag).as(exp)
|
30
24
|
end
|
31
25
|
end
|
32
26
|
context 'failure' do
|
@@ -34,8 +28,8 @@ describe Shop::Tags::Category do
|
|
34
28
|
mock(Shop::Tags::Helpers).current_categories(anything) { [] }
|
35
29
|
|
36
30
|
tag = %{<r:shop:if_categories>failure</r:shop:if_categories>}
|
37
|
-
|
38
|
-
|
31
|
+
exp = %{}
|
32
|
+
@page.should render(tag).as(exp)
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -46,154 +40,125 @@ describe Shop::Tags::Category do
|
|
46
40
|
mock(Shop::Tags::Helpers).current_categories(anything) { [] }
|
47
41
|
|
48
42
|
tag = %{<r:shop:unless_categories>success</r:shop:unless_categories>}
|
49
|
-
|
50
|
-
|
43
|
+
exp = %{success}
|
44
|
+
@page.should render(tag).as(exp)
|
51
45
|
end
|
52
46
|
end
|
53
47
|
context 'failure' do
|
54
48
|
it 'should not render' do
|
55
|
-
mock(Shop::Tags::Helpers).current_categories(anything) { @
|
49
|
+
mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
|
56
50
|
|
57
51
|
tag = %{<r:shop:unless_categories>failure</r:shop:unless_categories>}
|
58
|
-
|
59
|
-
|
52
|
+
exp = %{}
|
53
|
+
@page.should render(tag).as(exp)
|
60
54
|
end
|
61
55
|
end
|
62
56
|
end
|
63
57
|
|
64
58
|
describe '<r:shop:categories>' do
|
65
59
|
it 'should render' do
|
66
|
-
mock(Shop::Tags::Helpers).current_categories(anything) { @
|
60
|
+
mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
|
67
61
|
tag = %{<r:shop:categories>success</r:shop:categories>}
|
68
|
-
|
62
|
+
exp = %{success}
|
69
63
|
|
70
|
-
|
64
|
+
@page.should render(tag).as(exp)
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|
74
68
|
describe '<r:shop:category:if_current>' do
|
75
69
|
before :each do
|
76
|
-
mock(Shop::Tags::Helpers).current_category(anything) { @
|
77
|
-
stub(@shop_category).id { 1 }
|
78
|
-
stub(@shop_category).handle { 'handle' }
|
70
|
+
mock(Shop::Tags::Helpers).current_category(anything) { @category }
|
79
71
|
end
|
80
|
-
context '
|
72
|
+
context 'this categories page' do
|
81
73
|
it 'should expand' do
|
82
|
-
page = pages(:home)
|
83
|
-
stub(page).slug { @shop_category.handle }
|
84
|
-
|
85
74
|
tag = %{<r:shop:category:if_current>success</r:shop:category:if_current>}
|
86
|
-
|
75
|
+
exp = %{success}
|
87
76
|
|
88
|
-
page.should render(tag).as(
|
77
|
+
@category.page.should render(tag).as(exp)
|
89
78
|
end
|
90
79
|
end
|
91
|
-
context '
|
80
|
+
context 'categories product page' do
|
92
81
|
it 'should expand' do
|
93
|
-
page = pages(:home)
|
94
|
-
stub(page).shop_category_id { @shop_category.id }
|
95
|
-
|
96
82
|
tag = %{<r:shop:category:if_current>success</r:shop:category:if_current>}
|
97
|
-
|
83
|
+
exp = %{success}
|
98
84
|
|
99
|
-
page.should render(tag).as(
|
100
|
-
end
|
101
|
-
end
|
102
|
-
context 'product page' do
|
103
|
-
it 'should expand' do
|
104
|
-
mock(Shop::Tags::Helpers).current_product(anything) { @shop_product }
|
105
|
-
stub(@shop_product).category { @shop_category }
|
106
|
-
|
107
|
-
tag = %{<r:shop:product><r:category:if_current>success</r:category:if_current></r:shop:product>}
|
108
|
-
expected = %{success}
|
109
|
-
|
110
|
-
pages(:home).should render(tag).as(expected)
|
85
|
+
@category.products.first.page.should render(tag).as(exp)
|
111
86
|
end
|
112
87
|
end
|
113
88
|
context 'failure' do
|
114
89
|
it 'should not expand' do
|
115
90
|
tag = %{<r:shop:category:if_current>failure</r:shop:category:if_current>}
|
116
|
-
|
91
|
+
exp = %{}
|
117
92
|
|
118
|
-
|
93
|
+
@page.should render(tag).as(exp)
|
119
94
|
end
|
120
95
|
end
|
121
96
|
end
|
122
97
|
|
123
98
|
describe 'simple attributes' do
|
124
99
|
before :each do
|
125
|
-
mock(Shop::Tags::Helpers).current_category(anything) { @
|
100
|
+
mock(Shop::Tags::Helpers).current_category(anything) { @category }
|
126
101
|
end
|
127
102
|
it 'should render <r:id />' do
|
128
|
-
stub(@shop_category).id { 1 }
|
129
|
-
|
130
103
|
tag = %{<r:shop:category:id />}
|
131
|
-
|
132
|
-
|
104
|
+
exp = @category.id.to_s
|
105
|
+
|
106
|
+
@page.should render(tag).as(exp)
|
133
107
|
end
|
134
108
|
it 'should render <r:name />' do
|
135
|
-
stub(@shop_category).name { 'name' }
|
136
|
-
|
137
109
|
tag = %{<r:shop:category:name />}
|
138
|
-
|
139
|
-
|
110
|
+
exp = @category.name
|
111
|
+
|
112
|
+
@page.should render(tag).as(exp)
|
140
113
|
end
|
141
114
|
it 'should render <r:handle />' do
|
142
|
-
stub(@shop_category).handle { 'handle' }
|
143
|
-
|
144
115
|
tag = %{<r:shop:category:handle />}
|
145
|
-
|
146
|
-
|
116
|
+
exp = @category.handle
|
117
|
+
|
118
|
+
@page.should render(tag).as(exp)
|
147
119
|
end
|
148
120
|
it 'should render <r:slug />' do
|
149
|
-
stub(@shop_category).slug { 'slug' }
|
150
|
-
|
151
121
|
tag = %{<r:shop:category:slug />}
|
152
|
-
|
153
|
-
pages(:home).should render(tag).as(expected)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe '<r:description />' do
|
158
|
-
it 'should render a textile filtered result' do
|
159
|
-
mock(Shop::Tags::Helpers).current_category(anything) { @shop_category }
|
160
|
-
stub(@shop_category).description { '*bold*' }
|
122
|
+
exp = @category.slug
|
161
123
|
|
162
|
-
tag
|
163
|
-
|
164
|
-
|
124
|
+
@page.should render(tag).as(exp)
|
125
|
+
end
|
126
|
+
describe '<r:description />' do
|
127
|
+
it 'should render a textile filtered result' do
|
128
|
+
tag = %{<r:shop:category:description />}
|
129
|
+
exp = TextileFilter.filter(@category.description)
|
130
|
+
|
131
|
+
@page.should render(tag).as(exp)
|
132
|
+
end
|
165
133
|
end
|
166
134
|
end
|
167
135
|
|
168
136
|
describe '<r:link />' do
|
169
137
|
before :each do
|
170
|
-
mock(Shop::Tags::Helpers).current_category(anything) { @
|
138
|
+
mock(Shop::Tags::Helpers).current_category(anything) { @category }
|
171
139
|
end
|
172
140
|
|
173
141
|
context 'standalone' do
|
174
|
-
before :each do
|
175
|
-
stub(@shop_category).slug { 'slug' }
|
176
|
-
stub(@shop_category).name { 'name' }
|
177
|
-
end
|
178
142
|
it 'should render an anchor element' do
|
179
143
|
tag = %{<r:shop:category:link />}
|
180
|
-
|
181
|
-
|
144
|
+
exp = %{<a href="#{@category.slug}">#{@category.name}</a>}
|
145
|
+
|
146
|
+
@page.should render(tag).as(exp)
|
182
147
|
end
|
183
148
|
it 'should assign attributes' do
|
184
149
|
tag = %{<r:shop:category:link title="title" data-title="data-title"/>}
|
185
|
-
|
186
|
-
|
150
|
+
exp = %{<a href="#{@category.slug}" data-title="data-title" title="title">#{@category.name}</a>}
|
151
|
+
|
152
|
+
@page.should render(tag).as(exp)
|
187
153
|
end
|
188
154
|
end
|
189
155
|
|
190
156
|
context 'wrapped' do
|
191
157
|
it 'should render an anchor element' do
|
192
|
-
stub(@shop_category).slug { 'slug' }
|
193
|
-
|
194
158
|
tag = %{<r:shop:category:link>title</r:shop:category:link>}
|
195
|
-
|
196
|
-
|
159
|
+
exp = %{<a href="#{@category.slug}">title</a>}
|
160
|
+
|
161
|
+
@page.should render(tag).as(exp)
|
197
162
|
end
|
198
163
|
end
|
199
164
|
end
|
@@ -2,7 +2,7 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Shop::Tags::Helpers do
|
4
4
|
|
5
|
-
dataset :pages, :shop_products, :shop_orders, :shop_addresses
|
5
|
+
dataset :pages, :shop_products, :shop_product_variants, :shop_orders, :shop_addresses, :shop_line_items
|
6
6
|
|
7
7
|
before :all do
|
8
8
|
@page = pages(:home)
|
@@ -26,44 +26,31 @@ describe Shop::Tags::Helpers do
|
|
26
26
|
before :each do
|
27
27
|
@category = shop_categories(:bread)
|
28
28
|
end
|
29
|
-
|
30
|
-
context '
|
31
|
-
before :each do
|
32
|
-
@tag.locals.shop_categories = [@category]
|
33
|
-
end
|
34
|
-
it 'should return categories' do
|
35
|
-
result = Shop::Tags::Helpers.current_categories(@tag)
|
36
|
-
result.should == [@category]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'search query sent to page' do
|
29
|
+
|
30
|
+
context 'parent sent' do
|
41
31
|
before :each do
|
42
|
-
@tag.
|
32
|
+
@tag.attr = { 'parent' => @category.page.parent.slug }
|
43
33
|
end
|
44
|
-
it 'should return matching categories' do
|
34
|
+
it 'should return the matching categories' do
|
45
35
|
result = Shop::Tags::Helpers.current_categories(@tag)
|
46
|
-
result.should ==
|
36
|
+
result.should == @category.page.parent.children.map(&:shop_category)
|
47
37
|
end
|
48
38
|
end
|
49
39
|
|
50
|
-
context '
|
40
|
+
context 'categories previously set' do
|
51
41
|
before :each do
|
52
|
-
@tag.
|
42
|
+
@tag.locals.shop_categories = [@category]
|
53
43
|
end
|
54
|
-
it 'should return
|
44
|
+
it 'should return categories' do
|
55
45
|
result = Shop::Tags::Helpers.current_categories(@tag)
|
56
46
|
result.should == [@category]
|
57
47
|
end
|
58
48
|
end
|
59
49
|
|
60
50
|
context 'nothing additional sent' do
|
61
|
-
before :each do
|
62
|
-
mock(ShopCategory).all { [@category] }
|
63
|
-
end
|
64
51
|
it 'should return all categories in the database' do
|
65
52
|
result = Shop::Tags::Helpers.current_categories(@tag)
|
66
|
-
result.should ==
|
53
|
+
result.should == ShopCategory.all
|
67
54
|
end
|
68
55
|
end
|
69
56
|
end
|
@@ -73,40 +60,40 @@ describe Shop::Tags::Helpers do
|
|
73
60
|
@category = shop_categories(:bread)
|
74
61
|
@product = shop_categories(:bread).products.first
|
75
62
|
end
|
76
|
-
|
77
|
-
context '
|
63
|
+
|
64
|
+
context 'name sent' do
|
78
65
|
before :each do
|
79
|
-
@tag.
|
66
|
+
@tag.attr = { 'name' => @category.name }
|
80
67
|
end
|
81
|
-
it 'should return the
|
68
|
+
it 'should return the matching category' do
|
82
69
|
result = Shop::Tags::Helpers.current_category(@tag)
|
83
70
|
result.should == @category
|
84
71
|
end
|
85
72
|
end
|
86
73
|
|
87
|
-
context '
|
74
|
+
context 'handle sent' do
|
88
75
|
before :each do
|
89
|
-
@tag.
|
76
|
+
@tag.attr = { 'handle' => @category.slug }
|
90
77
|
end
|
91
|
-
it 'should return the category
|
78
|
+
it 'should return the matching category' do
|
92
79
|
result = Shop::Tags::Helpers.current_category(@tag)
|
93
80
|
result.should == @category
|
94
81
|
end
|
95
82
|
end
|
96
|
-
|
97
|
-
context '
|
83
|
+
|
84
|
+
context 'category previously set' do
|
98
85
|
before :each do
|
99
|
-
@tag.
|
86
|
+
@tag.locals.shop_category = @category
|
100
87
|
end
|
101
|
-
it 'should return the
|
88
|
+
it 'should return the existing category' do
|
102
89
|
result = Shop::Tags::Helpers.current_category(@tag)
|
103
90
|
result.should == @category
|
104
91
|
end
|
105
92
|
end
|
106
93
|
|
107
|
-
context '
|
94
|
+
context 'product previously set' do
|
108
95
|
before :each do
|
109
|
-
@tag.locals.
|
96
|
+
@tag.locals.shop_product = @product
|
110
97
|
end
|
111
98
|
it 'should return the category of the product attached to the page' do
|
112
99
|
result = Shop::Tags::Helpers.current_category(@tag)
|
@@ -114,11 +101,11 @@ describe Shop::Tags::Helpers do
|
|
114
101
|
end
|
115
102
|
end
|
116
103
|
|
117
|
-
context 'the current page
|
104
|
+
context 'the current page has a product attached to it' do
|
118
105
|
before :each do
|
119
|
-
@tag.locals.page.
|
106
|
+
@tag.locals.page.shop_product = @product
|
120
107
|
end
|
121
|
-
it 'should return the category
|
108
|
+
it 'should return the category of the product attached to the page' do
|
122
109
|
result = Shop::Tags::Helpers.current_category(@tag)
|
123
110
|
result.should == @category
|
124
111
|
end
|
@@ -148,7 +135,17 @@ describe Shop::Tags::Helpers do
|
|
148
135
|
@product = shop_products(:soft_bread)
|
149
136
|
@category = shop_categories(:bread)
|
150
137
|
end
|
151
|
-
|
138
|
+
|
139
|
+
context 'category sent' do
|
140
|
+
before :each do
|
141
|
+
@tag.attr = { 'category' => @product.category.page.slug }
|
142
|
+
end
|
143
|
+
it 'should return the matching products' do
|
144
|
+
result = Shop::Tags::Helpers.current_products(@tag)
|
145
|
+
result.should == @product.page.parent.children.map(&:shop_product)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
152
149
|
context 'products previously set' do
|
153
150
|
before :each do
|
154
151
|
@tag.locals.shop_products = [ @product ]
|
@@ -179,59 +176,76 @@ describe Shop::Tags::Helpers do
|
|
179
176
|
end
|
180
177
|
end
|
181
178
|
|
182
|
-
context '
|
179
|
+
context 'nothing additional sent' do
|
183
180
|
before :each do
|
184
|
-
|
181
|
+
mock(ShopProduct).all { [@product] }
|
185
182
|
end
|
186
|
-
it 'should return
|
183
|
+
it 'should return all products in the database' do
|
187
184
|
result = Shop::Tags::Helpers.current_products(@tag)
|
188
185
|
result.should == [@product]
|
189
186
|
end
|
190
187
|
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe '#current_product' do
|
191
|
+
before :each do
|
192
|
+
@product = shop_products(:soft_bread)
|
193
|
+
@line_item = shop_line_items(:one)
|
194
|
+
end
|
191
195
|
|
192
|
-
context '
|
196
|
+
context 'name sent' do
|
193
197
|
before :each do
|
194
|
-
@tag.attr = { '
|
198
|
+
@tag.attr = { 'name' => @product.name }
|
195
199
|
end
|
196
|
-
it 'should return the matching
|
197
|
-
result = Shop::Tags::Helpers.
|
198
|
-
result.should ==
|
200
|
+
it 'should return the matching product' do
|
201
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
202
|
+
result.should == @product
|
199
203
|
end
|
200
204
|
end
|
201
205
|
|
202
|
-
context '
|
206
|
+
context 'sku sent' do
|
203
207
|
before :each do
|
204
|
-
|
208
|
+
@tag.attr = { 'sku' => @product.slug }
|
205
209
|
end
|
206
|
-
it 'should return
|
207
|
-
result = Shop::Tags::Helpers.
|
208
|
-
result.should ==
|
210
|
+
it 'should return the matching product' do
|
211
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
212
|
+
result.should == @product
|
209
213
|
end
|
210
214
|
end
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
before :each do
|
215
|
-
@product = shop_products(:soft_bread)
|
215
|
+
|
216
|
+
context 'sku not unique' do
|
217
|
+
it 'should use the full slug not the single product url'
|
216
218
|
end
|
217
219
|
|
218
220
|
context 'product previously set' do
|
219
221
|
before :each do
|
220
222
|
@tag.locals.shop_product = @product
|
221
223
|
end
|
222
|
-
it 'should return the product
|
224
|
+
it 'should return the product in that context' do
|
223
225
|
result = Shop::Tags::Helpers.current_product(@tag)
|
224
226
|
result.should == @product
|
225
227
|
end
|
226
228
|
end
|
227
|
-
|
228
|
-
context '
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
229
|
+
|
230
|
+
context 'line item previously set' do
|
231
|
+
context 'for product' do
|
232
|
+
before :each do
|
233
|
+
@tag.locals.shop_line_item = @line_item
|
234
|
+
end
|
235
|
+
it 'should return the product of the line item' do
|
236
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
237
|
+
result.should == @line_item.item
|
238
|
+
end
|
239
|
+
end
|
240
|
+
context 'not for product' do
|
241
|
+
before :each do
|
242
|
+
@line_item.item_type = 'ShopOther'
|
243
|
+
@tag.locals.shop_line_item = @line_item
|
244
|
+
end
|
245
|
+
it 'should not return the product' do
|
246
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
247
|
+
result.should be_nil
|
248
|
+
end
|
235
249
|
end
|
236
250
|
end
|
237
251
|
|
@@ -291,9 +305,44 @@ describe Shop::Tags::Helpers do
|
|
291
305
|
|
292
306
|
end
|
293
307
|
|
308
|
+
describe '#current_line_items' do
|
309
|
+
before :each do
|
310
|
+
@order = shop_orders(:several_items)
|
311
|
+
@tag.locals.shop_order = @order
|
312
|
+
end
|
313
|
+
|
314
|
+
context 'line items previously set' do
|
315
|
+
before :each do
|
316
|
+
@tag.locals.shop_line_items = [@order.line_items.first]
|
317
|
+
end
|
318
|
+
it 'should return the order' do
|
319
|
+
result = Shop::Tags::Helpers.current_line_items(@tag)
|
320
|
+
result.should == [@order.line_items.first]
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'key and value sent' do
|
325
|
+
before :each do
|
326
|
+
@tag.attr = { 'key' => 'id', 'value' => @order.line_items.first.id }
|
327
|
+
end
|
328
|
+
it 'should return the matching order' do
|
329
|
+
result = Shop::Tags::Helpers.current_line_items(@tag)
|
330
|
+
result.should == [@order.line_items.first]
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
context 'nothing available to find the items' do
|
335
|
+
it 'should return the current orders items' do
|
336
|
+
result = Shop::Tags::Helpers.current_line_items(@tag)
|
337
|
+
result.should == @order.line_items
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
342
|
+
|
294
343
|
describe '#current_line_item' do
|
295
344
|
before :each do
|
296
|
-
@item = shop_line_items(:
|
345
|
+
@item = shop_line_items(:one)
|
297
346
|
end
|
298
347
|
|
299
348
|
context 'existing line item' do
|
@@ -338,7 +387,7 @@ describe Shop::Tags::Helpers do
|
|
338
387
|
context 'current_order exists and has billing' do
|
339
388
|
before :each do
|
340
389
|
@order = shop_orders(:one_item)
|
341
|
-
@order.update_attribute(:
|
390
|
+
@order.update_attribute(:billing, @address)
|
342
391
|
@tag.locals.shop_order = @order
|
343
392
|
end
|
344
393
|
it 'should return the order billing address' do
|
@@ -365,4 +414,48 @@ describe Shop::Tags::Helpers do
|
|
365
414
|
end
|
366
415
|
end
|
367
416
|
|
417
|
+
describe '#current_product_variants' do
|
418
|
+
before :each do
|
419
|
+
@product = shop_products(:crusty_bread)
|
420
|
+
end
|
421
|
+
|
422
|
+
context 'existing product variant' do
|
423
|
+
it 'should return that existing line item' do
|
424
|
+
@tag.locals.shop_product = @product
|
425
|
+
|
426
|
+
result = Shop::Tags::Helpers.current_product_variants(@tag)
|
427
|
+
result.should == @product.variants
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
context 'nothing sent or available' do
|
432
|
+
it 'should return nil' do
|
433
|
+
result = Shop::Tags::Helpers.current_product_variants(@tag)
|
434
|
+
result.should be_nil
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
describe '#current_product_variant' do
|
440
|
+
before :each do
|
441
|
+
@variant = shop_product_variants(:mouldy_crusty_bread)
|
442
|
+
end
|
443
|
+
|
444
|
+
context 'existing product variant' do
|
445
|
+
it 'should return that existing variant' do
|
446
|
+
@tag.locals.shop_product_variant = @variant
|
447
|
+
|
448
|
+
result = Shop::Tags::Helpers.current_product_variant(@tag)
|
449
|
+
result.should == @variant
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
context 'nothing sent or available' do
|
454
|
+
it 'should return nil' do
|
455
|
+
result = Shop::Tags::Helpers.current_product_variant(@tag)
|
456
|
+
result.should be_nil
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
368
461
|
end
|