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.
Files changed (227) hide show
  1. data/HISTORY.md +21 -3
  2. data/LICENSE +42 -0
  3. data/README.md +62 -25
  4. data/Rakefile +4 -5
  5. data/VERSION +1 -1
  6. data/app/controllers/admin/shop/categories_controller.rb +1 -0
  7. data/app/controllers/admin/shop/orders_controller.rb +1 -1
  8. data/app/controllers/admin/shop/products_controller.rb +18 -7
  9. data/app/helpers/shop_helper.rb +8 -0
  10. data/app/models/form_address.rb +5 -5
  11. data/app/models/form_checkout.rb +25 -17
  12. data/app/models/form_line_item.rb +1 -1
  13. data/app/models/shop_category.rb +22 -7
  14. data/app/models/shop_customer.rb +1 -1
  15. data/app/models/shop_line_item.rb +26 -26
  16. data/app/models/shop_order.rb +0 -2
  17. data/app/models/shop_product.rb +15 -18
  18. data/app/views/.DS_Store +0 -0
  19. data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
  20. data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
  21. data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
  22. data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
  23. data/app/views/admin/shop/products/index/_product.html.haml +1 -1
  24. data/config/locales/en.yml +8 -7
  25. data/config/routes.rb +4 -16
  26. data/db/migrate/20101011063133_setup_shop.rb +94 -0
  27. data/db/seeds/forms.rb +113 -154
  28. data/db/seeds/layouts.rb +67 -103
  29. data/db/seeds/pages.rb +101 -0
  30. data/db/seeds/products.rb +29 -0
  31. data/db/seeds/snippets.rb +36 -21
  32. data/lib/shop/controllers/application_controller.rb +5 -3
  33. data/lib/shop/models/form_extension.rb +1 -2
  34. data/lib/shop/models/page.rb +0 -1
  35. data/lib/shop/models/user.rb +0 -1
  36. data/lib/shop/tags/card.rb +8 -2
  37. data/lib/shop/tags/cart.rb +5 -1
  38. data/lib/shop/tags/helpers.rb +35 -60
  39. data/lib/shop/tags/item.rb +2 -16
  40. data/lib/shop/tags/product.rb +7 -0
  41. data/lib/tasks/shop_extension_tasks.rake +9 -4
  42. data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
  43. data/radiant-shop-extension.gemspec +25 -201
  44. data/shop_extension.rb +18 -19
  45. data/spec/datasets/forms.rb +25 -28
  46. data/spec/datasets/shop_categories.rb +2 -2
  47. data/spec/datasets/shop_config.rb +24 -0
  48. data/spec/datasets/shop_customers.rb +1 -0
  49. data/spec/datasets/shop_line_items.rb +21 -3
  50. data/spec/datasets/shop_products.rb +4 -1
  51. data/spec/datasets/tags.rb +19 -0
  52. data/spec/lib/shop/models/page_spec.rb +1 -1
  53. data/spec/lib/shop/tags/card_spec.rb +30 -4
  54. data/spec/lib/shop/tags/cart_spec.rb +29 -12
  55. data/spec/lib/shop/tags/helpers_spec.rb +45 -66
  56. data/spec/lib/shop/tags/item_spec.rb +6 -10
  57. data/spec/lib/shop/tags/product_spec.rb +27 -2
  58. data/spec/models/form_address_spec.rb +9 -8
  59. data/spec/models/form_checkout_spec.rb +28 -22
  60. data/spec/models/shop_category_spec.rb +2 -10
  61. data/spec/models/shop_line_item_spec.rb +71 -34
  62. data/spec/models/shop_order_spec.rb +5 -5
  63. data/spec/models/shop_product_attachment_spec.rb +1 -0
  64. data/spec/models/shop_product_spec.rb +4 -47
  65. data/spec/spec.opts +3 -5
  66. metadata +60 -248
  67. data/Gemfile +0 -26
  68. data/Gemfile.lock +0 -75
  69. data/MIT-LICENSE +0 -20
  70. data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
  71. data/app/controllers/admin/shop/discounts_controller.rb +0 -64
  72. data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
  73. data/app/controllers/admin/shop/packages_controller.rb +0 -63
  74. data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
  75. data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
  76. data/app/controllers/admin/shop/variants_controller.rb +0 -48
  77. data/app/models/form_discount.rb +0 -39
  78. data/app/models/shop_discount.rb +0 -37
  79. data/app/models/shop_discountable.rb +0 -64
  80. data/app/models/shop_group.rb +0 -15
  81. data/app/models/shop_grouping.rb +0 -6
  82. data/app/models/shop_package.rb +0 -74
  83. data/app/models/shop_packing.rb +0 -22
  84. data/app/models/shop_product_variant.rb +0 -34
  85. data/app/models/shop_variant.rb +0 -23
  86. data/app/views/admin/pages/_shop_category.html.haml +0 -4
  87. data/app/views/admin/pages/_shop_product.html.haml +0 -4
  88. data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
  89. data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
  90. data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
  91. data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
  92. data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
  93. data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
  94. data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
  95. data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
  96. data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
  97. data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
  98. data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
  99. data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
  100. data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
  101. data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
  102. data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
  103. data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
  104. data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
  105. data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
  106. data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
  107. data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
  108. data/app/views/admin/shop/discounts/edit.html.haml +0 -11
  109. data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
  110. data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
  111. data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
  112. data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
  113. data/app/views/admin/shop/discounts/index.html.haml +0 -13
  114. data/app/views/admin/shop/discounts/new.html.haml +0 -11
  115. data/app/views/admin/shop/discounts/remove.html.haml +0 -12
  116. data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
  117. data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
  118. data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
  119. data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
  120. data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
  121. data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
  122. data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
  123. data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
  124. data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
  125. data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
  126. data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
  127. data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
  128. data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
  129. data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
  130. data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
  131. data/app/views/admin/shop/packages/edit.html.haml +0 -11
  132. data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
  133. data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
  134. data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
  135. data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
  136. data/app/views/admin/shop/packages/index.html.haml +0 -13
  137. data/app/views/admin/shop/packages/new.html.haml +0 -11
  138. data/app/views/admin/shop/packages/remove.html.haml +0 -12
  139. data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
  140. data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
  141. data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
  142. data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
  143. data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
  144. data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
  145. data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
  146. data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
  147. data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
  148. data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
  149. data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
  150. data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
  151. data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
  152. data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
  153. data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
  154. data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
  155. data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
  156. data/app/views/admin/shop/variants/edit.html.haml +0 -11
  157. data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
  158. data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
  159. data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
  160. data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
  161. data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
  162. data/app/views/admin/shop/variants/index.html.haml +0 -13
  163. data/app/views/admin/shop/variants/new.html.haml +0 -11
  164. data/app/views/admin/shop/variants/remove.html.haml +0 -12
  165. data/app/views/shop/categories/show.html.haml +0 -1
  166. data/app/views/shop/orders/show.html.haml +0 -1
  167. data/app/views/shop/products/index.html.haml +0 -1
  168. data/app/views/shop/products/show.html.haml +0 -1
  169. data/cucumber.yml +0 -1
  170. data/db/migrate/20100311053701_initial.rb +0 -153
  171. data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
  172. data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
  173. data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
  174. data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
  175. data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
  176. data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
  177. data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
  178. data/db/migrate/20100929081200_create_variants.rb +0 -20
  179. data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
  180. data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
  181. data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
  182. data/db/migrate/20100930235221_create_packages.rb +0 -31
  183. data/db/migrate/20101005231713_create_page_ids.rb +0 -11
  184. data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
  185. data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
  186. data/db/migrate/20101010071143_create_discounts.rb +0 -29
  187. data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
  188. data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
  189. data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
  190. data/features/support/env.rb +0 -16
  191. data/features/support/paths.rb +0 -14
  192. data/lib/shop/interface/packages.rb +0 -34
  193. data/lib/shop/interface/variants.rb +0 -34
  194. data/lib/shop/tags/package.rb +0 -95
  195. data/lib/shop/tags/product_variant.rb +0 -52
  196. data/lib/shop/tags/responses.rb +0 -34
  197. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  198. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  199. data/mockups/discounts/new-edit.bmml +0 -492
  200. data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
  201. data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
  202. data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
  203. data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
  204. data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
  205. data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
  206. data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
  207. data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
  208. data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
  209. data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
  210. data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
  211. data/spec/datasets/shop_discountables.rb +0 -22
  212. data/spec/datasets/shop_discounts.rb +0 -29
  213. data/spec/datasets/shop_groups.rb +0 -15
  214. data/spec/datasets/shop_packages.rb +0 -25
  215. data/spec/datasets/shop_product_variants.rb +0 -22
  216. data/spec/datasets/shop_variants.rb +0 -17
  217. data/spec/lib/shop/tags/package_spec.rb +0 -342
  218. data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
  219. data/spec/lib/shop/tags/responses_spec.rb +0 -129
  220. data/spec/models/form_discount_spec.rb +0 -63
  221. data/spec/models/shop_discount_spec.rb +0 -130
  222. data/spec/models/shop_discountable_spec.rb +0 -114
  223. data/spec/models/shop_group_spec.rb +0 -38
  224. data/spec/models/shop_package_spec.rb +0 -117
  225. data/spec/models/shop_packing_spec.rb +0 -67
  226. data/spec/models/shop_product_variant_spec.rb +0 -92
  227. data/spec/models/shop_variant_spec.rb +0 -32
@@ -1,188 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Admin::Shop::Packages::PackingsController do
4
-
5
- dataset :users
6
-
7
- before(:each) do
8
- login_as :admin
9
-
10
- @shop_package = ShopPackage.new
11
- @shop_packages = [ @shop_package ]
12
-
13
- @shop_product = ShopProduct.new
14
- @shop_products = [ @shop_product ]
15
-
16
- @shop_packing = ShopPacking.new
17
- @shop_packings = [ @shop_packing ]
18
-
19
- stub(@shop_package).id { 1 }
20
- stub(@shop_package).packings { @shop_packings }
21
- end
22
-
23
- describe '#sort' do
24
- before :each do
25
- @packings = [
26
- 'package_products[]=2',
27
- 'package_products[]=1'
28
- ].join('&')
29
- end
30
-
31
- context 'packings are not passed' do
32
- context 'js' do
33
- it 'should return an error string and failure status' do
34
- put :sort, :package_id => 1, :format => 'js'
35
-
36
- response.should_not be_success
37
- response.body.should === "Could not sort products."
38
- end
39
- end
40
- end
41
-
42
- context 'categories are passed' do
43
- context 'could not sort' do
44
- before :each do
45
- mock(ShopPacking).find('2').stub!.update_attributes!({:position,1}) { raise ActiveRecord::RecordNotSaved }
46
- end
47
-
48
- context 'js' do
49
- it 'should return an error string and failure status' do
50
- put :sort, :package_id => 1, :packings => @packings, :format => 'js'
51
-
52
- response.should_not be_success
53
- response.body.should === 'Could not sort products.'
54
- end
55
- end
56
- end
57
-
58
- context 'successfully sorted' do
59
- before :each do
60
- mock(ShopPacking).find('2').stub!.update_attributes!({:position,1}) { true }
61
- mock(ShopPacking).find('1').stub!.update_attributes!({:position,2}) { true }
62
- end
63
-
64
- context 'js' do
65
- it 'should return success string and success status' do
66
- put :sort, :package_id => 1, :packings => @packings, :format => 'js'
67
-
68
- response.should be_success
69
- response.body.should === 'Products successfully sorted.'
70
- end
71
- end
72
- end
73
- end
74
- end
75
-
76
- describe '#create' do
77
- before :each do
78
- mock(ShopPackage).find('1') { @shop_package }
79
- mock(ShopProduct).find('1') { @shop_product }
80
- mock(ShopPacking).new { @shop_packing }
81
- end
82
- context 'packing could not be created' do
83
- before :each do
84
- mock(@shop_packing).save! { raise ActiveRecord::RecordNotSaved }
85
- end
86
-
87
- context 'js' do
88
- it 'should return error notice and failure status' do
89
- post :create, :package_id => 1, :product_id => 1, :format => 'js'
90
-
91
- response.body.should === 'Could not attach product.'
92
- response.should_not be_success
93
- end
94
- end
95
- end
96
-
97
- context 'packing successfully created' do
98
- before :each do
99
- mock(@shop_packing).save! { true }
100
- end
101
-
102
- context 'js' do
103
- it 'should render the collection partial and success status' do
104
- post :create, :package_id => 1, :product_id => 1, :format => 'js'
105
-
106
- response.should be_success
107
- assigns(:shop_packing).should === @shop_packing
108
- response.should render_template('admin/shop/packages/edit/shared/_product')
109
- end
110
- end
111
- end
112
- end
113
-
114
- describe '#update' do
115
- before :each do
116
- mock(ShopPacking).find('1') { @shop_packing }
117
- end
118
- context 'packing could not be created' do
119
- before :each do
120
- mock(@shop_packing).update_attributes!({ :quantity => '1' }) { raise ActiveRecord::RecordNotSaved }
121
- end
122
-
123
- context 'js' do
124
- it 'should return error notice and failure status' do
125
- put :update, :package_id => 1, :id => 1, :quantity => 1, :format => 'js'
126
-
127
- response.should_not be_success
128
- response.body.should === 'Could not update Product Quantity.'
129
- end
130
- end
131
- end
132
-
133
- context 'packing successfully created' do
134
- before :each do
135
- mock(@shop_packing).update_attributes!({ :quantity => '1' }) { true }
136
- end
137
-
138
- context 'js' do
139
- it 'should render the collection partial and success status' do
140
- put :update, :package_id => 1, :id => 1, :quantity => 1, :format => 'js'
141
-
142
- response.should be_success
143
- response.body.should === 'Product Quantity successfully updated.'
144
-
145
- end
146
- end
147
- end
148
- end
149
-
150
- describe '#destroy' do
151
- before :each do
152
- mock(ShopPacking).find('1') { @shop_packing }
153
- stub(@shop_packing).product { nil }
154
- stub(@shop_packing).package { nil }
155
- end
156
-
157
- context 'product not destroyed' do
158
- before :each do
159
- stub(@shop_packing).destroy { raise ActiveRecord::RecordNotFound }
160
- end
161
-
162
- context 'js' do
163
- it 'should render an error and failure status' do
164
- delete :destroy, :package_id => 1, :id => 1, :format => 'js'
165
-
166
- response.should_not be_success
167
- response.body.should === 'Could not remove product.'
168
- end
169
- end
170
- end
171
-
172
- context 'product successfully destroyed' do
173
- before :each do
174
- stub(@shop_packing).destroy { true }
175
- end
176
-
177
- context 'js' do
178
- it 'should render success message and success status' do
179
- delete :destroy, :package_id => 1, :id => 1, :format => 'js'
180
-
181
- response.should be_success
182
- response.should render_template('admin/shop/packages/edit/shared/_product')
183
- end
184
- end
185
- end
186
- end
187
-
188
- end
@@ -1,32 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Admin::Shop::PackagesController do
4
-
5
- dataset :users, :shop_packages
6
-
7
- before(:each) do
8
- login_as :admin
9
- @package = shop_packages(:all_bread)
10
- end
11
-
12
- describe '#new' do
13
- it 'should assign global instance variables' do
14
- get :new
15
-
16
- assigns(:meta).should === ['sku']
17
- assigns(:buttons).should === []
18
- assigns(:parts).should === ['description']
19
- end
20
- end
21
-
22
- describe '#edit' do
23
- it 'should assign global instance variables' do
24
- get :edit, :id => @package.id
25
-
26
- assigns(:meta).should === ['sku']
27
- assigns(:buttons).should === ['browse_products']
28
- assigns(:parts).should === ['description','products']
29
- end
30
- end
31
-
32
- end
@@ -1,53 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Admin::Shop::Products::VariantTemplatesController do
4
-
5
- dataset :users, :shop_variants, :shop_product_variants
6
-
7
- before :each do
8
- login_as :admin
9
- end
10
-
11
- describe '#create' do
12
- before :each do
13
- @product = shop_products(:crusty_bread)
14
- @variant = shop_variants(:milk_states)
15
- @initial_product_variants = @product.variants.all
16
- end
17
- context 'successfully created' do
18
- before :each do
19
- stub(ShopProduct).find.with_any_args { @product }
20
- put :update, :product_id => @product.id, :id => @variant.id
21
- end
22
- it 'should add the variant templates to product' do
23
- final_variants = @product.variants.all
24
- final_variants.should_not == @initial_product_variants
25
-
26
- names = final_variants.map(&:name)
27
- @variant.options.each do |name|
28
- names.include?(name).should be_true
29
- end
30
- end
31
- it 'should redirect to edit product path' do
32
- response.should redirect_to(edit_admin_shop_product_path(@product))
33
- end
34
- end
35
- context 'could not create' do
36
- before :each do
37
- stub(ShopProduct).find.with_any_args { @product }
38
- mock(@product).apply_variant_template(@variant) { false }
39
- put :update, :product_id => @product.id, :id => @variant.id
40
- end
41
- it 'should not add the variant templates to product' do
42
- @product.variants.all.should == @initial_product_variants
43
- end
44
- it 'should assign flash error' do
45
- flash.now[:error].should_not be_nil
46
- end
47
- it 'should redirect to edit product path' do
48
- response.should redirect_to(edit_admin_shop_product_path(@product))
49
- end
50
- end
51
- end
52
-
53
- end
@@ -1,116 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Admin::Shop::Products::VariantsController do
4
-
5
- dataset :users, :shop_variants, :shop_product_variants
6
-
7
- before :each do
8
- login_as :admin
9
- end
10
-
11
- describe '#create' do
12
- before :all do
13
- @product = shop_products(:crusty_bread)
14
- end
15
- context 'successfully created' do
16
- before :each do
17
- mock.instance_of(ShopProductVariant).save! { true }
18
- end
19
- context 'html' do
20
- before :each do
21
- post :create, :product_id => @product.id, :shop_product_variant => { }
22
- end
23
- it 'should redirect to product path' do
24
- response.should redirect_to(edit_admin_shop_product_path(@product))
25
- end
26
- end
27
- context 'js' do
28
- before :each do
29
- post :create, :product_id => @product.id, :shop_product_variant => { }, :format => 'js'
30
- end
31
- it 'should render the partial' do
32
- response.should render_template('/admin/shop/products/edit/shared/_variant')
33
- end
34
- end
35
- end
36
- context 'could not be created' do
37
- before :each do
38
- mock.instance_of(ShopProductVariant).save! { raise ActiveRecord::RecordNotSaved }
39
- end
40
- context 'html' do
41
- before :each do
42
- post :create, :product_id => @product.id, :shop_product_variant => { }
43
- end
44
- it 'should assign flash error' do
45
- flash.now[:error].should_not be_nil
46
- end
47
- it 'should redirect to product path' do
48
- response.should redirect_to(edit_admin_shop_product_path(@product))
49
- end
50
- end
51
- context 'js' do
52
- before :each do
53
- post :create, :product_id => @product.id, :shop_product_variant => { }, :format => 'js'
54
- end
55
- it 'should not be success' do
56
- response.should_not be_success
57
- end
58
- end
59
- end
60
- end
61
-
62
- describe '#destroy' do
63
- before :each do
64
- @product = shop_products(:crusty_bread)
65
- @product_variant = shop_product_variants(:mouldy_crusty_bread)
66
- end
67
- describe 'successfully destroyed' do
68
- before :each do
69
- mock(ShopProductVariant).find(@product_variant.id.to_s) { @product_variant }
70
- stub(@product_variant).destroy { true }
71
- end
72
- context 'html' do
73
- before :each do
74
- delete :destroy, :product_id => @product.id, :id => @product_variant.id
75
- end
76
- it 'should redirect to product path' do
77
- response.should redirect_to(edit_admin_shop_product_path(@product_variant.product))
78
- end
79
- end
80
- context 'js' do
81
- before :each do
82
- delete :destroy, :product_id => @product.id, :id => @product_variant.id, :format => 'js'
83
- end
84
- it 'should render the partial' do
85
- response.should be_success
86
- end
87
- end
88
- end
89
- describe 'could not be destroyed' do
90
- before :each do
91
- mock(ShopProductVariant).find(@product_variant.id.to_s) { @product_variant }
92
- stub(@product_variant).destroy { false }
93
- end
94
- context 'html' do
95
- before :each do
96
- delete :destroy, :product_id => @product.id, :id => @product_variant.id
97
- end
98
- it 'should assign flash error' do
99
- flash.now[:error].should_not be_nil
100
- end
101
- it 'should redirect to product path' do
102
- response.should redirect_to(edit_admin_shop_product_path(@product_variant.product))
103
- end
104
- end
105
- context 'js' do
106
- before :each do
107
- delete :destroy, :product_id => @product.id, :id => @product_variant.id, :format => 'js'
108
- end
109
- it 'should not be success' do
110
- response.should_not be_success
111
- end
112
- end
113
- end
114
- end
115
-
116
- end
@@ -1,67 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Admin::Shop::VariantsController do
4
-
5
- dataset :users, :shop_variants
6
-
7
- before(:each) do
8
- login_as :admin
9
- end
10
-
11
- describe '#new' do
12
- context 'instance variables' do
13
- it 'should be assigned' do
14
- get :new
15
-
16
- assigns(:inputs).should === ['name','options']
17
- assigns(:meta).should === []
18
- assigns(:buttons).should === []
19
- assigns(:parts).should === []
20
- assigns(:popups).should === []
21
- end
22
- end
23
- end
24
-
25
- describe '#edit' do
26
- context 'instance variables' do
27
- it 'should be assigned' do
28
- get :edit, :id => shop_variants(:bread_states).id
29
-
30
- assigns(:inputs).should === ['name','options']
31
- assigns(:meta).should === []
32
- assigns(:buttons).should === []
33
- assigns(:parts).should === []
34
- assigns(:popups).should === []
35
- end
36
- end
37
- end
38
-
39
- describe '#create' do
40
- context 'instance variables' do
41
- it 'should be assigned' do
42
- post :create, :shop_variant => {}
43
-
44
- assigns(:inputs).should === ['name','options']
45
- assigns(:meta).should === []
46
- assigns(:buttons).should === []
47
- assigns(:parts).should === []
48
- assigns(:popups).should === []
49
- end
50
- end
51
- end
52
-
53
- describe '#update' do
54
- context 'instance variables' do
55
- it 'should be assigned' do
56
- put :update, :id => shop_variants(:bread_states).id, :shop_variant => {}
57
-
58
- assigns(:inputs).should === ['name','options']
59
- assigns(:meta).should === []
60
- assigns(:buttons).should === []
61
- assigns(:parts).should === []
62
- assigns(:popups).should === []
63
- end
64
- end
65
- end
66
-
67
- end
@@ -1,22 +0,0 @@
1
- class ShopDiscountablesDataset < Dataset::Base
2
-
3
- uses :shop_discounts, :shop_categories, :shop_products
4
-
5
- def load
6
- create_record :shop_discountables, :ten_percent_bread,
7
- :discount_id => shop_discounts(:ten_percent).id,
8
- :discounted_id => shop_categories(:bread).id,
9
- :discounted_type => 'ShopCategory'
10
-
11
- create_record :shop_discountables, :five_percent_bread,
12
- :discount_id => shop_discounts(:five_percent).id,
13
- :discounted_id => shop_categories(:bread).id,
14
- :discounted_type => 'ShopCategory'
15
-
16
- create_record :shop_discountables, :five_percent_crusty_bread,
17
- :discount_id => shop_discounts(:five_percent).id,
18
- :discounted_id => shop_products(:crusty_bread).id,
19
- :discounted_type => 'ShopProduct'
20
- end
21
-
22
- end
@@ -1,29 +0,0 @@
1
- class ShopDiscountsDataset < Dataset::Base
2
-
3
- def load
4
- create_record :shop_discounts, :ten_percent,
5
- :name => 'ten percent',
6
- :code => '10pcoff',
7
- :amount => 10.00
8
-
9
- create_record :shop_discounts, :five_percent,
10
- :name => 'five percent',
11
- :code => '5pcoff',
12
- :amount => 10.00
13
-
14
- create_record :shop_discounts, :one_percent,
15
- :name => 'one percent',
16
- :code => '1pcoff',
17
- :amount => 1.00,
18
- :starts_at => nil,
19
- :finishes_at => nil
20
-
21
- create_record :shop_discounts, :invalid,
22
- :name => 'invalid',
23
- :code => 'invalid',
24
- :amount => 100,
25
- :starts_at => Time.now - 5.days,
26
- :finishes_at => Time.now - 2.days
27
- end
28
-
29
- end
@@ -1,15 +0,0 @@
1
- class ShopGroupsDataset < Dataset::Base
2
-
3
- uses :shop_products
4
-
5
- def load
6
- create_record :shop_groups, :breakfast,
7
- :name => 'breakfast'
8
-
9
- shop_groups(:breakfast).products = [
10
- shop_products(:crusty_bread),
11
- shop_products(:choc_milk)
12
- ]
13
- end
14
-
15
- end
@@ -1,25 +0,0 @@
1
- class ShopPackagesDataset < Dataset::Base
2
-
3
- uses :shop_products
4
-
5
- def load
6
- packages = {
7
- :bread => [ :soft, :crusty, :warm ]
8
- }
9
-
10
- packages.each do |package, products|
11
- create_record :shop_package, "all_#{package.to_s}".to_sym,
12
- :name => "all #{package.to_s}",
13
- :sku => "all_#{package.to_s}",
14
- :price => 1 * 10
15
- products.each_with_index do |product, i|
16
- create_record :shop_packing, "#{product.to_s}_bread".to_s.to_sym,
17
- :quantity => 1,
18
- :position => 1,
19
- :package => shop_packages("all_#{package.to_s}".to_sym),
20
- :product => shop_products("#{product.to_s}_bread".to_sym)
21
- end
22
- end
23
- end
24
-
25
- end
@@ -1,22 +0,0 @@
1
- class ShopProductVariantsDataset < Dataset::Base
2
-
3
- uses :shop_products
4
-
5
- def load
6
- create_record :shop_product_variants, :mouldy_crusty_bread,
7
- :name => 'mouldy',
8
- :price => -2.50,
9
- :product => shop_products(:crusty_bread)
10
-
11
- create_record :shop_product_variants, :fresh_crusty_bread,
12
- :name => 'fresh',
13
- :price => 2.50,
14
- :product => shop_products(:crusty_bread)
15
-
16
- create_record :shop_product_variants, :royal_soft_bread,
17
- :name => 'royal',
18
- :price => 2.50,
19
- :product => shop_products(:soft_bread)
20
- end
21
-
22
- end
@@ -1,17 +0,0 @@
1
- class ShopVariantsDataset < Dataset::Base
2
-
3
- def load
4
- create_record :shop_variants, :bread_states,
5
- :name => 'bread states',
6
- :options_json => ActiveSupport::JSON.encode([ 'mouldy', 'fresh' ])
7
-
8
- create_record :shop_variants, :milk_states,
9
- :name => 'milk states',
10
- :options_json => ActiveSupport::JSON.encode([ 'cold', 'warm', 'sour' ])
11
-
12
- create_record :shop_variants, :salad_states,
13
- :name => 'milk states',
14
- :options_json => ActiveSupport::JSON.encode([ 'fresh', 'wilted' ])
15
- end
16
-
17
- end