radiant-shop-extension 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/Rakefile +2 -1
  2. data/VERSION +1 -1
  3. data/app/controllers/admin/shop/discounts/discountables_controller.rb +44 -0
  4. data/app/controllers/admin/shop/discounts_controller.rb +64 -0
  5. data/app/controllers/admin/shop/orders_controller.rb +19 -3
  6. data/app/controllers/admin/shop/packages_controller.rb +1 -3
  7. data/app/controllers/admin/shop/products_controller.rb +1 -2
  8. data/app/controllers/admin/shop/variants_controller.rb +3 -4
  9. data/app/models/form_address.rb +4 -2
  10. data/app/models/form_discount.rb +39 -0
  11. data/app/models/form_line_item.rb +1 -11
  12. data/app/models/shop_category.rb +3 -0
  13. data/app/models/shop_customer.rb +0 -9
  14. data/app/models/shop_discount.rb +37 -0
  15. data/app/models/shop_discountable.rb +64 -0
  16. data/app/models/shop_line_item.rb +24 -1
  17. data/app/models/shop_order.rb +41 -28
  18. data/app/models/shop_product.rb +11 -0
  19. data/app/models/shop_product_variant.rb +3 -0
  20. data/app/models/shop_variant.rb +1 -3
  21. data/app/views/admin/shop/discounts/edit.html.haml +11 -0
  22. data/app/views/admin/shop/discounts/edit/_foot.html.haml +16 -0
  23. data/app/views/admin/shop/discounts/edit/_form.html.haml +15 -0
  24. data/app/views/admin/shop/discounts/edit/_head.html.haml +4 -0
  25. data/app/views/admin/shop/discounts/edit/_inputs.html.haml +2 -0
  26. data/app/views/admin/shop/discounts/edit/_meta.html.haml +8 -0
  27. data/app/views/admin/shop/discounts/edit/_parts.html.haml +9 -0
  28. data/app/views/admin/shop/discounts/edit/_popups.html.haml +4 -0
  29. data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +1 -0
  30. data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +1 -0
  31. data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +3 -0
  32. data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +3 -0
  33. data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +3 -0
  34. data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +5 -0
  35. data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +5 -0
  36. data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +3 -0
  37. data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +3 -0
  38. data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +6 -0
  39. data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +6 -0
  40. data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +11 -0
  41. data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +12 -0
  42. data/app/views/admin/shop/discounts/index.html.haml +13 -0
  43. data/app/views/admin/shop/discounts/index/_discount.html.haml +13 -0
  44. data/app/views/admin/shop/discounts/index/_foot.html.haml +5 -0
  45. data/app/views/admin/shop/discounts/index/_head.html.haml +2 -0
  46. data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +1 -0
  47. data/app/views/admin/shop/discounts/new.html.haml +11 -0
  48. data/app/views/admin/shop/discounts/remove.html.haml +12 -0
  49. data/app/views/admin/shop/orders/index.html.haml +1 -1
  50. data/app/views/admin/shop/orders/index/_foot.html.haml +3 -1
  51. data/app/views/admin/shop/orders/index/_head.html.haml +1 -3
  52. data/app/views/admin/shop/packages/index.html.haml +1 -1
  53. data/app/views/admin/shop/packages/index/_foot.html.haml +3 -2
  54. data/app/views/admin/shop/packages/index/_head.html.haml +1 -3
  55. data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +1 -0
  56. data/app/views/admin/shop/products/index.html.haml +1 -1
  57. data/app/views/admin/shop/products/index/_foot.html.haml +3 -2
  58. data/app/views/admin/shop/products/index/_head.html.haml +1 -3
  59. data/app/views/admin/shop/products/index/buttons/_add_category.html.haml +1 -0
  60. data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -1
  61. data/app/views/admin/shop/variants/index.html.haml +1 -1
  62. data/app/views/admin/shop/variants/index/_foot.html.haml +3 -2
  63. data/app/views/admin/shop/variants/index/_head.html.haml +1 -3
  64. data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +1 -0
  65. data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +1 -0
  66. data/config/routes.rb +11 -5
  67. data/db/migrate/20101010071143_create_discounts.rb +29 -0
  68. data/db/migrate/20101010072225_modify_categories_remove_variant.rb +9 -0
  69. data/db/migrate/20101010130034_change_discountables_add_observer.rb +15 -0
  70. data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +11 -0
  71. data/lib/shop/interface/discounts.rb +34 -0
  72. data/lib/shop/interface/orders.rb +2 -2
  73. data/lib/shop/interface/packages.rb +2 -2
  74. data/lib/shop/interface/products.rb +2 -2
  75. data/lib/shop/interface/variants.rb +2 -2
  76. data/lib/shop/models/form_extension.rb +12 -1
  77. data/lib/shop/models/user.rb +18 -0
  78. data/lib/shop/tags/cart.rb +24 -0
  79. data/lib/shop/tags/helpers.rb +1 -1
  80. data/lib/shop/tags/item.rb +26 -11
  81. data/lib/shop/tags/tax.rb +73 -0
  82. data/lib/tasks/shop_extension_tasks.rake +1 -1
  83. data/mockups/discounts/new-edit.bmml +49 -49
  84. data/public/javascripts/admin/extensions/shop/discounts/edit.js +76 -0
  85. data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +125 -0
  86. data/public/stylesheets/sass/admin/extensions/shop/index.sass +14 -40
  87. data/radiant-shop-extension.gemspec +70 -7
  88. data/shop_extension.rb +23 -12
  89. data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +73 -0
  90. data/spec/controllers/admin/shop/discounts_controller_spec.rb +81 -0
  91. data/spec/controllers/admin/shop/orders_controller_spec.rb +35 -0
  92. data/spec/datasets/forms.rb +23 -12
  93. data/spec/datasets/shop_discountables.rb +22 -0
  94. data/spec/datasets/shop_discounts.rb +29 -0
  95. data/spec/lib/shop/tags/cart_spec.rb +75 -1
  96. data/spec/lib/shop/tags/item_spec.rb +4 -7
  97. data/spec/lib/shop/tags/tax_spec.rb +201 -0
  98. data/spec/models/form_discount_spec.rb +63 -0
  99. data/spec/models/shop_category_spec.rb +8 -0
  100. data/spec/models/shop_discount_spec.rb +130 -0
  101. data/spec/models/shop_discountable_spec.rb +114 -0
  102. data/spec/models/shop_line_item_spec.rb +9 -1
  103. data/spec/models/shop_order_spec.rb +253 -199
  104. data/spec/models/shop_product_spec.rb +31 -2
  105. data/spec/models/shop_variant_spec.rb +0 -15
  106. metadata +97 -21
  107. data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +0 -1
  108. data/app/views/admin/shop/products/index/buttons/_packages.html.haml +0 -1
@@ -8,45 +8,6 @@
8
8
  height: 46px
9
9
  padding-right: 20px
10
10
  background-color: #7E7E7E
11
-
12
- .button
13
- float: right
14
- margin-left: 10px
15
- margin-top: 10px
16
- display: block
17
- height: 16px
18
- padding: 6px 8px
19
- font:
20
- size: 12px
21
- weight: bold
22
- background:
23
- color: #eeeeee
24
- image: url(/images/admin/buttons_background.png)
25
- position: 0 0
26
- repeat: repeat-x
27
- color: #555555
28
- text:
29
- decoration: none
30
- shadow: 1px 1px 1px #eeeeee
31
- cursor: pointer
32
- border:
33
- radius: 5px
34
- -moz:
35
- border:
36
- radius: 5px
37
- -webkit:
38
- border:
39
- radius: 5px
40
-
41
- img
42
- position: relative
43
- top: -2px
44
-
45
- &:hover, &.active
46
- background: #ebebeb
47
- color: #000000
48
- text:
49
- shadow: 1px 1px 1px #FFFFFF
50
11
 
51
12
  .map
52
13
  background-color: #FFFFFF
@@ -112,4 +73,17 @@
112
73
  background:
113
74
  image: url(/images/admin/minus.png)
114
75
  repeat: no-repeat
115
- position: 0 50%
76
+ position: 0 50%
77
+
78
+ #actions
79
+
80
+ ul
81
+
82
+ li
83
+
84
+ a
85
+
86
+ &.active
87
+ -moz-box-shadow: none
88
+ background: url("../../images/admin/shadow.png") repeat-x scroll 0 0 #FFFFFF
89
+ color: #000000
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-shop-extension}
8
- s.version = "0.11.5"
8
+ s.version = "0.11.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dirk Kelly", "John Barker"]
12
- s.date = %q{2010-10-09}
12
+ s.date = %q{2010-10-14}
13
13
  s.description = %q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
14
14
  s.email = %q{dk@dirkkelly.com}
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
27
27
  "app/.DS_Store",
28
28
  "app/controllers/admin/shop/categories_controller.rb",
29
29
  "app/controllers/admin/shop/customers_controller.rb",
30
+ "app/controllers/admin/shop/discounts/discountables_controller.rb",
31
+ "app/controllers/admin/shop/discounts_controller.rb",
30
32
  "app/controllers/admin/shop/orders_controller.rb",
31
33
  "app/controllers/admin/shop/packages/packings_controller.rb",
32
34
  "app/controllers/admin/shop/packages_controller.rb",
@@ -39,11 +41,14 @@ Gem::Specification.new do |s|
39
41
  "app/helpers/shop_helper.rb",
40
42
  "app/models/form_address.rb",
41
43
  "app/models/form_checkout.rb",
44
+ "app/models/form_discount.rb",
42
45
  "app/models/form_line_item.rb",
43
46
  "app/models/shop_address.rb",
44
47
  "app/models/shop_category.rb",
45
48
  "app/models/shop_category_page.rb",
46
49
  "app/models/shop_customer.rb",
50
+ "app/models/shop_discount.rb",
51
+ "app/models/shop_discountable.rb",
47
52
  "app/models/shop_group.rb",
48
53
  "app/models/shop_grouping.rb",
49
54
  "app/models/shop_line_item.rb",
@@ -99,6 +104,34 @@ Gem::Specification.new do |s|
99
104
  "app/views/admin/shop/customers/index/_head.html.haml",
100
105
  "app/views/admin/shop/customers/new.html.haml",
101
106
  "app/views/admin/shop/customers/remove.html.haml",
107
+ "app/views/admin/shop/discounts/edit.html.haml",
108
+ "app/views/admin/shop/discounts/edit/_foot.html.haml",
109
+ "app/views/admin/shop/discounts/edit/_form.html.haml",
110
+ "app/views/admin/shop/discounts/edit/_head.html.haml",
111
+ "app/views/admin/shop/discounts/edit/_inputs.html.haml",
112
+ "app/views/admin/shop/discounts/edit/_meta.html.haml",
113
+ "app/views/admin/shop/discounts/edit/_parts.html.haml",
114
+ "app/views/admin/shop/discounts/edit/_popups.html.haml",
115
+ "app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml",
116
+ "app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml",
117
+ "app/views/admin/shop/discounts/edit/inputs/_amount.html.haml",
118
+ "app/views/admin/shop/discounts/edit/inputs/_code.html.haml",
119
+ "app/views/admin/shop/discounts/edit/inputs/_name.html.haml",
120
+ "app/views/admin/shop/discounts/edit/meta/_finish.html.haml",
121
+ "app/views/admin/shop/discounts/edit/meta/_start.html.haml",
122
+ "app/views/admin/shop/discounts/edit/parts/_categories.html.haml",
123
+ "app/views/admin/shop/discounts/edit/parts/_products.html.haml",
124
+ "app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml",
125
+ "app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml",
126
+ "app/views/admin/shop/discounts/edit/shared/_category.html.haml",
127
+ "app/views/admin/shop/discounts/edit/shared/_product.html.haml",
128
+ "app/views/admin/shop/discounts/index.html.haml",
129
+ "app/views/admin/shop/discounts/index/_discount.html.haml",
130
+ "app/views/admin/shop/discounts/index/_foot.html.haml",
131
+ "app/views/admin/shop/discounts/index/_head.html.haml",
132
+ "app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml",
133
+ "app/views/admin/shop/discounts/new.html.haml",
134
+ "app/views/admin/shop/discounts/remove.html.haml",
102
135
  "app/views/admin/shop/orders/edit.html.haml",
103
136
  "app/views/admin/shop/orders/edit/_foot.html.haml",
104
137
  "app/views/admin/shop/orders/edit/_form.html.haml",
@@ -139,6 +172,7 @@ Gem::Specification.new do |s|
139
172
  "app/views/admin/shop/packages/index/_foot.html.haml",
140
173
  "app/views/admin/shop/packages/index/_head.html.haml",
141
174
  "app/views/admin/shop/packages/index/_package.html.haml",
175
+ "app/views/admin/shop/packages/index/buttons/_new_package.html.haml",
142
176
  "app/views/admin/shop/packages/new.html.haml",
143
177
  "app/views/admin/shop/packages/remove.html.haml",
144
178
  "app/views/admin/shop/products/edit.html.haml",
@@ -173,8 +207,7 @@ Gem::Specification.new do |s|
173
207
  "app/views/admin/shop/products/index/_foot.html.haml",
174
208
  "app/views/admin/shop/products/index/_head.html.haml",
175
209
  "app/views/admin/shop/products/index/_product.html.haml",
176
- "app/views/admin/shop/products/index/buttons/_discounts.html.haml",
177
- "app/views/admin/shop/products/index/buttons/_packages.html.haml",
210
+ "app/views/admin/shop/products/index/buttons/_add_category.html.haml",
178
211
  "app/views/admin/shop/products/index/buttons/_variants.html.haml",
179
212
  "app/views/admin/shop/products/new.html.haml",
180
213
  "app/views/admin/shop/products/remove.html.haml",
@@ -192,6 +225,8 @@ Gem::Specification.new do |s|
192
225
  "app/views/admin/shop/variants/index/_foot.html.haml",
193
226
  "app/views/admin/shop/variants/index/_head.html.haml",
194
227
  "app/views/admin/shop/variants/index/_variant.html.haml",
228
+ "app/views/admin/shop/variants/index/buttons/_add_variant.html.haml",
229
+ "app/views/admin/shop/variants/index/buttons/_categories.html.haml",
195
230
  "app/views/admin/shop/variants/new.html.haml",
196
231
  "app/views/admin/shop/variants/remove.html.haml",
197
232
  "app/views/shop/categories/show.html.haml",
@@ -218,6 +253,10 @@ Gem::Specification.new do |s|
218
253
  "db/migrate/20101005231713_create_page_ids.rb",
219
254
  "db/migrate/20101006051214_create_pages_for_products_and_categories.rb",
220
255
  "db/migrate/20101007111845_add_default_position_to_attachment.rb",
256
+ "db/migrate/20101010071143_create_discounts.rb",
257
+ "db/migrate/20101010072225_modify_categories_remove_variant.rb",
258
+ "db/migrate/20101010130034_change_discountables_add_observer.rb",
259
+ "db/migrate/20101011063133_change_orders_set_limits_to_null.rb",
221
260
  "db/seed.rb",
222
261
  "db/seeds/forms.rb",
223
262
  "db/seeds/layouts.rb",
@@ -228,6 +267,7 @@ Gem::Specification.new do |s|
228
267
  "lib/shop/controllers/site_controller.rb",
229
268
  "lib/shop/interface/categories.rb",
230
269
  "lib/shop/interface/customers.rb",
270
+ "lib/shop/interface/discounts.rb",
231
271
  "lib/shop/interface/orders.rb",
232
272
  "lib/shop/interface/packages.rb",
233
273
  "lib/shop/interface/products.rb",
@@ -235,6 +275,7 @@ Gem::Specification.new do |s|
235
275
  "lib/shop/models/form_extension.rb",
236
276
  "lib/shop/models/image.rb",
237
277
  "lib/shop/models/page.rb",
278
+ "lib/shop/models/user.rb",
238
279
  "lib/shop/tags/address.rb",
239
280
  "lib/shop/tags/card.rb",
240
281
  "lib/shop/tags/cart.rb",
@@ -246,15 +287,18 @@ Gem::Specification.new do |s|
246
287
  "lib/shop/tags/product.rb",
247
288
  "lib/shop/tags/product_variant.rb",
248
289
  "lib/shop/tags/responses.rb",
290
+ "lib/shop/tags/tax.rb",
249
291
  "lib/tasks/shop_extension_tasks.rake",
250
292
  "mockups/balsamiq/products-retro_fun_tshirt-more.bmml",
251
293
  "mockups/balsamiq/products-retro_fun_tshirt.bmml",
252
294
  "mockups/discounts/new-edit.bmml",
253
295
  "public/images/admin/extensions/shop/products/sort.png",
296
+ "public/javascripts/admin/extensions/shop/discounts/edit.js",
254
297
  "public/javascripts/admin/extensions/shop/edit.js",
255
298
  "public/javascripts/admin/extensions/shop/packages/edit.js",
256
299
  "public/javascripts/admin/extensions/shop/products/edit.js",
257
300
  "public/javascripts/admin/extensions/shop/products/index.js",
301
+ "public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass",
258
302
  "public/stylesheets/sass/admin/extensions/shop/edit.sass",
259
303
  "public/stylesheets/sass/admin/extensions/shop/index.sass",
260
304
  "public/stylesheets/sass/admin/extensions/shop/packages/edit.sass",
@@ -264,6 +308,8 @@ Gem::Specification.new do |s|
264
308
  "shop_extension.rb",
265
309
  "spec/controllers/admin/shop/categories_controller_spec.rb",
266
310
  "spec/controllers/admin/shop/customers_controller_spec.rb",
311
+ "spec/controllers/admin/shop/discounts/discountables_controller_spec.rb",
312
+ "spec/controllers/admin/shop/discounts_controller_spec.rb",
267
313
  "spec/controllers/admin/shop/orders_controller_spec.rb",
268
314
  "spec/controllers/admin/shop/packages/packings_controller_spec.rb",
269
315
  "spec/controllers/admin/shop/packages_controller_spec.rb",
@@ -277,6 +323,8 @@ Gem::Specification.new do |s|
277
323
  "spec/datasets/shop_addresses.rb",
278
324
  "spec/datasets/shop_categories.rb",
279
325
  "spec/datasets/shop_customers.rb",
326
+ "spec/datasets/shop_discountables.rb",
327
+ "spec/datasets/shop_discounts.rb",
280
328
  "spec/datasets/shop_groups.rb",
281
329
  "spec/datasets/shop_line_items.rb",
282
330
  "spec/datasets/shop_orders.rb",
@@ -300,14 +348,18 @@ Gem::Specification.new do |s|
300
348
  "spec/lib/shop/tags/product_spec.rb",
301
349
  "spec/lib/shop/tags/product_variant_spec.rb",
302
350
  "spec/lib/shop/tags/responses_spec.rb",
351
+ "spec/lib/shop/tags/tax_spec.rb",
303
352
  "spec/matchers/comparison.rb",
304
353
  "spec/matchers/render_matcher.rb",
305
354
  "spec/models/form_address_spec.rb",
306
355
  "spec/models/form_checkout_spec.rb",
356
+ "spec/models/form_discount_spec.rb",
307
357
  "spec/models/shop_address_spec.rb",
308
358
  "spec/models/shop_category_page_spec.rb",
309
359
  "spec/models/shop_category_spec.rb",
310
360
  "spec/models/shop_customer_spec.rb",
361
+ "spec/models/shop_discount_spec.rb",
362
+ "spec/models/shop_discountable_spec.rb",
311
363
  "spec/models/shop_group_spec.rb",
312
364
  "spec/models/shop_line_item_spec.rb",
313
365
  "spec/models/shop_order_spec.rb",
@@ -334,6 +386,8 @@ Gem::Specification.new do |s|
334
386
  s.test_files = [
335
387
  "spec/controllers/admin/shop/categories_controller_spec.rb",
336
388
  "spec/controllers/admin/shop/customers_controller_spec.rb",
389
+ "spec/controllers/admin/shop/discounts/discountables_controller_spec.rb",
390
+ "spec/controllers/admin/shop/discounts_controller_spec.rb",
337
391
  "spec/controllers/admin/shop/orders_controller_spec.rb",
338
392
  "spec/controllers/admin/shop/packages/packings_controller_spec.rb",
339
393
  "spec/controllers/admin/shop/packages_controller_spec.rb",
@@ -347,6 +401,8 @@ Gem::Specification.new do |s|
347
401
  "spec/datasets/shop_addresses.rb",
348
402
  "spec/datasets/shop_categories.rb",
349
403
  "spec/datasets/shop_customers.rb",
404
+ "spec/datasets/shop_discountables.rb",
405
+ "spec/datasets/shop_discounts.rb",
350
406
  "spec/datasets/shop_groups.rb",
351
407
  "spec/datasets/shop_line_items.rb",
352
408
  "spec/datasets/shop_orders.rb",
@@ -370,14 +426,18 @@ Gem::Specification.new do |s|
370
426
  "spec/lib/shop/tags/product_spec.rb",
371
427
  "spec/lib/shop/tags/product_variant_spec.rb",
372
428
  "spec/lib/shop/tags/responses_spec.rb",
429
+ "spec/lib/shop/tags/tax_spec.rb",
373
430
  "spec/matchers/comparison.rb",
374
431
  "spec/matchers/render_matcher.rb",
375
432
  "spec/models/form_address_spec.rb",
376
433
  "spec/models/form_checkout_spec.rb",
434
+ "spec/models/form_discount_spec.rb",
377
435
  "spec/models/shop_address_spec.rb",
378
436
  "spec/models/shop_category_page_spec.rb",
379
437
  "spec/models/shop_category_spec.rb",
380
438
  "spec/models/shop_customer_spec.rb",
439
+ "spec/models/shop_discount_spec.rb",
440
+ "spec/models/shop_discountable_spec.rb",
381
441
  "spec/models/shop_group_spec.rb",
382
442
  "spec/models/shop_line_item_spec.rb",
383
443
  "spec/models/shop_order_spec.rb",
@@ -399,30 +459,33 @@ Gem::Specification.new do |s|
399
459
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
400
460
  s.add_runtime_dependency(%q<radiant>, [">= 0.9.1"])
401
461
  s.add_runtime_dependency(%q<activemerchant>, [">= 1.8.0"])
462
+ s.add_runtime_dependency(%q<fastercsv>, [">= 1.5.3"])
402
463
  s.add_runtime_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
403
464
  s.add_runtime_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
404
465
  s.add_runtime_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
405
466
  s.add_runtime_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
406
- s.add_runtime_dependency(%q<radiant-scoped-extension>, [">= 0.2.1"])
467
+ s.add_runtime_dependency(%q<radiant-scoped-extension>, [">= 0.2.2"])
407
468
  s.add_runtime_dependency(%q<radiant-drag-extension>, [">= 0.1.0"])
408
469
  else
409
470
  s.add_dependency(%q<radiant>, [">= 0.9.1"])
410
471
  s.add_dependency(%q<activemerchant>, [">= 1.8.0"])
472
+ s.add_dependency(%q<fastercsv>, [">= 1.5.3"])
411
473
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
412
474
  s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
413
475
  s.add_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
414
476
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
415
- s.add_dependency(%q<radiant-scoped-extension>, [">= 0.2.1"])
477
+ s.add_dependency(%q<radiant-scoped-extension>, [">= 0.2.2"])
416
478
  s.add_dependency(%q<radiant-drag-extension>, [">= 0.1.0"])
417
479
  end
418
480
  else
419
481
  s.add_dependency(%q<radiant>, [">= 0.9.1"])
420
482
  s.add_dependency(%q<activemerchant>, [">= 1.8.0"])
483
+ s.add_dependency(%q<fastercsv>, [">= 1.5.3"])
421
484
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
422
485
  s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
423
486
  s.add_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
424
487
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
425
- s.add_dependency(%q<radiant-scoped-extension>, [">= 0.2.1"])
488
+ s.add_dependency(%q<radiant-scoped-extension>, [">= 0.2.2"])
426
489
  s.add_dependency(%q<radiant-drag-extension>, [">= 0.1.0"])
427
490
  end
428
491
  end
data/shop_extension.rb CHANGED
@@ -5,35 +5,40 @@ class ShopExtension < Radiant::Extension
5
5
 
6
6
  extension_config do |config|
7
7
  config.gem 'activemerchant', :lib => 'active_merchant'
8
+ config.gem 'fastercsv', :lib => 'fastercsv'
8
9
  end
9
10
 
10
- UserActionObserver.instance.send :add_observer!, ShopProduct
11
11
  UserActionObserver.instance.send :add_observer!, ShopCategory
12
+ UserActionObserver.instance.send :add_observer!, ShopDiscount
12
13
  UserActionObserver.instance.send :add_observer!, ShopOrder
14
+ UserActionObserver.instance.send :add_observer!, ShopPackage
15
+ UserActionObserver.instance.send :add_observer!, ShopProduct
13
16
  UserActionObserver.instance.send :add_observer!, ShopProductAttachment
17
+ UserActionObserver.instance.send :add_observer!, ShopDiscountable
14
18
  UserActionObserver.instance.send :add_observer!, ShopProductVariant
15
19
  UserActionObserver.instance.send :add_observer!, ShopVariant
16
- UserActionObserver.instance.send :add_observer!, ShopPackage
17
20
 
18
21
  def activate
19
22
  # View Hooks
20
23
  unless defined? admin.products
21
- Radiant::AdminUI.send :include, Shop::Interface::Categories, Shop::Interface::Customers, Shop::Interface::Orders, Shop::Interface::Packages, Shop::Interface::Products, Shop::Interface::Variants
22
-
23
- admin.categories= Radiant::AdminUI.load_default_shop_categories_regions
24
- admin.customers = Radiant::AdminUI.load_default_shop_customers_regions
25
- admin.orders = Radiant::AdminUI.load_default_shop_orders_regions
26
- admin.packages = Radiant::AdminUI.load_default_shop_packages_regions
27
- admin.products = Radiant::AdminUI.load_default_shop_products_regions
28
- admin.variants = Radiant::AdminUI.load_default_shop_variants_regions
24
+ Radiant::AdminUI.send :include, Shop::Interface::Categories, Shop::Interface::Customers, Shop::Interface::Discounts, Shop::Interface::Orders, Shop::Interface::Packages, Shop::Interface::Products, Shop::Interface::Variants
25
+
26
+ admin.categories = Radiant::AdminUI.load_default_shop_categories_regions
27
+ admin.customers = Radiant::AdminUI.load_default_shop_customers_regions
28
+ admin.discounts = Radiant::AdminUI.load_default_shop_discounts_regions
29
+ admin.orders = Radiant::AdminUI.load_default_shop_orders_regions
30
+ admin.packages = Radiant::AdminUI.load_default_shop_packages_regions
31
+ admin.products = Radiant::AdminUI.load_default_shop_products_regions
32
+ admin.variants = Radiant::AdminUI.load_default_shop_variants_regions
29
33
  end
30
34
 
31
35
  # Tags
32
- Page.send :include, Shop::Tags::Core, Shop::Tags::Address, Shop::Tags::Card, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Package, Shop::Tags::Product, Shop::Tags::ProductVariant, Shop::Tags::Responses
36
+ Page.send :include, Shop::Tags::Core, Shop::Tags::Address, Shop::Tags::Card, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Package, Shop::Tags::Product, Shop::Tags::ProductVariant, Shop::Tags::Responses, Shop::Tags::Tax
33
37
 
34
38
  # Model Includes
35
- Page.send :include, Shop::Models::Page
39
+ Page.send :include, Shop::Models::Page
36
40
  Image.send :include, Shop::Models::Image
41
+ User.send :include, Shop::Models::User
37
42
 
38
43
  # Controller Includes
39
44
  ApplicationController.send :include, Shop::Controllers::ApplicationController
@@ -43,7 +48,9 @@ class ShopExtension < Radiant::Extension
43
48
 
44
49
  tab "Shop" do
45
50
  add_item "Products", "/admin/shop"
51
+ add_item "Packages", "/admin/shop/packages"
46
52
  add_item "Orders", "/admin/shop/orders"
53
+ add_item "Discounts", "/admin/shop/discounts"
47
54
  add_item "Customers", "/admin/shop/customers"
48
55
  end
49
56
 
@@ -58,6 +65,10 @@ class ShopExtension < Radiant::Extension
58
65
  Radiant::Config['shop.price_separator'] ||= '.'
59
66
  Radiant::Config['shop.price_delimiter'] ||= ','
60
67
 
68
+ Radiant::Config['shop.tax_strategy'] ||= 'inclusive' #exclusive
69
+ Radiant::Config['shop.tax_percentage'] ||= '10'
70
+ Radiant::Config['shop.tax_name'] ||= 'gst'
71
+
61
72
  # Scoped Customer Welcome Page
62
73
  Radiant::Config['scoped.customer.redirect'] = '/cart'
63
74
  end
@@ -0,0 +1,73 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Admin::Shop::Discounts::DiscountablesController do
4
+
5
+ dataset :users, :shop_discountables
6
+
7
+ before :each do
8
+ login_as :admin
9
+ @discountable = shop_discountables(:ten_percent_bread)
10
+ end
11
+
12
+ describe '#create' do
13
+ before :each do
14
+ @discounted = shop_products(:warm_bread)
15
+ end
16
+ context 'packing could not be created' do
17
+ before :each do
18
+ stub(ShopDiscountable).new { @discountable }
19
+ mock(@discountable).save! { raise ActiveRecord::RecordNotSaved }
20
+ end
21
+
22
+ context 'js' do
23
+ it 'should return error notice and failure status' do
24
+ post :create, :discount_id => @discountable.discount.id, :discounted_id => @discounted.id, :discounted_type => @discounted.class.name, :format => 'js'
25
+
26
+ response.body.should === 'Could not attach Discount.'
27
+ response.should_not be_success
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'packing successfully created' do
33
+ context 'js' do
34
+ it 'should render the collection partial and success status' do
35
+ post :create, :discount_id => @discountable.discount.id, :discounted_id => @discounted.id, :discounted_type => @discounted.class.name, :format => 'js'
36
+
37
+ response.should be_success
38
+ assigns(:shop_discountable).is_a?(ShopDiscountable).should === true
39
+ response.should render_template('admin/shop/discounts/edit/shared/_product')
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ describe '#destroy' do
46
+ context 'discountable not destroyed' do
47
+ before :each do
48
+ stub(ShopDiscountable).find(@discountable.id.to_s) { @discountable }
49
+ stub(@discountable).destroy { raise ActiveRecord::RecordNotFound }
50
+ end
51
+
52
+ context 'js' do
53
+ it 'should render an error and failure status' do
54
+ delete :destroy, :discount_id => @discountable.discount.id, :id => @discountable.id, :format => 'js'
55
+
56
+ response.should_not be_success
57
+ response.body.should === 'Could not remove Discount.'
58
+ end
59
+ end
60
+ end
61
+
62
+ context 'discountable successfully destroyed' do
63
+ context 'js' do
64
+ it 'should render success message and success status' do
65
+ delete :destroy, :discount_id => @discountable.discount.id, :id => @discountable.id, :format => 'js'
66
+ response.should be_success
67
+ response.should render_template('admin/shop/discounts/edit/shared/_category')
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ end