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,342 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Shop::Tags::Package do
4
-
5
- dataset :pages, :shop_packages
6
-
7
- it 'should describe these tags' do
8
- Shop::Tags::Package.tags.sort.should == [
9
- 'shop:packages',
10
- 'shop:packages:if_packages',
11
- 'shop:packages:unless_packages',
12
- 'shop:packages:each',
13
- 'shop:package',
14
- 'shop:package:id',
15
- 'shop:package:name',
16
- 'shop:package:sku',
17
- 'shop:package:description',
18
- 'shop:package:price',
19
- 'shop:package:value',
20
- 'shop:package:if_products',
21
- 'shop:package:unless_products',
22
- 'shop:package:products',
23
- 'shop:package:products:each',
24
- 'shop:package:product:quantity'].sort
25
- end
26
-
27
- before :all do
28
- @page = pages(:home)
29
- end
30
-
31
- before :each do
32
- @package = shop_packages(:all_bread)
33
- end
34
-
35
- context 'outside a package' do
36
- describe '<r:shop:packages>' do
37
- context 'packages' do
38
- it 'should render' do
39
- tag = %{<r:shop:packages>success</r:shop:packages>}
40
- exp = %{success}
41
-
42
- @page.should render(tag).as(exp)
43
- end
44
- end
45
- context 'no packages' do
46
- it 'should render' do
47
- tag = %{<r:shop:packages>success</r:shop:packages>}
48
- exp = %{success}
49
-
50
- @page.should render(tag).as(exp)
51
- end
52
- end
53
- end
54
-
55
- describe '<r:shop:packages:if_packages>' do
56
- context 'success' do
57
- it 'should render' do
58
- tag = %{<r:shop:packages:if_packages>success</r:shop:packages:if_packages>}
59
- exp = %{success}
60
-
61
- @page.should render(tag).as(exp)
62
- end
63
- end
64
- context 'failure' do
65
- it 'should render' do
66
- mock(Shop::Tags::Helpers).current_packages(anything) { [] }
67
- tag = %{<r:shop:packages:if_packages>failure</r:shop:packages:if_packages>}
68
- exp = %{}
69
-
70
- @page.should render(tag).as(exp)
71
- end
72
- end
73
- end
74
-
75
- describe '<r:shop:packages:unless_packages>' do
76
- context 'success' do
77
- it 'should not render' do
78
- mock(Shop::Tags::Helpers).current_packages(anything) { [] }
79
-
80
- tag = %{<r:shop:packages:unless_packages>success</r:shop:packages:unless_packages>}
81
- exp = %{success}
82
-
83
- @page.should render(tag).as(exp)
84
- end
85
- end
86
- context 'failure' do
87
- it 'should render' do
88
- mock(Shop::Tags::Helpers).current_packages(anything) { ShopPackage.all }
89
-
90
- tag = %{<r:shop:packages:unless_packages>failure</r:shop:packages:unless_packages>}
91
- exp = %{}
92
-
93
- @page.should render(tag).as(exp)
94
- end
95
- end
96
- end
97
-
98
- describe '<r:shop:packages:each>' do
99
- context 'success' do
100
- it 'should render' do
101
- mock(Shop::Tags::Helpers).current_packages(anything) { ShopPackage.all }
102
-
103
- tag = %{<r:shop:packages:each>.a.</r:shop:packages:each>}
104
- exp = ShopPackage.all.map{ '.a.' }.join('')
105
-
106
- @page.should render(tag).as(exp)
107
- end
108
- end
109
-
110
- context 'failure' do
111
- it 'should not render' do
112
- mock(Shop::Tags::Helpers).current_packages(anything) { [] }
113
-
114
- tag = %{<r:shop:packages:each>failure</r:shop:packages:each>}
115
- exp = %{}
116
-
117
- @page.should render(tag).as(exp)
118
- end
119
- end
120
- end
121
-
122
- describe '<r:shop:package>' do
123
- context 'success' do
124
- it 'should render' do
125
- mock(Shop::Tags::Helpers).current_package(anything) { @package }
126
-
127
- tag = %{<r:shop:package>success</r:shop:package>}
128
- exp = %{success}
129
-
130
- @page.should render(tag).as(exp)
131
- end
132
- end
133
-
134
- context 'failure' do
135
- it 'should not render' do
136
- mock(Shop::Tags::Helpers).current_package(anything) { nil }
137
-
138
- tag = %{<r:shop:package>failure</r:shop:package>}
139
- exp = %{}
140
-
141
- @page.should render(tag).as(exp)
142
- end
143
- end
144
- end
145
-
146
- end
147
-
148
- context 'within a package' do
149
-
150
- before :each do
151
- mock(Shop::Tags::Helpers).current_package(anything) { @package }
152
- end
153
-
154
- context 'simple attributes' do
155
- describe '<r:shop:package:id />' do
156
- it 'should render the id' do
157
- tag = %{<r:shop:package:id />}
158
- exp = @package.id.to_s
159
-
160
- @page.should render(tag).as(exp)
161
- end
162
- end
163
-
164
- describe '<r:shop:package:name />' do
165
- it 'should render the name' do
166
- tag = %{<r:shop:package:name />}
167
- exp = @package.name.to_s
168
-
169
- @page.should render(tag).as(exp)
170
- end
171
- end
172
-
173
- describe '<r:shop:package:sku />' do
174
- it 'should render the sku' do
175
- tag = %{<r:shop:package:sku />}
176
- exp = @package.sku.to_s
177
-
178
- @page.should render(tag).as(exp)
179
- end
180
- end
181
- end
182
-
183
- describe '<r:package:description />' do
184
- it 'should render a textile filtered result' do
185
- @package.description = '*bold*'
186
-
187
- tag = %{<r:shop:package:description />}
188
- exp = %{<p><strong>bold</strong></p>}
189
-
190
- @page.should render(tag).as(exp)
191
- end
192
- end
193
-
194
- context 'currency attributes' do
195
- describe '<r:shop:package:price />' do
196
- before :each do
197
- @package.price = 1234.34567890
198
- end
199
-
200
- it 'should render a standard price' do
201
- tag = %{<r:shop:package:price />}
202
- exp = %{$1,234.35}
203
- @page.should render(tag).as(exp)
204
- end
205
-
206
- it 'should render a high precision price' do
207
- tag = %{<r:shop:package:price precision="8"/>}
208
- exp = %{$1,234.34567890}
209
-
210
- @page.should render(tag).as(exp)
211
- end
212
-
213
- it 'should render a custom format' do
214
- tag = %{<r:shop:package:price unit="%" separator="-" delimiter="+" />}
215
- exp = %{%1+234-35}
216
-
217
- @page.should render(tag).as(exp)
218
- end
219
- end
220
-
221
- describe '<r:shop:package:name />' do
222
- before :each do
223
- stub(@package).value { 1234.34567890 }
224
- end
225
-
226
- it 'should render a standard price' do
227
- tag = %{<r:shop:package:value />}
228
- exp = %{$1,234.35}
229
-
230
- @page.should render(tag).as(exp)
231
- end
232
-
233
- it 'should render a high precision price' do
234
- tag = %{<r:shop:package:value precision="8"/>}
235
- exp = %{$1,234.34567890}
236
-
237
- @page.should render(tag).as(exp)
238
- end
239
-
240
- it 'should render a custom format' do
241
- tag = %{<r:shop:package:value unit="%" separator="-" delimiter="+" />}
242
- exp = %{%1+234-35}
243
-
244
- @page.should render(tag).as(exp)
245
- end
246
- end
247
- end
248
-
249
- end
250
-
251
- context 'products in a package' do
252
-
253
- before :each do
254
- mock(Shop::Tags::Helpers).current_package(anything) { @package }
255
- end
256
-
257
- describe '<r:shop:package:if_products>' do
258
- context 'success' do
259
- it 'should render' do
260
- tag = %{<r:shop:package:if_products>success</r:shop:package:if_products>}
261
- exp = %{success}
262
-
263
- @page.should render(tag).as(exp)
264
- end
265
- end
266
-
267
- context 'failure' do
268
- it 'should not render' do
269
- stub(@package).products { [] }
270
-
271
- tag = %{<r:shop:package:if_products>failure</r:shop:package:if_products>}
272
- exp = %{}
273
-
274
- @page.should render(tag).as(exp)
275
- end
276
- end
277
- end
278
-
279
- describe '<r:shop:package:unless_products>' do
280
- context 'success' do
281
- it 'should render' do
282
- stub(@package).products { [] }
283
- tag = %{<r:shop:package:unless_products>success</r:shop:package:unless_products>}
284
- exp = %{success}
285
-
286
- @page.should render(tag).as(exp)
287
- end
288
- end
289
-
290
- context 'failure' do
291
- it 'should not render' do
292
- tag = %{<r:shop:package:unless_products>failure</r:shop:package:unless_products>}
293
- exp = %{}
294
-
295
- @page.should render(tag).as(exp)
296
- end
297
- end
298
- end
299
-
300
- describe '<r:shop:package:products>' do
301
- it 'should render' do
302
- tag = %{<r:shop:package:products>success</r:shop:package:products>}
303
- exp = %{success}
304
-
305
- @page.should render(tag).as(exp)
306
- end
307
- end
308
-
309
- describe '<r:shop:package:products:each>' do
310
- context 'success' do
311
- it 'should render' do
312
- tag = %{<r:shop:package:products:each>.a.</r:shop:package:products:each>}
313
- exp = @package.products.map{'.a.'}.join('')
314
-
315
- @page.should render(tag).as(exp)
316
- end
317
- end
318
-
319
- context 'failure' do
320
- it 'should not render' do
321
- stub(@package).packings { [] }
322
-
323
- tag = %{<r:shop:package:products:each>failure</r:shop:package:products:each>}
324
- exp = %{}
325
-
326
- @page.should render(tag).as(exp)
327
- end
328
- end
329
- end
330
-
331
- describe '<r:shop:package:product:quantity>' do
332
- it 'should render the quantity of the current packing' do
333
- tag = %{<r:shop:package:products:each:product:quantity />}
334
- exp = @package.packings.map{|p| p.quantity}.join('')
335
-
336
- @page.should render(tag).as(exp)
337
- end
338
- end
339
-
340
- end
341
-
342
- end
@@ -1,175 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Shop::Tags::ProductVariant do
4
-
5
- dataset :pages, :shop_product_variants, :shop_products
6
-
7
- it 'should describe these tags' do
8
- Shop::Tags::ProductVariant.tags.sort.should == [
9
- 'shop:product:variants',
10
- 'shop:product:variants:each',
11
- 'shop:product:variants:if_variants',
12
- 'shop:product:variants:unless_variants',
13
- 'shop:product:variant',
14
- 'shop:product:variant:id',
15
- 'shop:product:variant:name',
16
- 'shop:product:variant:sku',
17
- 'shop:product:variant:price'].sort
18
- end
19
-
20
- before :all do
21
- @page = pages(:home)
22
- end
23
-
24
- context 'tags' do
25
-
26
- before :each do
27
- @product = shop_products(:crusty_bread)
28
- @variant = shop_product_variants(:mouldy_crusty_bread)
29
-
30
- stub(Shop::Tags::Helpers).current_product(anything) { @product }
31
- end
32
-
33
- describe '<r:shop:product:variants>' do
34
- context 'variants exist' do
35
- it 'should render' do
36
- tag = %{<r:shop:product:variants>success</r:shop:product:variants>}
37
- exp = %{success}
38
-
39
- @page.should render(tag).as(exp)
40
- end
41
- end
42
-
43
- context 'variants do not exist' do
44
- it 'should render' do
45
- @product.variants = []
46
-
47
- tag = %{<r:shop:product:variants>success</r:shop:product:variants>}
48
- exp = %{success}
49
-
50
- @page.should render(tag).as(exp)
51
- end
52
- end
53
- end
54
-
55
- describe '<r:shop:product:variants:if_variants>' do
56
- context 'success' do
57
- it 'should render' do
58
- tag = %{<r:shop:product:variants:if_variants>success</r:shop:product:variants:if_variants>}
59
- exp = %{success}
60
- @page.should render(tag).as(exp)
61
- end
62
- end
63
-
64
- context 'failure' do
65
- it 'should not render' do
66
- mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
67
-
68
- tag = %{<r:shop:product:variants:if_variants>failure</r:shop:product:variants:if_variants>}
69
- exp = %{}
70
- @page.should render(tag).as(exp)
71
- end
72
- end
73
- end
74
-
75
- describe '<r:shop:product:variants:unless_variants>' do
76
- context 'success' do
77
- it 'should render' do
78
- mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
79
-
80
- tag = %{<r:shop:product:variants:unless_variants>success</r:shop:product:variants:unless_variants>}
81
- exp = %{success}
82
- @page.should render(tag).as(exp)
83
- end
84
- end
85
-
86
- context 'failure' do
87
- it 'should not render' do
88
- tag = %{<r:shop:product:variants:unless_variants>failure</r:shop:product:variants:unless_variants>}
89
- exp = %{}
90
- @page.should render(tag).as(exp)
91
- end
92
- end
93
- end
94
-
95
- describe '<r:shop:product:variants:each>' do
96
- context 'success' do
97
- it 'should not render' do
98
- tag = %{<r:shop:product:variants:each><r:product:id /></r:shop:product:variants:each>}
99
- exp = @product.variants.map{ |p| p.product.id }.join('')
100
- @page.should render(tag).as(exp)
101
- end
102
- end
103
-
104
- context 'failure' do
105
- it 'should not render' do
106
- mock(Shop::Tags::Helpers).current_product_variants(anything) { [] }
107
-
108
- tag = %{<r:shop:product:variants:each>failure</r:shop:product:variants:each>}
109
- exp = %{}
110
- @page.should render(tag).as(exp)
111
- end
112
- end
113
- end
114
-
115
- describe '<r:shop:product:variant>' do
116
- context 'variant exists in the context' do
117
- it 'should render' do
118
- mock(Shop::Tags::Helpers).current_product_variant(anything) { @variant }
119
-
120
- tag = %{<r:shop:product:variant>success</r:shop:product:variant>}
121
- exp = %{success}
122
- @page.should render(tag).as(exp)
123
- end
124
- end
125
-
126
- context 'product does not exist in the context' do
127
- it 'should not render' do
128
- mock(Shop::Tags::Helpers).current_product_variant(anything) { nil }
129
-
130
- tag = %{<r:shop:product:variant>failure</r:shop:product:variant>}
131
- exp = %{}
132
- @page.should render(tag).as(exp)
133
- end
134
- end
135
- end
136
-
137
- context '#attributes' do
138
- before :each do
139
- mock(Shop::Tags::Helpers).current_product_variant(anything) { @variant }
140
- end
141
-
142
- describe '<r:id />' do
143
- it 'should render the product id' do
144
- tag = %{<r:shop:product:variant:id />}
145
- exp = @variant.id.to_s
146
- @page.should render(tag).as(exp)
147
- end
148
- end
149
- describe '<r:name />' do
150
- it 'should render the product name' do
151
- tag = %{<r:shop:product:variant:name />}
152
- exp = @variant.name
153
- @page.should render(tag).as(exp)
154
- end
155
- end
156
- describe '<r:sku />' do
157
- it 'should render the product sku' do
158
- tag = %{<r:shop:product:variant:sku />}
159
- exp = @variant.sku
160
- @page.should render(tag).as(exp)
161
- end
162
- end
163
- describe '<r:price />' do
164
- it 'should render a standard price' do
165
- tag = %{<r:shop:product:variant:price />}
166
- exp = Shop::Tags::Helpers.currency(@variant.price,{})
167
-
168
- @page.should render(tag).as(exp)
169
- end
170
- end
171
- end
172
-
173
- end
174
-
175
- end
@@ -1,129 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe Shop::Tags::Responses do
4
-
5
- dataset :forms, :pages
6
-
7
- it 'should describe these tags' do
8
- Shop::Tags::Responses.tags.sort.should == [
9
- 'response:checkout',
10
- 'response:checkout:payment',
11
- 'response:checkout:payment:if_success',
12
- 'response:checkout:payment:unless_success'
13
- ].sort
14
- end
15
-
16
- context 'responses' do
17
-
18
- before :each do
19
- login_as :customer
20
- @order = shop_orders(:several_items)
21
-
22
- mock_page_with_request_and_data
23
- mock_response
24
-
25
- mock.instance_of(ActiveMerchant::Billing::CreditCard).valid? { true }
26
- mock_valid_form_checkout_request
27
- @checkout = FormCheckout.new(@form, @page)
28
- end
29
-
30
- describe '<r:response:checkout>' do
31
- context 'checkout exists' do
32
- before :each do
33
- @response.result[:results][:checkout] = @checkout.create
34
- end
35
- it 'should expand' do
36
- tag = %{<r:response:checkout>success</r:response:checkout>}
37
- exp = %{success}
38
-
39
- pages(:home).should render(tag).as(exp)
40
- end
41
- end
42
- context 'checkout does not exist' do
43
- it 'should not expand' do
44
- tag = %{<r:response:checkout>failure</r:response:checkout>}
45
- exp = %{}
46
-
47
- pages(:home).should render(tag).as(exp)
48
- end
49
- end
50
- end
51
-
52
- describe '<r:response:payment>' do
53
- before :each do
54
- @response.result[:results][:checkout] = @checkout.create
55
- end
56
- context 'payment success' do
57
- it 'should expand' do
58
- tag = %{<r:response:checkout:payment>success</r:response:checkout:payment>}
59
- exp = %{success}
60
-
61
- pages(:home).should render(tag).as(exp)
62
- end
63
- end
64
- context 'payment failure' do
65
- before :each do
66
- @response.result[:results][:checkout][:payment] = false
67
- end
68
- it 'should expand' do
69
- tag = %{<r:response:checkout:payment>success</r:response:checkout:payment>}
70
- exp = %{success}
71
-
72
- pages(:home).should render(tag).as(exp)
73
- end
74
- end
75
- end
76
-
77
- describe '<r:response:payment:if_success>' do
78
- before :each do
79
- @response.result[:results][:checkout] = @checkout.create
80
- end
81
- context 'payment success' do
82
- it 'should expand' do
83
- tag = %{<r:response:checkout:payment:if_success>success</r:response:checkout:payment:if_success>}
84
- exp = %{success}
85
-
86
- pages(:home).should render(tag).as(exp)
87
- end
88
- end
89
- context 'payment failure' do
90
- before :each do
91
- @response.result[:results][:checkout][:payment] = false
92
- end
93
- it 'should not expand' do
94
- tag = %{<r:response:checkout:payment:if_success>failure</r:response:checkout:payment:if_success>}
95
- exp = %{}
96
-
97
- pages(:home).should render(tag).as(exp)
98
- end
99
- end
100
- end
101
-
102
- describe '<r:response:payment:unless_success>' do
103
- before :each do
104
- @response.result[:results][:checkout] = @checkout.create
105
- end
106
- context 'payment failure' do
107
- before :each do
108
- @response.result[:results][:checkout][:payment] = false
109
- end
110
- it 'should expand' do
111
- tag = %{<r:response:checkout:payment:unless_success>success</r:response:checkout:payment:unless_success>}
112
- exp = %{success}
113
-
114
- pages(:home).should render(tag).as(exp)
115
- end
116
- end
117
- context 'payment success' do
118
- it 'should not expand' do
119
- tag = %{<r:response:checkout:payment:unless_success>failure</r:response:checkout:payment:unless_success>}
120
- exp = %{}
121
-
122
- pages(:home).should render(tag).as(exp)
123
- end
124
- end
125
- end
126
-
127
- end
128
-
129
- end
@@ -1,63 +0,0 @@
1
- require 'spec/spec_helper'
2
-
3
- describe FormDiscount do
4
-
5
- dataset :shop_discounts, :pages, :forms
6
-
7
- before :each do
8
- mock_page_with_request_and_data
9
- end
10
-
11
- describe '#create' do
12
- before :each do
13
- login_as :customer
14
- @order = shop_orders(:several_items)
15
- end
16
- context 'add' do
17
- before :each do
18
- mock_valid_form_discount_request
19
- end
20
- context 'valid discount' do
21
- before :each do
22
- @discount = FormDiscount.new(@form, @page)
23
- @result = @discount.create
24
- end
25
- it 'should add the discount to the order' do
26
- shop_orders(:several_items).discounts.first(:conditions => { :code => '10pcoff' }).should_not be_nil
27
- end
28
- it 'should return true for result[:add]' do
29
- @result[:add].should be_true
30
- end
31
- end
32
- context 'invalid discount' do
33
- before :each do
34
- @data[:discount][:code] = 'invalid'
35
- end
36
- it 'should not add the discount to the order' do
37
- shop_orders(:several_items).discounts.first(:conditions => { :code => 'invalid' }).should be_nil
38
- end
39
- end
40
- end
41
-
42
- context 'remove' do
43
- before :each do
44
- discountable = shop_discounts(:ten_percent).discountables.create(:discounted_id => @order.id, :discounted_type => @order.class.name)
45
-
46
- mock_valid_form_discount_request
47
- @form[:extensions][:discount][:process] = 'remove'
48
- @data[:discountable] = { :id => discountable.id }
49
-
50
- @discount = FormDiscount.new(@form, @page)
51
- @result = @discount.create
52
- end
53
- it 'should remove the discount from the order' do
54
- shop_orders(:several_items).discounts.include?(shop_discounts(:ten_percent)).should be_false
55
- end
56
- it 'should return true for result[:remove]' do
57
- @result[:remove].should be_true
58
- end
59
- end
60
-
61
- end
62
-
63
- end