radiant-shop-extension 0.11.6 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +21 -3
- data/LICENSE +42 -0
- data/README.md +62 -25
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +1 -0
- data/app/controllers/admin/shop/orders_controller.rb +1 -1
- data/app/controllers/admin/shop/products_controller.rb +18 -7
- data/app/helpers/shop_helper.rb +8 -0
- data/app/models/form_address.rb +5 -5
- data/app/models/form_checkout.rb +25 -17
- data/app/models/form_line_item.rb +1 -1
- data/app/models/shop_category.rb +22 -7
- data/app/models/shop_customer.rb +1 -1
- data/app/models/shop_line_item.rb +26 -26
- data/app/models/shop_order.rb +0 -2
- data/app/models/shop_product.rb +15 -18
- data/app/views/.DS_Store +0 -0
- data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
- data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
- data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/index/_product.html.haml +1 -1
- data/config/locales/en.yml +8 -7
- data/config/routes.rb +4 -16
- data/db/migrate/20101011063133_setup_shop.rb +94 -0
- data/db/seeds/forms.rb +113 -154
- data/db/seeds/layouts.rb +67 -103
- data/db/seeds/pages.rb +101 -0
- data/db/seeds/products.rb +29 -0
- data/db/seeds/snippets.rb +36 -21
- data/lib/shop/controllers/application_controller.rb +5 -3
- data/lib/shop/models/form_extension.rb +1 -2
- data/lib/shop/models/page.rb +0 -1
- data/lib/shop/models/user.rb +0 -1
- data/lib/shop/tags/card.rb +8 -2
- data/lib/shop/tags/cart.rb +5 -1
- data/lib/shop/tags/helpers.rb +35 -60
- data/lib/shop/tags/item.rb +2 -16
- data/lib/shop/tags/product.rb +7 -0
- data/lib/tasks/shop_extension_tasks.rake +9 -4
- data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
- data/radiant-shop-extension.gemspec +25 -201
- data/shop_extension.rb +18 -19
- data/spec/datasets/forms.rb +25 -28
- data/spec/datasets/shop_categories.rb +2 -2
- data/spec/datasets/shop_config.rb +24 -0
- data/spec/datasets/shop_customers.rb +1 -0
- data/spec/datasets/shop_line_items.rb +21 -3
- data/spec/datasets/shop_products.rb +4 -1
- data/spec/datasets/tags.rb +19 -0
- data/spec/lib/shop/models/page_spec.rb +1 -1
- data/spec/lib/shop/tags/card_spec.rb +30 -4
- data/spec/lib/shop/tags/cart_spec.rb +29 -12
- data/spec/lib/shop/tags/helpers_spec.rb +45 -66
- data/spec/lib/shop/tags/item_spec.rb +6 -10
- data/spec/lib/shop/tags/product_spec.rb +27 -2
- data/spec/models/form_address_spec.rb +9 -8
- data/spec/models/form_checkout_spec.rb +28 -22
- data/spec/models/shop_category_spec.rb +2 -10
- data/spec/models/shop_line_item_spec.rb +71 -34
- data/spec/models/shop_order_spec.rb +5 -5
- data/spec/models/shop_product_attachment_spec.rb +1 -0
- data/spec/models/shop_product_spec.rb +4 -47
- data/spec/spec.opts +3 -5
- metadata +60 -248
- data/Gemfile +0 -26
- data/Gemfile.lock +0 -75
- data/MIT-LICENSE +0 -20
- data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
- data/app/controllers/admin/shop/discounts_controller.rb +0 -64
- data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
- data/app/controllers/admin/shop/packages_controller.rb +0 -63
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
- data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
- data/app/controllers/admin/shop/variants_controller.rb +0 -48
- data/app/models/form_discount.rb +0 -39
- data/app/models/shop_discount.rb +0 -37
- data/app/models/shop_discountable.rb +0 -64
- data/app/models/shop_group.rb +0 -15
- data/app/models/shop_grouping.rb +0 -6
- data/app/models/shop_package.rb +0 -74
- data/app/models/shop_packing.rb +0 -22
- data/app/models/shop_product_variant.rb +0 -34
- data/app/models/shop_variant.rb +0 -23
- data/app/views/admin/pages/_shop_category.html.haml +0 -4
- data/app/views/admin/pages/_shop_product.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
- data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
- data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
- data/app/views/admin/shop/discounts/edit.html.haml +0 -11
- data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
- data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
- data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
- data/app/views/admin/shop/discounts/index.html.haml +0 -13
- data/app/views/admin/shop/discounts/new.html.haml +0 -11
- data/app/views/admin/shop/discounts/remove.html.haml +0 -12
- data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
- data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
- data/app/views/admin/shop/packages/edit.html.haml +0 -11
- data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
- data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
- data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
- data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
- data/app/views/admin/shop/packages/index.html.haml +0 -13
- data/app/views/admin/shop/packages/new.html.haml +0 -11
- data/app/views/admin/shop/packages/remove.html.haml +0 -12
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
- data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
- data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
- data/app/views/admin/shop/variants/edit.html.haml +0 -11
- data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
- data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
- data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
- data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
- data/app/views/admin/shop/variants/index.html.haml +0 -13
- data/app/views/admin/shop/variants/new.html.haml +0 -11
- data/app/views/admin/shop/variants/remove.html.haml +0 -12
- data/app/views/shop/categories/show.html.haml +0 -1
- data/app/views/shop/orders/show.html.haml +0 -1
- data/app/views/shop/products/index.html.haml +0 -1
- data/app/views/shop/products/show.html.haml +0 -1
- data/cucumber.yml +0 -1
- data/db/migrate/20100311053701_initial.rb +0 -153
- data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
- data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
- data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
- data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
- data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
- data/db/migrate/20100929081200_create_variants.rb +0 -20
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
- data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
- data/db/migrate/20100930235221_create_packages.rb +0 -31
- data/db/migrate/20101005231713_create_page_ids.rb +0 -11
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
- data/db/migrate/20101010071143_create_discounts.rb +0 -29
- data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
- data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
- data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
- data/features/support/env.rb +0 -16
- data/features/support/paths.rb +0 -14
- data/lib/shop/interface/packages.rb +0 -34
- data/lib/shop/interface/variants.rb +0 -34
- data/lib/shop/tags/package.rb +0 -95
- data/lib/shop/tags/product_variant.rb +0 -52
- data/lib/shop/tags/responses.rb +0 -34
- data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
- data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
- data/mockups/discounts/new-edit.bmml +0 -492
- data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
- data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
- data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
- data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
- data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
- data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
- data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
- data/spec/datasets/shop_discountables.rb +0 -22
- data/spec/datasets/shop_discounts.rb +0 -29
- data/spec/datasets/shop_groups.rb +0 -15
- data/spec/datasets/shop_packages.rb +0 -25
- data/spec/datasets/shop_product_variants.rb +0 -22
- data/spec/datasets/shop_variants.rb +0 -17
- data/spec/lib/shop/tags/package_spec.rb +0 -342
- data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
- data/spec/lib/shop/tags/responses_spec.rb +0 -129
- data/spec/models/form_discount_spec.rb +0 -63
- data/spec/models/shop_discount_spec.rb +0 -130
- data/spec/models/shop_discountable_spec.rb +0 -114
- data/spec/models/shop_group_spec.rb +0 -38
- data/spec/models/shop_package_spec.rb +0 -117
- data/spec/models/shop_packing_spec.rb +0 -67
- data/spec/models/shop_product_variant_spec.rb +0 -92
- data/spec/models/shop_variant_spec.rb +0 -32
data/spec/datasets/forms.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class FormsDataset < Dataset::Base
|
2
2
|
|
3
|
-
uses :pages, :shop_orders
|
3
|
+
uses :pages, :shop_orders
|
4
4
|
|
5
5
|
def load
|
6
6
|
create_record :form, :checkout,
|
@@ -84,16 +84,27 @@ CONFIG
|
|
84
84
|
|
85
85
|
def mock_valid_form_checkout_request
|
86
86
|
@form = forms(:checkout)
|
87
|
+
@form.page = pages(:home)
|
87
88
|
@form[:extensions] = {
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
|
92
|
-
|
93
|
-
:mail => {
|
94
|
-
:subject=> 'new order',
|
95
|
-
:bcc => 'orders@example.com'
|
89
|
+
:bogus_checkout => {
|
90
|
+
:extension => 'checkout',
|
91
|
+
:test => true,
|
92
|
+
:gateway => {
|
93
|
+
:name => 'Bogus'
|
96
94
|
},
|
95
|
+
:extensions => {
|
96
|
+
:order => {
|
97
|
+
:extension => 'mail',
|
98
|
+
:subject => 'new order',
|
99
|
+
:from => 'orders@bogus.com',
|
100
|
+
:to => 'orders@bogus.com'
|
101
|
+
},
|
102
|
+
:invoice => {
|
103
|
+
:extension => 'mail',
|
104
|
+
:from => 'orders@bogus.com',
|
105
|
+
:subject => 'your invoice'
|
106
|
+
},
|
107
|
+
}
|
97
108
|
}
|
98
109
|
}
|
99
110
|
|
@@ -119,10 +130,12 @@ CONFIG
|
|
119
130
|
|
120
131
|
def mock_valid_form_address_request
|
121
132
|
@form = forms(:checkout)
|
133
|
+
@form.page = pages(:home)
|
122
134
|
@form[:extensions] = {
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
135
|
+
:addresses => {
|
136
|
+
:extension => 'address',
|
137
|
+
:billing => true,
|
138
|
+
:shipping => true
|
126
139
|
}
|
127
140
|
}
|
128
141
|
|
@@ -152,22 +165,6 @@ CONFIG
|
|
152
165
|
@request.session = { :shop_order => @order.id }
|
153
166
|
end
|
154
167
|
|
155
|
-
def mock_valid_form_discount_request
|
156
|
-
@form = forms(:checkout)
|
157
|
-
@form[:extensions] = {
|
158
|
-
:discount => {
|
159
|
-
:process => 'add'
|
160
|
-
}
|
161
|
-
}
|
162
|
-
@data = {
|
163
|
-
:discount => {
|
164
|
-
:code => shop_discounts(:ten_percent).code
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
@request.session = { :shop_order => @order.id }
|
169
|
-
end
|
170
|
-
|
171
168
|
end
|
172
169
|
|
173
170
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ShopConfigDataset < Dataset::Base
|
2
|
+
|
3
|
+
def load
|
4
|
+
Radiant::Config['shop.root_page_id'] = pages(:home).id
|
5
|
+
|
6
|
+
Radiant::Config['shop.layout_product'] = 'Product'
|
7
|
+
Radiant::Config['shop.layout_category'] = 'Products'
|
8
|
+
|
9
|
+
Radiant::Config['shop.price_unit'] = '$'
|
10
|
+
Radiant::Config['shop.price_precision'] = 2
|
11
|
+
Radiant::Config['shop.price_separator'] = '.'
|
12
|
+
Radiant::Config['shop.price_delimiter'] = ','
|
13
|
+
|
14
|
+
Radiant::Config['shop.tax_strategy'] = 'inclusive'
|
15
|
+
Radiant::Config['shop.tax_percentage'] = '10'
|
16
|
+
Radiant::Config['shop.tax_name'] = 'gst'
|
17
|
+
|
18
|
+
Radiant::Config['shop.date_format'] = '%d/%m/%Y'
|
19
|
+
|
20
|
+
# Scoped Customer Welcome Page
|
21
|
+
Radiant::Config['scoped.customer.redirect'] = '/cart'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -1,10 +1,28 @@
|
|
1
|
+
class ShopProductAlternative < ShopProduct; end
|
2
|
+
|
1
3
|
class ShopLineItemsDataset < Dataset::Base
|
2
4
|
|
3
5
|
uses :shop_products, :shop_orders
|
4
6
|
|
5
7
|
def load
|
6
|
-
create_record :shop_line_item, :one,
|
7
|
-
|
8
|
-
|
8
|
+
create_record :shop_line_item, :one,
|
9
|
+
:item_id => shop_products(:crusty_bread).id,
|
10
|
+
:order => shop_orders(:one_item),
|
11
|
+
:item_type => 'ShopProduct',
|
12
|
+
:item_price => shop_products(:crusty_bread).price
|
13
|
+
|
14
|
+
create_record :shop_line_item, :two,
|
15
|
+
:item_id => shop_products(:soft_bread).id,
|
16
|
+
:order => shop_orders(:several_items),
|
17
|
+
:item_type => 'ShopProduct',
|
18
|
+
:quantity => 2,
|
19
|
+
:item_price => shop_products(:soft_bread).price
|
20
|
+
|
21
|
+
create_record :shop_line_item, :three,
|
22
|
+
:item_id => shop_products(:choc_milk).id,
|
23
|
+
:order => shop_orders(:several_items),
|
24
|
+
:item_type => 'ShopProduct',
|
25
|
+
:quantity => 3,
|
26
|
+
:item_price => shop_products(:choc_milk).price
|
9
27
|
end
|
10
28
|
end
|
@@ -3,6 +3,8 @@ class ShopProductsDataset < Dataset::Base
|
|
3
3
|
uses :shop_categories
|
4
4
|
|
5
5
|
def load
|
6
|
+
Radiant::Config['shop.root_page_id'] = pages(:home).id
|
7
|
+
|
6
8
|
categories = {
|
7
9
|
:bread => [ :soft, :crusty, :warm ],
|
8
10
|
:milk => [ :full, :hilo, :choc ]
|
@@ -16,7 +18,8 @@ class ShopProductsDataset < Dataset::Base
|
|
16
18
|
:breadcrumb => "#{product.to_s}_#{category.to_s}",
|
17
19
|
:parent => shop_categories(category).page,
|
18
20
|
:class_name => 'ShopProductPage',
|
19
|
-
:layout => layouts(:product)
|
21
|
+
:layout => layouts(:product),
|
22
|
+
:position => i + 1
|
20
23
|
|
21
24
|
create_record :shop_product, "#{product.to_s}_#{category.to_s}".to_sym,
|
22
25
|
:price => i + 1 * 10,
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class TagsDataset < Dataset::Base
|
2
|
+
|
3
|
+
helpers do
|
4
|
+
def mock_valid_tag_for_helper
|
5
|
+
@tag = OpenStruct.new({
|
6
|
+
:attr => {},
|
7
|
+
:locals => OpenStruct.new({
|
8
|
+
:page => OpenStruct.new({
|
9
|
+
:params => {},
|
10
|
+
:request => OpenStruct.new({
|
11
|
+
:session => {}
|
12
|
+
})
|
13
|
+
})
|
14
|
+
})
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -21,16 +21,42 @@ describe Shop::Tags::Card do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe 'form:card:type' do
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
context 'all cards' do
|
25
|
+
it 'should output the card types' do
|
26
|
+
tag = %{<r:form:card:type />}
|
27
|
+
exp = %{<select name="card[type]" id="card_type">
|
27
28
|
<option value="amex">American Express</option>
|
28
29
|
<option value="diners">Diners Club</option>
|
29
30
|
<option value="mastercard">Master Card</option>
|
30
31
|
<option value="visa">Visa</option>
|
31
32
|
</select>}
|
32
33
|
|
33
|
-
|
34
|
+
@page.should render(tag).as(exp)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'except amex and diners' do
|
39
|
+
it 'should output all except amex and diners' do
|
40
|
+
tag = %{<r:form:card:type except="amex,diners" />}
|
41
|
+
exp = %{<select name="card[type]" id="card_type">
|
42
|
+
<option value="mastercard">Master Card</option>
|
43
|
+
<option value="visa">Visa</option>
|
44
|
+
</select>}
|
45
|
+
|
46
|
+
@page.should render(tag).as(exp)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'only amex and diners' do
|
51
|
+
it 'should output all except amex' do
|
52
|
+
tag = %{<r:form:card:type only="amex,diners" />}
|
53
|
+
exp = %{<select name="card[type]" id="card_type">
|
54
|
+
<option value="amex">American Express</option>
|
55
|
+
<option value="diners">Diners Club</option>
|
56
|
+
</select>}
|
57
|
+
|
58
|
+
@page.should render(tag).as(exp)
|
59
|
+
end
|
34
60
|
end
|
35
61
|
end
|
36
62
|
|
@@ -6,17 +6,18 @@ require 'spec/helpers/nested_tag_helper'
|
|
6
6
|
#
|
7
7
|
describe Shop::Tags::Cart do
|
8
8
|
|
9
|
-
dataset :pages, :shop_orders, :shop_payments
|
9
|
+
dataset :pages, :tags, :shop_config, :shop_orders, :shop_payments
|
10
10
|
|
11
11
|
it 'should describe these tags' do
|
12
12
|
Shop::Tags::Cart.tags.sort.should == [
|
13
|
+
'shop:cart',
|
14
|
+
'shop:cart:forget',
|
13
15
|
'shop:cart:if_cart',
|
14
16
|
'shop:cart:unless_cart',
|
15
17
|
'shop:cart:payment',
|
16
18
|
'shop:cart:payment:if_paid',
|
17
19
|
'shop:cart:payment:unless_paid',
|
18
20
|
'shop:cart:payment:date',
|
19
|
-
'shop:cart',
|
20
21
|
'shop:cart:id',
|
21
22
|
'shop:cart:status',
|
22
23
|
'shop:cart:quantity',
|
@@ -24,15 +25,17 @@ describe Shop::Tags::Cart do
|
|
24
25
|
'shop:cart:price'].sort
|
25
26
|
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
context 'cart tags' do
|
29
|
+
|
30
|
+
before :all do
|
31
|
+
@page = pages(:home)
|
32
|
+
end
|
33
|
+
|
34
|
+
before :each do
|
35
|
+
@order = shop_orders(:several_items)
|
36
|
+
mock_valid_tag_for_helper
|
37
|
+
end
|
38
|
+
|
36
39
|
describe '<r:shop:cart>' do
|
37
40
|
context 'success' do
|
38
41
|
it 'should render' do
|
@@ -42,6 +45,8 @@ describe Shop::Tags::Cart do
|
|
42
45
|
expected = %{success}
|
43
46
|
|
44
47
|
@page.should render(tag).as(expected)
|
48
|
+
|
49
|
+
@tag.locals.page.request.session[:shop_order].should be_nil
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
@@ -55,6 +60,18 @@ describe Shop::Tags::Cart do
|
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
63
|
+
describe '<r:shop:cart:forget>' do
|
64
|
+
it 'should remove the cart from the session' do
|
65
|
+
pending 'dont know how to test this'
|
66
|
+
@tag.locals.page.request.session[:shop_order] = @order
|
67
|
+
|
68
|
+
tag = %{<r:shop:cart />}
|
69
|
+
expected = %{}
|
70
|
+
|
71
|
+
@page.should render(tag).as(expected)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
58
75
|
describe '<r:shop:cart:if_cart>' do
|
59
76
|
context 'success' do
|
60
77
|
it 'should render' do
|
@@ -160,7 +177,7 @@ describe Shop::Tags::Cart do
|
|
160
177
|
describe '<r:shop:cart:payment:date />' do
|
161
178
|
it 'should return the created_at date of the payment' do
|
162
179
|
tag = %{<r:shop:cart:payment:date />}
|
163
|
-
expected = @order.payment.created_at.
|
180
|
+
expected = @order.payment.created_at.strftime(Radiant::Config['shop.date_format'])
|
164
181
|
@page.should render(tag).as(expected)
|
165
182
|
end
|
166
183
|
end
|
@@ -2,24 +2,14 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Shop::Tags::Helpers do
|
4
4
|
|
5
|
-
dataset :pages, :
|
5
|
+
dataset :pages, :tags, :shop_products, :shop_orders, :shop_addresses, :shop_line_items, :shop_product_attachments
|
6
6
|
|
7
7
|
before :all do
|
8
8
|
@page = pages(:home)
|
9
9
|
end
|
10
10
|
|
11
11
|
before(:each) do
|
12
|
-
|
13
|
-
:attr => {},
|
14
|
-
:locals => OpenStruct.new({
|
15
|
-
:page => OpenStruct.new({
|
16
|
-
:params => {},
|
17
|
-
:request => OpenStruct.new({
|
18
|
-
:session => {}
|
19
|
-
})
|
20
|
-
})
|
21
|
-
})
|
22
|
-
})
|
12
|
+
mock_valid_tag_for_helper
|
23
13
|
end
|
24
14
|
|
25
15
|
describe '#current_categories' do
|
@@ -227,6 +217,22 @@ describe Shop::Tags::Helpers do
|
|
227
217
|
end
|
228
218
|
end
|
229
219
|
|
220
|
+
context 'position sent' do
|
221
|
+
before :each do
|
222
|
+
@tag.locals.shop_category = shop_categories(:bread)
|
223
|
+
end
|
224
|
+
it 'should return the matching product at that position' do
|
225
|
+
@tag.attr = { 'position' => 1 }
|
226
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
227
|
+
result.should == shop_categories(:bread).products[0]
|
228
|
+
end
|
229
|
+
it 'should return the matching product at that position or the first' do
|
230
|
+
@tag.attr = { 'position' => 0 }
|
231
|
+
result = Shop::Tags::Helpers.current_product(@tag)
|
232
|
+
result.should == shop_categories(:bread).products[0]
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
230
236
|
context 'line item previously set' do
|
231
237
|
context 'for product' do
|
232
238
|
before :each do
|
@@ -261,6 +267,33 @@ describe Shop::Tags::Helpers do
|
|
261
267
|
|
262
268
|
end
|
263
269
|
|
270
|
+
describe '#current_image' do
|
271
|
+
before :each do
|
272
|
+
@attachment = shop_products(:crusty_bread).attachments.first
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'image previously set' do
|
276
|
+
before :each do
|
277
|
+
@tag.locals.image = @attachment
|
278
|
+
end
|
279
|
+
it 'should return the image' do
|
280
|
+
result = Shop::Tags::Helpers.current_image(@tag)
|
281
|
+
result.should == @attachment.image
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'position set' do
|
286
|
+
before :each do
|
287
|
+
@tag.locals.images = shop_products(:crusty_bread).attachments
|
288
|
+
@tag.attr = { 'position' => 1 }
|
289
|
+
end
|
290
|
+
it 'should return the image at that position' do
|
291
|
+
result = Shop::Tags::Helpers.current_image(@tag)
|
292
|
+
result.should == shop_products(:crusty_bread).attachments[0]
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
264
297
|
describe '#current_order' do
|
265
298
|
before :each do
|
266
299
|
@order = shop_orders(:one_item)
|
@@ -321,16 +354,6 @@ describe Shop::Tags::Helpers do
|
|
321
354
|
end
|
322
355
|
end
|
323
356
|
|
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
357
|
context 'nothing available to find the items' do
|
335
358
|
it 'should return the current orders items' do
|
336
359
|
result = Shop::Tags::Helpers.current_line_items(@tag)
|
@@ -414,48 +437,4 @@ describe Shop::Tags::Helpers do
|
|
414
437
|
end
|
415
438
|
end
|
416
439
|
|
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
|
-
|
461
440
|
end
|
@@ -6,7 +6,7 @@ require 'spec/helpers/nested_tag_helper'
|
|
6
6
|
#
|
7
7
|
describe Shop::Tags::Item do
|
8
8
|
|
9
|
-
dataset :pages, :shop_orders, :shop_line_items
|
9
|
+
dataset :pages, :shop_config, :shop_orders, :shop_line_items
|
10
10
|
|
11
11
|
it 'should describe these tags' do
|
12
12
|
Shop::Tags::Item.tags.sort.should == [
|
@@ -18,13 +18,9 @@ describe Shop::Tags::Item do
|
|
18
18
|
'shop:cart:item:id',
|
19
19
|
'shop:cart:item:quantity',
|
20
20
|
'shop:cart:item:name',
|
21
|
-
'shop:cart:item:sku',
|
22
|
-
'shop:cart:item:link',
|
23
21
|
'shop:cart:item:price',
|
24
|
-
'shop:cart:item:
|
25
|
-
'shop:cart:item:
|
26
|
-
'shop:cart:item:if_discounted',
|
27
|
-
'shop:cart:item:unless_discounted'].sort
|
22
|
+
'shop:cart:item:sku',
|
23
|
+
'shop:cart:item:link'].sort
|
28
24
|
end
|
29
25
|
|
30
26
|
context 'within a cart' do
|
@@ -223,12 +219,12 @@ describe Shop::Tags::Item do
|
|
223
219
|
context 'standalone' do
|
224
220
|
it 'should render an anchor element' do
|
225
221
|
tag = %{<r:shop:cart:item:link />}
|
226
|
-
exp = %{<a href="#{@line_item.item.
|
222
|
+
exp = %{<a href="#{@line_item.item.url}">#{@line_item.item.name}</a>}
|
227
223
|
pages(:home).should render(tag).as(exp)
|
228
224
|
end
|
229
225
|
it 'should assign attributes' do
|
230
226
|
tag = %{<r:shop:cart:item:link title="title" data-title="data-title"/>}
|
231
|
-
exp = %{<a href="#{@line_item.item.
|
227
|
+
exp = %{<a href="#{@line_item.item.url}" data-title="data-title" title="title">#{@line_item.item.name}</a>}
|
232
228
|
pages(:home).should render(tag).as(exp)
|
233
229
|
end
|
234
230
|
end
|
@@ -236,7 +232,7 @@ describe Shop::Tags::Item do
|
|
236
232
|
context 'wrapped' do
|
237
233
|
it 'should render an anchor element' do
|
238
234
|
tag = %{<r:shop:cart:item:link>title</r:shop:cart:item:link>}
|
239
|
-
exp = %{<a href="#{@line_item.item.
|
235
|
+
exp = %{<a href="#{@line_item.item.url}">title</a>}
|
240
236
|
pages(:home).should render(tag).as(exp)
|
241
237
|
end
|
242
238
|
end
|
@@ -2,7 +2,7 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe Shop::Tags::Product do
|
4
4
|
|
5
|
-
dataset :pages, :shop_products, :shop_product_attachments
|
5
|
+
dataset :pages, :shop_config, :shop_products, :shop_product_attachments
|
6
6
|
|
7
7
|
it 'should describe these tags' do
|
8
8
|
Shop::Tags::Product.tags.sort.should == [
|
@@ -21,7 +21,8 @@ describe Shop::Tags::Product do
|
|
21
21
|
'shop:product:images',
|
22
22
|
'shop:product:images:if_images',
|
23
23
|
'shop:product:images:unless_images',
|
24
|
-
'shop:product:images:each'
|
24
|
+
'shop:product:images:each',
|
25
|
+
'shop:product:images:image'].sort
|
25
26
|
end
|
26
27
|
|
27
28
|
before :all do
|
@@ -346,6 +347,30 @@ describe Shop::Tags::Product do
|
|
346
347
|
end
|
347
348
|
end
|
348
349
|
|
350
|
+
describe '<r:shop:product:images:image>' do
|
351
|
+
before :each do
|
352
|
+
mock(Shop::Tags::Helpers).current_product(anything) { @product }
|
353
|
+
end
|
354
|
+
context 'image exists' do
|
355
|
+
it 'should expand' do
|
356
|
+
mock(Shop::Tags::Helpers).current_image(anything) { @product.images.first }
|
357
|
+
|
358
|
+
tag = %{<r:shop:product:images:image>success</r:shop:product:images:image>}
|
359
|
+
exp = %{success}
|
360
|
+
@page.should render(tag).as(exp)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
context 'image does not exist' do
|
364
|
+
it 'should expand' do
|
365
|
+
mock(Shop::Tags::Helpers).current_image(anything) { nil }
|
366
|
+
|
367
|
+
tag = %{<r:shop:product:images:image>success</r:shop:product:images:image>}
|
368
|
+
exp = %{success}
|
369
|
+
@page.should render(tag).as(exp)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
349
374
|
end
|
350
375
|
|
351
376
|
end
|
@@ -21,7 +21,7 @@ describe FormAddress do
|
|
21
21
|
@data[:billing] = { :id => shop_orders(:several_items).billing.id }
|
22
22
|
@data[:shipping] = { :id => shop_orders(:several_items).shipping.id }
|
23
23
|
|
24
|
-
@address = FormAddress.new(@form, @page)
|
24
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
25
25
|
result = @address.create
|
26
26
|
|
27
27
|
shop_orders(:one_item).billing.should === shop_addresses(:billing)
|
@@ -38,7 +38,7 @@ describe FormAddress do
|
|
38
38
|
@data[:shipping] = {}
|
39
39
|
@form[:extensions][:address] = { :billing => true }
|
40
40
|
|
41
|
-
@address = FormAddress.new(@form, @page)
|
41
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
42
42
|
result = @address.create
|
43
43
|
|
44
44
|
shop_orders(:one_item).billing.should === shop_addresses(:billing)
|
@@ -57,7 +57,7 @@ describe FormAddress do
|
|
57
57
|
end
|
58
58
|
context 'both billing and shipping' do
|
59
59
|
it 'it should not assign those addresses' do
|
60
|
-
@address = FormAddress.new(@form, @page)
|
60
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
61
61
|
result = @address.create
|
62
62
|
|
63
63
|
shop_orders(:one_item).billing.should be_nil
|
@@ -72,11 +72,12 @@ describe FormAddress do
|
|
72
72
|
context 'sending ids as a bad customer' do
|
73
73
|
before :each do
|
74
74
|
login_as :bad_customer
|
75
|
+
|
75
76
|
@order = shop_orders(:one_item)
|
76
77
|
mock_valid_form_address_request
|
77
78
|
end
|
78
79
|
it 'should not assign those addresses' do
|
79
|
-
@address = FormAddress.new(@form, @page)
|
80
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
80
81
|
result = @address.create
|
81
82
|
|
82
83
|
shop_orders(:one_item).billing.should be_nil
|
@@ -97,7 +98,7 @@ describe FormAddress do
|
|
97
98
|
@data[:billing] = { :name => 'new billing' }
|
98
99
|
@data[:shipping] = { :name => 'new shipping' }
|
99
100
|
|
100
|
-
@address = FormAddress.new(@form, @page)
|
101
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
101
102
|
result = @address.create
|
102
103
|
|
103
104
|
shop_addresses(:billing).name.should === 'new billing'
|
@@ -120,7 +121,7 @@ describe FormAddress do
|
|
120
121
|
|
121
122
|
context 'both billing and shipping sent' do
|
122
123
|
it 'should create new addresses' do
|
123
|
-
@address = FormAddress.new(@form, @page)
|
124
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
124
125
|
result = @address.create
|
125
126
|
|
126
127
|
shop_orders(:one_item).billing.name.should === @data[:billing][:name]
|
@@ -135,7 +136,7 @@ describe FormAddress do
|
|
135
136
|
it 'should copy billing to shipping' do
|
136
137
|
@data[:shipping] = {}
|
137
138
|
|
138
|
-
@address = FormAddress.new(@form, @page)
|
139
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
139
140
|
result = @address.create
|
140
141
|
|
141
142
|
shop_orders(:one_item).billing.name.should === @data[:billing][:name]
|
@@ -150,7 +151,7 @@ describe FormAddress do
|
|
150
151
|
it 'should copy billing to shipping' do
|
151
152
|
@data[:shipping] = @data[:billing]
|
152
153
|
|
153
|
-
@address = FormAddress.new(@form, @page)
|
154
|
+
@address = FormAddress.new(@form, @page, @form[:extensions][:addresses])
|
154
155
|
result = @address.create
|
155
156
|
|
156
157
|
shop_orders(:one_item).shipping.should === shop_orders(:one_item).billing
|