radiant-shop-extension 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +75 -0
- data/HISTORY.md +77 -0
- data/MIT-LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +141 -0
- data/VERSION +1 -0
- data/app/.DS_Store +0 -0
- data/app/controllers/admin/shop/categories_controller.rb +206 -0
- data/app/controllers/admin/shop/customers_controller.rb +137 -0
- data/app/controllers/admin/shop/orders_controller.rb +171 -0
- data/app/controllers/admin/shop/products/images_controller.rb +144 -0
- data/app/controllers/admin/shop/products_controller.rb +217 -0
- data/app/controllers/admin/shops_controller.rb +9 -0
- data/app/controllers/shop/categories_controller.rb +49 -0
- data/app/controllers/shop/line_items_controller.rb +165 -0
- data/app/controllers/shop/orders_controller.rb +16 -0
- data/app/controllers/shop/products_controller.rb +48 -0
- data/app/models/form_checkout.rb +245 -0
- data/app/models/shop_address.rb +13 -0
- data/app/models/shop_addressable.rb +11 -0
- data/app/models/shop_category.rb +85 -0
- data/app/models/shop_category_page.rb +7 -0
- data/app/models/shop_customer.rb +27 -0
- data/app/models/shop_line_item.rb +32 -0
- data/app/models/shop_order.rb +108 -0
- data/app/models/shop_payment.rb +6 -0
- data/app/models/shop_payment_method.rb +5 -0
- data/app/models/shop_product.rb +87 -0
- data/app/models/shop_product_attachment.rb +30 -0
- data/app/models/shop_product_page.rb +7 -0
- data/app/views/.DS_Store +0 -0
- data/app/views/admin/.DS_Store +0 -0
- data/app/views/admin/pages/_shop_category.html.haml +4 -0
- data/app/views/admin/pages/_shop_product.html.haml +4 -0
- data/app/views/admin/shop/categories/edit.html.haml +12 -0
- data/app/views/admin/shop/categories/edit/_fields.html.haml +28 -0
- data/app/views/admin/shop/categories/edit/_head.html.haml +2 -0
- data/app/views/admin/shop/categories/edit/_meta.html.haml +7 -0
- data/app/views/admin/shop/categories/edit/_part.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/_popup.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +5 -0
- data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +10 -0
- data/app/views/admin/shop/categories/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/categories/index/_category.html.haml +16 -0
- data/app/views/admin/shop/categories/new.html.haml +10 -0
- data/app/views/admin/shop/categories/remove.html.haml +12 -0
- data/app/views/admin/shop/customers/index.html.haml +36 -0
- data/app/views/admin/shop/orders/index.html.haml +33 -0
- data/app/views/admin/shop/products/edit.html.haml +14 -0
- data/app/views/admin/shop/products/edit/_fields.html.haml +38 -0
- data/app/views/admin/shop/products/edit/_head.html.haml +2 -0
- data/app/views/admin/shop/products/edit/_image.html.haml +12 -0
- data/app/views/admin/shop/products/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/products/edit/_part.html.haml +3 -0
- data/app/views/admin/shop/products/edit/_popup.html.haml +3 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -0
- data/app/views/admin/shop/products/edit/meta/_category.html.haml +5 -0
- data/app/views/admin/shop/products/edit/meta/_sku.html.haml +5 -0
- data/app/views/admin/shop/products/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/products/edit/parts/_images.html.haml +5 -0
- data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +18 -0
- data/app/views/admin/shop/products/index.html.haml +10 -0
- data/app/views/admin/shop/products/index/_bottom.html.haml +5 -0
- data/app/views/admin/shop/products/index/_product.html.haml +13 -0
- data/app/views/admin/shop/products/new.html.haml +10 -0
- data/app/views/admin/shop/products/remove.html.haml +12 -0
- data/app/views/shop/categories/show.html.haml +1 -0
- data/app/views/shop/orders/show.html.haml +1 -0
- data/app/views/shop/products/index.html.haml +1 -0
- data/app/views/shop/products/show.html.haml +1 -0
- data/config/locales/en.yml +50 -0
- data/config/routes.rb +38 -0
- data/config/shop_cart.yml +16 -0
- data/cucumber.yml +1 -0
- data/db/migrate/20100311053701_initial.rb +153 -0
- data/db/migrate/20100520033059_create_layouts.rb +119 -0
- data/db/migrate/20100903122123_create_forms.rb +44 -0
- data/db/migrate/20100908063639_create_snippets.rb +22 -0
- data/features/support/env.rb +16 -0
- data/features/support/paths.rb +14 -0
- data/lib/shop/controllers/application_controller.rb +39 -0
- data/lib/shop/controllers/site_controller.rb +12 -0
- data/lib/shop/interface/products.rb +49 -0
- data/lib/shop/models/image.rb +14 -0
- data/lib/shop/models/page.rb +14 -0
- data/lib/shop/tags/address.rb +40 -0
- data/lib/shop/tags/cart.rb +49 -0
- data/lib/shop/tags/category.rb +83 -0
- data/lib/shop/tags/core.rb +12 -0
- data/lib/shop/tags/helpers.rb +142 -0
- data/lib/shop/tags/item.rb +109 -0
- data/lib/shop/tags/product.rb +109 -0
- data/lib/shop/tags/responses.rb +34 -0
- data/lib/tasks/shop_extension_tasks.rake +54 -0
- data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
- data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
- data/public/images/admin/extensions/shop/products/sort.png +0 -0
- data/public/javascripts/admin/extensions/shop/products/edit.js +115 -0
- data/public/javascripts/admin/extensions/shop/products/index.js +65 -0
- data/public/stylesheets/sass/admin/extensions/shop/edit.sass +86 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +158 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +129 -0
- data/radiant-shop-extension.gemspec +245 -0
- data/shop_extension.rb +62 -0
- data/spec/controllers/admin/shop/categories_controller_spec.rb +443 -0
- data/spec/controllers/admin/shop/products/images_controller_spec.rb +477 -0
- data/spec/controllers/admin/shop/products_controller_spec.rb +394 -0
- data/spec/controllers/admin/shops_controller_spec.rb +19 -0
- data/spec/controllers/shop/categories_controller_spec.rb +42 -0
- data/spec/controllers/shop/line_items_controller_spec.rb +256 -0
- data/spec/controllers/shop/orders_controller_specs.rb +37 -0
- data/spec/controllers/shop/products_controller_spec.rb +51 -0
- data/spec/datasets/forms.rb +153 -0
- data/spec/datasets/images.rb +13 -0
- data/spec/datasets/shop_addresses.rb +27 -0
- data/spec/datasets/shop_categories.rb +13 -0
- data/spec/datasets/shop_line_items.rb +9 -0
- data/spec/datasets/shop_orders.rb +21 -0
- data/spec/datasets/shop_products.rb +34 -0
- data/spec/helpers/nested_tag_helper.rb +33 -0
- data/spec/lib/shop/models/image_spec.rb +28 -0
- data/spec/lib/shop/models/page_spec.rb +38 -0
- data/spec/lib/shop/tags/address_spec.rb +196 -0
- data/spec/lib/shop/tags/cart_spec.rb +169 -0
- data/spec/lib/shop/tags/category_spec.rb +201 -0
- data/spec/lib/shop/tags/core_spec.rb +16 -0
- data/spec/lib/shop/tags/helpers_spec.rb +381 -0
- data/spec/lib/shop/tags/item_spec.rb +313 -0
- data/spec/lib/shop/tags/product_spec.rb +334 -0
- data/spec/matchers/comparison.rb +72 -0
- data/spec/matchers/render_matcher.rb +33 -0
- data/spec/models/form_checkout_spec.rb +376 -0
- data/spec/models/shop_category_page_spec.rb +10 -0
- data/spec/models/shop_category_spec.rb +58 -0
- data/spec/models/shop_line_item_spec.rb +42 -0
- data/spec/models/shop_order_spec.rb +228 -0
- data/spec/models/shop_product_attachment_spec.rb +72 -0
- data/spec/models/shop_product_page_spec.rb +10 -0
- data/spec/models/shop_product_spec.rb +135 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +22 -0
- data/vendor/plugins/acts_as_list/README +23 -0
- data/vendor/plugins/acts_as_list/init.rb +3 -0
- data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
- data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
- data/vendor/plugins/json_fields/.gitignore +3 -0
- data/vendor/plugins/json_fields/MIT-LICENSE +20 -0
- data/vendor/plugins/json_fields/README.rdoc +65 -0
- data/vendor/plugins/json_fields/Rakefile +55 -0
- data/vendor/plugins/json_fields/init.rb +2 -0
- data/vendor/plugins/json_fields/lib/json_fields.rb +99 -0
- data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +124 -0
- data/vendor/plugins/json_fields/spec/spec.opts +6 -0
- data/vendor/plugins/json_fields/spec/spec_helper.rb +29 -0
- data/vendor/plugins/json_fields/spec/test_models.rb +12 -0
- metadata +324 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
#products_map
|
2
|
+
border:
|
3
|
+
top: 21px #9e9e9e solid
|
4
|
+
|
5
|
+
.category
|
6
|
+
position: relative
|
7
|
+
width: 100%
|
8
|
+
min:
|
9
|
+
height: 30px
|
10
|
+
line:
|
11
|
+
height: 30px
|
12
|
+
|
13
|
+
.attributes
|
14
|
+
padding:
|
15
|
+
left: 5px
|
16
|
+
border:
|
17
|
+
bottom: 1px solid #cecece
|
18
|
+
background:
|
19
|
+
color: #F1EBE2
|
20
|
+
|
21
|
+
&:hover
|
22
|
+
background:
|
23
|
+
color: #e0f0ff
|
24
|
+
|
25
|
+
.handle
|
26
|
+
float: left
|
27
|
+
display: block
|
28
|
+
width: 24px
|
29
|
+
height: 24px
|
30
|
+
margin:
|
31
|
+
top: 3px
|
32
|
+
right: 5px
|
33
|
+
background:
|
34
|
+
position: 50% 50%
|
35
|
+
repeat: no-repeat
|
36
|
+
cursor: move
|
37
|
+
|
38
|
+
&:hover
|
39
|
+
|
40
|
+
.handle
|
41
|
+
background:
|
42
|
+
image: url(/images/admin/extensions/shop/products/sort.png)
|
43
|
+
|
44
|
+
.name, .name a
|
45
|
+
color: black
|
46
|
+
font:
|
47
|
+
weight: bold
|
48
|
+
size: 16px
|
49
|
+
text:
|
50
|
+
decoration: none
|
51
|
+
|
52
|
+
&:hover
|
53
|
+
color: #0066ce
|
54
|
+
text:
|
55
|
+
decoration: underline
|
56
|
+
|
57
|
+
.sku
|
58
|
+
font:
|
59
|
+
style: italic
|
60
|
+
size: 0.9em
|
61
|
+
color: #000000
|
62
|
+
|
63
|
+
.modify
|
64
|
+
float: right
|
65
|
+
width: 200px
|
66
|
+
text:
|
67
|
+
align: right
|
68
|
+
font:
|
69
|
+
size: 10px
|
70
|
+
|
71
|
+
span
|
72
|
+
padding:
|
73
|
+
left: 15px
|
74
|
+
right: 15px
|
75
|
+
|
76
|
+
a
|
77
|
+
color: black
|
78
|
+
text:
|
79
|
+
decoration: none
|
80
|
+
|
81
|
+
.add_child
|
82
|
+
background:
|
83
|
+
image: url(/images/admin/plus.png)
|
84
|
+
repeat: no-repeat
|
85
|
+
position: 0 50%
|
86
|
+
|
87
|
+
.remove
|
88
|
+
background:
|
89
|
+
image: url(/images/admin/minus.png)
|
90
|
+
repeat: no-repeat
|
91
|
+
position: 0 50%
|
92
|
+
|
93
|
+
.products
|
94
|
+
position: relative
|
95
|
+
min:
|
96
|
+
height: 1px
|
97
|
+
|
98
|
+
.product
|
99
|
+
position: relative
|
100
|
+
height: 45px
|
101
|
+
line:
|
102
|
+
height: 45px
|
103
|
+
margin:
|
104
|
+
bottom: 2px
|
105
|
+
|
106
|
+
.attributes
|
107
|
+
padding:
|
108
|
+
left: 35px
|
109
|
+
background:
|
110
|
+
color: #ffffff
|
111
|
+
|
112
|
+
.handle
|
113
|
+
margin:
|
114
|
+
top: 10px
|
115
|
+
|
116
|
+
.title
|
117
|
+
padding:
|
118
|
+
left: 10px
|
119
|
+
|
120
|
+
a
|
121
|
+
font:
|
122
|
+
size: 15px
|
123
|
+
weight: normal
|
124
|
+
|
125
|
+
.icon
|
126
|
+
float: left
|
127
|
+
margin: 5px
|
128
|
+
left: 0
|
129
|
+
height: 35px
|
@@ -0,0 +1,245 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{radiant-shop-extension}
|
8
|
+
s.version = "0.9.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dirk Kelly", "John Barker"]
|
12
|
+
s.date = %q{2010-09-23}
|
13
|
+
s.description = %q{Shop adds an easy to use api for creating products sold in a shop}
|
14
|
+
s.email = %q{dk@dirkkelly.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"HISTORY.md",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"app/.DS_Store",
|
28
|
+
"app/controllers/admin/shop/categories_controller.rb",
|
29
|
+
"app/controllers/admin/shop/customers_controller.rb",
|
30
|
+
"app/controllers/admin/shop/orders_controller.rb",
|
31
|
+
"app/controllers/admin/shop/products/images_controller.rb",
|
32
|
+
"app/controllers/admin/shop/products_controller.rb",
|
33
|
+
"app/controllers/admin/shops_controller.rb",
|
34
|
+
"app/controllers/shop/categories_controller.rb",
|
35
|
+
"app/controllers/shop/line_items_controller.rb",
|
36
|
+
"app/controllers/shop/orders_controller.rb",
|
37
|
+
"app/controllers/shop/products_controller.rb",
|
38
|
+
"app/models/form_checkout.rb",
|
39
|
+
"app/models/shop_address.rb",
|
40
|
+
"app/models/shop_addressable.rb",
|
41
|
+
"app/models/shop_category.rb",
|
42
|
+
"app/models/shop_category_page.rb",
|
43
|
+
"app/models/shop_customer.rb",
|
44
|
+
"app/models/shop_line_item.rb",
|
45
|
+
"app/models/shop_order.rb",
|
46
|
+
"app/models/shop_payment.rb",
|
47
|
+
"app/models/shop_payment_method.rb",
|
48
|
+
"app/models/shop_product.rb",
|
49
|
+
"app/models/shop_product_attachment.rb",
|
50
|
+
"app/models/shop_product_page.rb",
|
51
|
+
"app/views/.DS_Store",
|
52
|
+
"app/views/admin/.DS_Store",
|
53
|
+
"app/views/admin/pages/_shop_category.html.haml",
|
54
|
+
"app/views/admin/pages/_shop_product.html.haml",
|
55
|
+
"app/views/admin/shop/categories/edit.html.haml",
|
56
|
+
"app/views/admin/shop/categories/edit/_fields.html.haml",
|
57
|
+
"app/views/admin/shop/categories/edit/_head.html.haml",
|
58
|
+
"app/views/admin/shop/categories/edit/_meta.html.haml",
|
59
|
+
"app/views/admin/shop/categories/edit/_part.html.haml",
|
60
|
+
"app/views/admin/shop/categories/edit/_popup.html.haml",
|
61
|
+
"app/views/admin/shop/categories/edit/meta/_handle.html.haml",
|
62
|
+
"app/views/admin/shop/categories/edit/meta/_layouts.html.haml",
|
63
|
+
"app/views/admin/shop/categories/edit/parts/_description.html.haml",
|
64
|
+
"app/views/admin/shop/categories/index/_category.html.haml",
|
65
|
+
"app/views/admin/shop/categories/new.html.haml",
|
66
|
+
"app/views/admin/shop/categories/remove.html.haml",
|
67
|
+
"app/views/admin/shop/customers/index.html.haml",
|
68
|
+
"app/views/admin/shop/orders/index.html.haml",
|
69
|
+
"app/views/admin/shop/products/edit.html.haml",
|
70
|
+
"app/views/admin/shop/products/edit/_fields.html.haml",
|
71
|
+
"app/views/admin/shop/products/edit/_head.html.haml",
|
72
|
+
"app/views/admin/shop/products/edit/_image.html.haml",
|
73
|
+
"app/views/admin/shop/products/edit/_meta.html.haml",
|
74
|
+
"app/views/admin/shop/products/edit/_part.html.haml",
|
75
|
+
"app/views/admin/shop/products/edit/_popup.html.haml",
|
76
|
+
"app/views/admin/shop/products/edit/buttons/_browse_images.html.haml",
|
77
|
+
"app/views/admin/shop/products/edit/buttons/_new_image.html.haml",
|
78
|
+
"app/views/admin/shop/products/edit/meta/_category.html.haml",
|
79
|
+
"app/views/admin/shop/products/edit/meta/_sku.html.haml",
|
80
|
+
"app/views/admin/shop/products/edit/parts/_description.html.haml",
|
81
|
+
"app/views/admin/shop/products/edit/parts/_images.html.haml",
|
82
|
+
"app/views/admin/shop/products/edit/popups/_browse_images.html.haml",
|
83
|
+
"app/views/admin/shop/products/edit/popups/_new_image.html.haml",
|
84
|
+
"app/views/admin/shop/products/index.html.haml",
|
85
|
+
"app/views/admin/shop/products/index/_bottom.html.haml",
|
86
|
+
"app/views/admin/shop/products/index/_product.html.haml",
|
87
|
+
"app/views/admin/shop/products/new.html.haml",
|
88
|
+
"app/views/admin/shop/products/remove.html.haml",
|
89
|
+
"app/views/shop/categories/show.html.haml",
|
90
|
+
"app/views/shop/orders/show.html.haml",
|
91
|
+
"app/views/shop/products/index.html.haml",
|
92
|
+
"app/views/shop/products/show.html.haml",
|
93
|
+
"config/locales/en.yml",
|
94
|
+
"config/routes.rb",
|
95
|
+
"config/shop_cart.yml",
|
96
|
+
"cucumber.yml",
|
97
|
+
"db/migrate/20100311053701_initial.rb",
|
98
|
+
"db/migrate/20100520033059_create_layouts.rb",
|
99
|
+
"db/migrate/20100903122123_create_forms.rb",
|
100
|
+
"db/migrate/20100908063639_create_snippets.rb",
|
101
|
+
"features/support/env.rb",
|
102
|
+
"features/support/paths.rb",
|
103
|
+
"lib/shop/controllers/application_controller.rb",
|
104
|
+
"lib/shop/controllers/site_controller.rb",
|
105
|
+
"lib/shop/interface/products.rb",
|
106
|
+
"lib/shop/models/image.rb",
|
107
|
+
"lib/shop/models/page.rb",
|
108
|
+
"lib/shop/tags/address.rb",
|
109
|
+
"lib/shop/tags/cart.rb",
|
110
|
+
"lib/shop/tags/category.rb",
|
111
|
+
"lib/shop/tags/core.rb",
|
112
|
+
"lib/shop/tags/helpers.rb",
|
113
|
+
"lib/shop/tags/item.rb",
|
114
|
+
"lib/shop/tags/product.rb",
|
115
|
+
"lib/shop/tags/responses.rb",
|
116
|
+
"lib/tasks/shop_extension_tasks.rake",
|
117
|
+
"mockups/balsamiq/products-retro_fun_tshirt-more.bmml",
|
118
|
+
"mockups/balsamiq/products-retro_fun_tshirt.bmml",
|
119
|
+
"public/images/admin/extensions/shop/products/sort.png",
|
120
|
+
"public/javascripts/admin/extensions/shop/products/edit.js",
|
121
|
+
"public/javascripts/admin/extensions/shop/products/index.js",
|
122
|
+
"public/stylesheets/sass/admin/extensions/shop/edit.sass",
|
123
|
+
"public/stylesheets/sass/admin/extensions/shop/products/edit.sass",
|
124
|
+
"public/stylesheets/sass/admin/extensions/shop/products/index.sass",
|
125
|
+
"radiant-shop-extension.gemspec",
|
126
|
+
"shop_extension.rb",
|
127
|
+
"spec/controllers/admin/shop/categories_controller_spec.rb",
|
128
|
+
"spec/controllers/admin/shop/products/images_controller_spec.rb",
|
129
|
+
"spec/controllers/admin/shop/products_controller_spec.rb",
|
130
|
+
"spec/controllers/admin/shops_controller_spec.rb",
|
131
|
+
"spec/controllers/shop/categories_controller_spec.rb",
|
132
|
+
"spec/controllers/shop/line_items_controller_spec.rb",
|
133
|
+
"spec/controllers/shop/orders_controller_specs.rb",
|
134
|
+
"spec/controllers/shop/products_controller_spec.rb",
|
135
|
+
"spec/datasets/forms.rb",
|
136
|
+
"spec/datasets/images.rb",
|
137
|
+
"spec/datasets/shop_addresses.rb",
|
138
|
+
"spec/datasets/shop_categories.rb",
|
139
|
+
"spec/datasets/shop_line_items.rb",
|
140
|
+
"spec/datasets/shop_orders.rb",
|
141
|
+
"spec/datasets/shop_products.rb",
|
142
|
+
"spec/helpers/nested_tag_helper.rb",
|
143
|
+
"spec/lib/shop/models/image_spec.rb",
|
144
|
+
"spec/lib/shop/models/page_spec.rb",
|
145
|
+
"spec/lib/shop/tags/address_spec.rb",
|
146
|
+
"spec/lib/shop/tags/cart_spec.rb",
|
147
|
+
"spec/lib/shop/tags/category_spec.rb",
|
148
|
+
"spec/lib/shop/tags/core_spec.rb",
|
149
|
+
"spec/lib/shop/tags/helpers_spec.rb",
|
150
|
+
"spec/lib/shop/tags/item_spec.rb",
|
151
|
+
"spec/lib/shop/tags/product_spec.rb",
|
152
|
+
"spec/matchers/comparison.rb",
|
153
|
+
"spec/matchers/render_matcher.rb",
|
154
|
+
"spec/models/form_checkout_spec.rb",
|
155
|
+
"spec/models/shop_category_page_spec.rb",
|
156
|
+
"spec/models/shop_category_spec.rb",
|
157
|
+
"spec/models/shop_line_item_spec.rb",
|
158
|
+
"spec/models/shop_order_spec.rb",
|
159
|
+
"spec/models/shop_product_attachment_spec.rb",
|
160
|
+
"spec/models/shop_product_page_spec.rb",
|
161
|
+
"spec/models/shop_product_spec.rb",
|
162
|
+
"spec/spec.opts",
|
163
|
+
"spec/spec_helper.rb",
|
164
|
+
"vendor/plugins/acts_as_list/README",
|
165
|
+
"vendor/plugins/acts_as_list/init.rb",
|
166
|
+
"vendor/plugins/acts_as_list/lib/active_record/acts/list.rb",
|
167
|
+
"vendor/plugins/acts_as_list/test/list_test.rb",
|
168
|
+
"vendor/plugins/json_fields/.gitignore",
|
169
|
+
"vendor/plugins/json_fields/MIT-LICENSE",
|
170
|
+
"vendor/plugins/json_fields/README.rdoc",
|
171
|
+
"vendor/plugins/json_fields/Rakefile",
|
172
|
+
"vendor/plugins/json_fields/init.rb",
|
173
|
+
"vendor/plugins/json_fields/lib/json_fields.rb",
|
174
|
+
"vendor/plugins/json_fields/spec/lib/json_fields_spec.rb",
|
175
|
+
"vendor/plugins/json_fields/spec/spec.opts",
|
176
|
+
"vendor/plugins/json_fields/spec/spec_helper.rb",
|
177
|
+
"vendor/plugins/json_fields/spec/test_models.rb"
|
178
|
+
]
|
179
|
+
s.homepage = %q{http://github.com/squaretalent/radiant-shop-extension}
|
180
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
181
|
+
s.require_paths = ["lib"]
|
182
|
+
s.rubygems_version = %q{1.3.7}
|
183
|
+
s.summary = %q{Shop Extension for Radiant CMS}
|
184
|
+
s.test_files = [
|
185
|
+
"spec/controllers/admin/shop/categories_controller_spec.rb",
|
186
|
+
"spec/controllers/admin/shop/products/images_controller_spec.rb",
|
187
|
+
"spec/controllers/admin/shop/products_controller_spec.rb",
|
188
|
+
"spec/controllers/admin/shops_controller_spec.rb",
|
189
|
+
"spec/controllers/shop/categories_controller_spec.rb",
|
190
|
+
"spec/controllers/shop/line_items_controller_spec.rb",
|
191
|
+
"spec/controllers/shop/orders_controller_specs.rb",
|
192
|
+
"spec/controllers/shop/products_controller_spec.rb",
|
193
|
+
"spec/datasets/forms.rb",
|
194
|
+
"spec/datasets/images.rb",
|
195
|
+
"spec/datasets/shop_addresses.rb",
|
196
|
+
"spec/datasets/shop_categories.rb",
|
197
|
+
"spec/datasets/shop_line_items.rb",
|
198
|
+
"spec/datasets/shop_orders.rb",
|
199
|
+
"spec/datasets/shop_products.rb",
|
200
|
+
"spec/helpers/nested_tag_helper.rb",
|
201
|
+
"spec/lib/shop/models/image_spec.rb",
|
202
|
+
"spec/lib/shop/models/page_spec.rb",
|
203
|
+
"spec/lib/shop/tags/address_spec.rb",
|
204
|
+
"spec/lib/shop/tags/cart_spec.rb",
|
205
|
+
"spec/lib/shop/tags/category_spec.rb",
|
206
|
+
"spec/lib/shop/tags/core_spec.rb",
|
207
|
+
"spec/lib/shop/tags/helpers_spec.rb",
|
208
|
+
"spec/lib/shop/tags/item_spec.rb",
|
209
|
+
"spec/lib/shop/tags/product_spec.rb",
|
210
|
+
"spec/matchers/comparison.rb",
|
211
|
+
"spec/matchers/render_matcher.rb",
|
212
|
+
"spec/models/form_checkout_spec.rb",
|
213
|
+
"spec/models/shop_category_page_spec.rb",
|
214
|
+
"spec/models/shop_category_spec.rb",
|
215
|
+
"spec/models/shop_line_item_spec.rb",
|
216
|
+
"spec/models/shop_order_spec.rb",
|
217
|
+
"spec/models/shop_product_attachment_spec.rb",
|
218
|
+
"spec/models/shop_product_page_spec.rb",
|
219
|
+
"spec/models/shop_product_spec.rb",
|
220
|
+
"spec/spec_helper.rb"
|
221
|
+
]
|
222
|
+
|
223
|
+
if s.respond_to? :specification_version then
|
224
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
225
|
+
s.specification_version = 3
|
226
|
+
|
227
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
228
|
+
s.add_runtime_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
|
229
|
+
s.add_runtime_dependency(%q<radiant-images-extension>, [">= 0.1.1"])
|
230
|
+
s.add_runtime_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
|
231
|
+
s.add_runtime_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
|
232
|
+
else
|
233
|
+
s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
|
234
|
+
s.add_dependency(%q<radiant-images-extension>, [">= 0.1.1"])
|
235
|
+
s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
|
236
|
+
s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
|
237
|
+
end
|
238
|
+
else
|
239
|
+
s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.0"])
|
240
|
+
s.add_dependency(%q<radiant-images-extension>, [">= 0.1.1"])
|
241
|
+
s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
|
242
|
+
s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
data/shop_extension.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
class ShopExtension < Radiant::Extension
|
2
|
+
version "0.9"
|
3
|
+
description "Core extension for the Radiant shop"
|
4
|
+
url "http://github.com/squaretalent/radiant-shop-extension"
|
5
|
+
|
6
|
+
extension_config do |config|
|
7
|
+
config.gem 'activemerchant', :version => '1.7.3', :lib => 'active_merchant'
|
8
|
+
config.gem 'will_paginate', :version => '2.3.14'
|
9
|
+
config.gem 'radiant-layouts-extension', :version => '0.9.1', :lib => false
|
10
|
+
end
|
11
|
+
|
12
|
+
UserActionObserver.instance.send :add_observer!, ShopProduct
|
13
|
+
UserActionObserver.instance.send :add_observer!, ShopCategory
|
14
|
+
UserActionObserver.instance.send :add_observer!, ShopOrder
|
15
|
+
|
16
|
+
def activate
|
17
|
+
|
18
|
+
# View Hooks
|
19
|
+
unless defined? admin.products
|
20
|
+
Radiant::AdminUI.send :include, Shop::Interface::Products
|
21
|
+
|
22
|
+
admin.products = Radiant::AdminUI.load_default_shop_products_regions
|
23
|
+
admin.categories = Radiant::AdminUI.load_default_shop_categories_regions
|
24
|
+
end
|
25
|
+
|
26
|
+
if admin.respond_to? :page
|
27
|
+
admin.page.edit.add :layout_row, 'shop_category'
|
28
|
+
admin.page.edit.add :layout_row, 'shop_product'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Tags
|
32
|
+
Page.send :include, Shop::Tags::Core, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Product, Shop::Tags::Address, Shop::Tags::Responses
|
33
|
+
|
34
|
+
# Model Includes
|
35
|
+
Page.send :include, Shop::Models::Page
|
36
|
+
Image.send :include, Shop::Models::Image
|
37
|
+
|
38
|
+
# Controller Includes
|
39
|
+
ApplicationController.send :include, Shop::Controllers::ApplicationController
|
40
|
+
SiteController.send :include, Shop::Controllers::SiteController
|
41
|
+
|
42
|
+
# Tabs3
|
43
|
+
tab "Shop" do
|
44
|
+
add_item "Products", "/admin/shop"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Ensure there is always a shop prefix, otherwise we'll lose admin and pages
|
48
|
+
Radiant::Config['shop.url_prefix'] = Radiant::Config['shop.url_prefix'].blank? ? 'shop' : Radiant::Config['shop.url_prefix']
|
49
|
+
Radiant::Config['shop.product_layout'] ||= 'Product'
|
50
|
+
Radiant::Config['shop.category_layout'] ||= 'Products'
|
51
|
+
Radiant::Config['shop.order_layout'] ||= 'Cart'
|
52
|
+
|
53
|
+
Radiant::Config['shop.cart_thanks_path']||= 'cart/thanks'
|
54
|
+
Radiant::Config['shop.cart_path'] ||= 'cart'
|
55
|
+
|
56
|
+
Radiant::Config['shop.price_unit'] ||= '$'
|
57
|
+
Radiant::Config['shop.price_precision'] ||= 2
|
58
|
+
Radiant::Config['shop.price_seperator'] ||= '.'
|
59
|
+
Radiant::Config['shop.price_delimiter'] ||= ','
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,443 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe Admin::Shop::CategoriesController do
|
4
|
+
|
5
|
+
dataset :users
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
login_as :admin
|
9
|
+
|
10
|
+
@shop_category = ShopCategory.new
|
11
|
+
@shop_categories = [ @shop_category ]
|
12
|
+
|
13
|
+
@shop_product = ShopProduct.new
|
14
|
+
@shop_products = [ @shop_product ]
|
15
|
+
|
16
|
+
stub(@shop_category).id { 1 }
|
17
|
+
stub(@shop_category).products { @shop_products }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#index' do
|
21
|
+
before :each do
|
22
|
+
mock(ShopCategory).find(:all) { @shop_categories } # Resource Controller
|
23
|
+
mock(ShopCategory).search('search') { @shop_categories }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'html' do
|
27
|
+
before :each do
|
28
|
+
get :index, :search => 'search'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not assign an error or notice and redirect to shop_products path' do
|
32
|
+
response.should redirect_to(admin_shop_products_path)
|
33
|
+
flash.now[:error].should be_nil
|
34
|
+
flash.now[:notice].should be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should assign the shop_product_images instance variable' do
|
38
|
+
assigns(:shop_categories).should === @shop_categories
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'js' do
|
43
|
+
before :each do
|
44
|
+
get :index, :search => 'search', :format => 'js'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should render the collection partial and success status' do
|
48
|
+
response.should be_success
|
49
|
+
response.should render_template('/admin/shop/categories/index/_category')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should assign the shop_categories instance variable' do
|
53
|
+
assigns(:shop_categories).should === @shop_categories
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'json' do
|
58
|
+
before :each do
|
59
|
+
get :index, :search => 'search', :format => 'json'
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should return a json object of the array and success status' do
|
63
|
+
response.should be_success
|
64
|
+
response.body.should === @shop_categories.to_json(ShopCategory.params)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should assign the shop_product_images instance variable' do
|
68
|
+
assigns(:shop_categories).should === @shop_categories
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#products' do
|
75
|
+
before :each do
|
76
|
+
mock(ShopCategory).find('1') { @shop_category }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'html' do
|
80
|
+
before :each do
|
81
|
+
get :products, :id => @shop_category.id
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should render successfully' do
|
85
|
+
response.should render_template( '/admin/shop/products/index' )
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should assign the shop_products instance variable' do
|
89
|
+
assigns(:shop_products).should === @shop_products
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'js' do
|
94
|
+
before :each do
|
95
|
+
get :products, :id => @shop_category.id, :format => 'js'
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should render the collection template' do
|
99
|
+
response.should be_success
|
100
|
+
response.should render_template( '/admin/shop/products/index/_product' )
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should assign the shop_products instance variable' do
|
104
|
+
assigns(:shop_products).should === @shop_products
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'json' do
|
109
|
+
before :each do
|
110
|
+
get :products, :id => @shop_category.id, :format => 'json'
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should assign the shop_products and render the collection template' do
|
114
|
+
response.should be_success
|
115
|
+
response.body.should === @shop_products.to_json(ShopProduct.params)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should assign the shop_products instance variable' do
|
119
|
+
assigns(:shop_products).should === @shop_products
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#sort' do
|
126
|
+
before :each do
|
127
|
+
@categories = [
|
128
|
+
'shop_categories[]=2',
|
129
|
+
'shop_categories[]=1'
|
130
|
+
].join('&')
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'categories are not passed' do
|
134
|
+
context 'html' do
|
135
|
+
it 'should assign an error and redirect to admin_shop_products_path path' do
|
136
|
+
put :sort
|
137
|
+
flash.now[:error].should_not be_nil
|
138
|
+
response.should redirect_to(admin_shop_products_path)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'js' do
|
143
|
+
it 'should return an error string and failure status' do
|
144
|
+
put :sort, :format => 'js'
|
145
|
+
response.should_not be_success
|
146
|
+
response.body.should === 'Could not sort Categories.'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'json' do
|
151
|
+
it 'should return a json error object and failure status' do
|
152
|
+
put :sort, :format => 'json'
|
153
|
+
response.should_not be_success
|
154
|
+
JSON.parse(response.body)['error'].should === 'Could not sort Categories.'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'categories are passed' do
|
160
|
+
context 'could not sort' do
|
161
|
+
before :each do
|
162
|
+
mock(ShopCategory).find('2').stub!.update_attributes!({:position => 1}) { raise ActiveRecord::RecordNotSaved }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'html' do
|
166
|
+
it 'should assign an error and redirect to admin_shop_products_path path' do
|
167
|
+
put :sort, :categories => @categories
|
168
|
+
flash.now[:error].should === 'Could not sort Categories.'
|
169
|
+
response.should redirect_to(admin_shop_products_path)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'js' do
|
174
|
+
it 'should return an error string and failure status' do
|
175
|
+
put :sort, :categories => @categories, :format => 'js'
|
176
|
+
response.should_not be_success
|
177
|
+
response.body.should === 'Could not sort Categories.'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'json' do
|
182
|
+
it 'should return a json error object and failure status' do
|
183
|
+
put :sort, :categories => @categories, :format => 'json'
|
184
|
+
response.should_not be_success
|
185
|
+
JSON.parse(response.body)['error'].should === 'Could not sort Categories.'
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'successfully sorted' do
|
191
|
+
before :each do
|
192
|
+
mock(ShopCategory).find('2').stub!.update_attributes!({:position => 1}) { true }
|
193
|
+
mock(ShopCategory).find('1').stub!.update_attributes!({:position => 2}) { true }
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'html' do
|
197
|
+
it 'should assign a notice and redirect to admin_shop_products_path path' do
|
198
|
+
put :sort, :categories => @categories
|
199
|
+
flash.now[:notice].should === 'Categories successfully sorted.'
|
200
|
+
response.should redirect_to(admin_shop_products_path)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'js' do
|
205
|
+
it 'should return success string and success status' do
|
206
|
+
put :sort, :categories => @categories, :format => 'js'
|
207
|
+
response.should be_success
|
208
|
+
response.body.should === 'Categories successfully sorted.'
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'json' do
|
213
|
+
it 'should return a json success object and success status' do
|
214
|
+
put :sort, :categories => @categories, :format => 'json'
|
215
|
+
response.should be_success
|
216
|
+
JSON.parse(response.body)['notice'].should === 'Categories successfully sorted.'
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe '#create' do
|
224
|
+
before :each do
|
225
|
+
mock(ShopCategory).new { @shop_category }
|
226
|
+
end
|
227
|
+
context 'category could not be created' do
|
228
|
+
before :each do
|
229
|
+
mock(@shop_category).save! { raise ActiveRecord::RecordNotSaved }
|
230
|
+
end
|
231
|
+
|
232
|
+
context 'html' do
|
233
|
+
it 'should assign a flash error and render new' do
|
234
|
+
post :create, :shop_category => {}
|
235
|
+
|
236
|
+
response.should render_template(:new)
|
237
|
+
flash.now[:error].should === 'Could not create Category.'
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context 'js' do
|
242
|
+
it 'should return error notice and failure status' do
|
243
|
+
post :create, :shop_category => {}, :format => 'js'
|
244
|
+
|
245
|
+
response.body.should === 'Could not create Category.'
|
246
|
+
response.should_not be_success
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'json' do
|
251
|
+
it 'should return an error json object and failure status' do
|
252
|
+
post :create, :shop_category => {}, :format => 'json'
|
253
|
+
|
254
|
+
JSON.parse(response.body)['error'].should === 'Could not create Category.'
|
255
|
+
response.should_not be_success
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context 'category successfully created' do
|
261
|
+
before :each do
|
262
|
+
mock(@shop_category).save! { @shop_category }
|
263
|
+
end
|
264
|
+
|
265
|
+
context 'html' do
|
266
|
+
context 'not continue' do
|
267
|
+
it 'should assign a notice and redirect to edit_shop_product path' do
|
268
|
+
post :create, :shop_category => {}
|
269
|
+
flash.now[:notice].should === 'Category created successfully.'
|
270
|
+
response.should redirect_to(admin_shop_categories_path)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
context 'continue' do
|
274
|
+
it 'should assign a notice and redirect to edit_shop_product path' do
|
275
|
+
post :create, :shop_category => {}, :continue => true
|
276
|
+
flash.now[:notice].should === 'Category created successfully.'
|
277
|
+
response.should redirect_to(edit_admin_shop_category_path(@shop_category))
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'js' do
|
283
|
+
it 'should render the collection partial and success status' do
|
284
|
+
post :create, :shop_category => {}, :format => 'js'
|
285
|
+
response.should be_success
|
286
|
+
assigns(:shop_category).should === @shop_category
|
287
|
+
response.should render_template('/admin/shop/categories/index/_category')
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context 'json' do
|
292
|
+
it 'should render the json object and redirect to json show' do
|
293
|
+
post :create ,:shop_category => {}, :format => 'json'
|
294
|
+
response.should be_success
|
295
|
+
response.body.should === @shop_category.to_json(ShopCategory.params)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
describe '#update' do
|
302
|
+
before :each do
|
303
|
+
mock(ShopCategory).find('1') { @shop_category }
|
304
|
+
end
|
305
|
+
|
306
|
+
context 'could not update' do
|
307
|
+
before :each do
|
308
|
+
stub(@shop_category).update_attributes!({}) { raise ActiveRecord::RecordNotSaved }
|
309
|
+
end
|
310
|
+
|
311
|
+
context 'html' do
|
312
|
+
it 'should assign a flash error and render edit' do
|
313
|
+
put :update, :id => @shop_category.id, :shop_category => {}
|
314
|
+
response.should render_template(:edit)
|
315
|
+
flash.now[:error].should === 'Could not update Category.'
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
context 'js' do
|
320
|
+
it 'should render the error and failure status' do
|
321
|
+
put :update, :id => @shop_category.id, :shop_category => {}, :format => 'js'
|
322
|
+
response.should_not be_success
|
323
|
+
response.body.should === 'Could not update Category.'
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
context 'json' do
|
328
|
+
it 'should assign an error json object and failure status' do
|
329
|
+
put :update, :id => @shop_category.id, :shop_category => {}, :format => 'json'
|
330
|
+
response.should_not be_success
|
331
|
+
JSON.parse(response.body)['error'].should === 'Could not update Category.'
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
context 'successfully updated' do
|
337
|
+
before :each do
|
338
|
+
stub(@shop_category).update_attributes!({}) { true }
|
339
|
+
end
|
340
|
+
|
341
|
+
context 'html' do
|
342
|
+
context 'not continue' do
|
343
|
+
it 'should assign a notice and redirect to edit_shop_product path' do
|
344
|
+
put :update, :id => @shop_category.id, :shop_category => {}
|
345
|
+
flash.now[:notice].should === 'Category updated successfully.'
|
346
|
+
response.should redirect_to(admin_shop_categories_path)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
context 'continue' do
|
350
|
+
it 'should assign a notice and redirect to edit_shop_product path' do
|
351
|
+
put :update, :id => @shop_category.id, :shop_category => {}, :continue => true
|
352
|
+
flash.now[:notice].should === 'Category updated successfully.'
|
353
|
+
response.should redirect_to(edit_admin_shop_category_path(@shop_category))
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
context 'js' do
|
359
|
+
it 'should render the partial and success status' do
|
360
|
+
put :update, :id => @shop_category.id, :shop_category => {}, :format => 'js'
|
361
|
+
response.should be_success
|
362
|
+
response.should render_template('/admin/shop/categories/index/_category')
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
context 'json' do
|
367
|
+
it 'should assign the json object and success status' do
|
368
|
+
put :update, :id => @shop_category.id, :shop_category => {}, :format => 'json'
|
369
|
+
response.should be_success
|
370
|
+
response.body.should === @shop_category.to_json(ShopCategory.params)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
describe '#destroy' do
|
377
|
+
before :each do
|
378
|
+
mock(ShopCategory).find('1') { @shop_category }
|
379
|
+
end
|
380
|
+
|
381
|
+
context 'product not destroyed' do
|
382
|
+
before :each do
|
383
|
+
stub(@shop_category).destroy { raise ActiveRecord::RecordNotFound }
|
384
|
+
end
|
385
|
+
|
386
|
+
context 'html' do
|
387
|
+
it 'should assign a flash error and render remove' do
|
388
|
+
delete :destroy, :id => 1
|
389
|
+
flash.now[:error].should === 'Could not delete Category.'
|
390
|
+
response.should render_template(:remove)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
context 'js' do
|
395
|
+
it 'should render an error and failure status' do
|
396
|
+
delete :destroy, :id => 1, :format => 'js'
|
397
|
+
response.body.should === 'Could not delete Category.'
|
398
|
+
response.should_not be_success
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
context 'json' do
|
403
|
+
it 'should render an error and failure status' do
|
404
|
+
delete :destroy, :id => 1, :format => 'json'
|
405
|
+
JSON.parse(response.body)['error'].should === 'Could not delete Category.'
|
406
|
+
response.should_not be_success
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
|
412
|
+
context 'product successfully destroyed' do
|
413
|
+
before :each do
|
414
|
+
stub(@shop_category).destroy { true }
|
415
|
+
end
|
416
|
+
|
417
|
+
context 'html' do
|
418
|
+
it 'should assign a flash notice and redirect to shop_categories path' do
|
419
|
+
delete :destroy, :id => 1
|
420
|
+
flash.now[:notice].should === 'Category deleted successfully.'
|
421
|
+
response.should redirect_to(admin_shop_categories_path)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
context 'js' do
|
426
|
+
it 'should render success message and success status' do
|
427
|
+
delete :destroy, :id => 1, :format => 'js'
|
428
|
+
response.body.should === 'Category deleted successfully.'
|
429
|
+
response.should be_success
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
context 'json' do
|
434
|
+
it 'should return a success json object and success status' do
|
435
|
+
delete :destroy, :id => 1, :format => 'json'
|
436
|
+
JSON.parse(response.body)['notice'].should === 'Category deleted successfully.'
|
437
|
+
response.should be_success
|
438
|
+
end
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
end
|