radiant-shop-extension 0.11.6 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +21 -3
- data/LICENSE +42 -0
- data/README.md +62 -25
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +1 -0
- data/app/controllers/admin/shop/orders_controller.rb +1 -1
- data/app/controllers/admin/shop/products_controller.rb +18 -7
- data/app/helpers/shop_helper.rb +8 -0
- data/app/models/form_address.rb +5 -5
- data/app/models/form_checkout.rb +25 -17
- data/app/models/form_line_item.rb +1 -1
- data/app/models/shop_category.rb +22 -7
- data/app/models/shop_customer.rb +1 -1
- data/app/models/shop_line_item.rb +26 -26
- data/app/models/shop_order.rb +0 -2
- data/app/models/shop_product.rb +15 -18
- data/app/views/.DS_Store +0 -0
- data/app/views/admin/shop/categories/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/edit/_foot.html.haml +1 -8
- data/app/views/admin/shop/products/edit/meta/_layout.html.haml +6 -0
- data/app/views/admin/shop/products/edit/meta/_status.html.haml +3 -0
- data/app/views/admin/shop/products/index/_product.html.haml +1 -1
- data/config/locales/en.yml +8 -7
- data/config/routes.rb +4 -16
- data/db/migrate/20101011063133_setup_shop.rb +94 -0
- data/db/seeds/forms.rb +113 -154
- data/db/seeds/layouts.rb +67 -103
- data/db/seeds/pages.rb +101 -0
- data/db/seeds/products.rb +29 -0
- data/db/seeds/snippets.rb +36 -21
- data/lib/shop/controllers/application_controller.rb +5 -3
- data/lib/shop/models/form_extension.rb +1 -2
- data/lib/shop/models/page.rb +0 -1
- data/lib/shop/models/user.rb +0 -1
- data/lib/shop/tags/card.rb +8 -2
- data/lib/shop/tags/cart.rb +5 -1
- data/lib/shop/tags/helpers.rb +35 -60
- data/lib/shop/tags/item.rb +2 -16
- data/lib/shop/tags/product.rb +7 -0
- data/lib/tasks/shop_extension_tasks.rake +9 -4
- data/public/javascripts/admin/extensions/shop/products/edit.js +0 -25
- data/radiant-shop-extension.gemspec +25 -201
- data/shop_extension.rb +18 -19
- data/spec/datasets/forms.rb +25 -28
- data/spec/datasets/shop_categories.rb +2 -2
- data/spec/datasets/shop_config.rb +24 -0
- data/spec/datasets/shop_customers.rb +1 -0
- data/spec/datasets/shop_line_items.rb +21 -3
- data/spec/datasets/shop_products.rb +4 -1
- data/spec/datasets/tags.rb +19 -0
- data/spec/lib/shop/models/page_spec.rb +1 -1
- data/spec/lib/shop/tags/card_spec.rb +30 -4
- data/spec/lib/shop/tags/cart_spec.rb +29 -12
- data/spec/lib/shop/tags/helpers_spec.rb +45 -66
- data/spec/lib/shop/tags/item_spec.rb +6 -10
- data/spec/lib/shop/tags/product_spec.rb +27 -2
- data/spec/models/form_address_spec.rb +9 -8
- data/spec/models/form_checkout_spec.rb +28 -22
- data/spec/models/shop_category_spec.rb +2 -10
- data/spec/models/shop_line_item_spec.rb +71 -34
- data/spec/models/shop_order_spec.rb +5 -5
- data/spec/models/shop_product_attachment_spec.rb +1 -0
- data/spec/models/shop_product_spec.rb +4 -47
- data/spec/spec.opts +3 -5
- metadata +60 -248
- data/Gemfile +0 -26
- data/Gemfile.lock +0 -75
- data/MIT-LICENSE +0 -20
- data/app/controllers/admin/shop/discounts/discountables_controller.rb +0 -44
- data/app/controllers/admin/shop/discounts_controller.rb +0 -64
- data/app/controllers/admin/shop/packages/packings_controller.rb +0 -90
- data/app/controllers/admin/shop/packages_controller.rb +0 -63
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +0 -27
- data/app/controllers/admin/shop/products/variants_controller.rb +0 -60
- data/app/controllers/admin/shop/variants_controller.rb +0 -48
- data/app/models/form_discount.rb +0 -39
- data/app/models/shop_discount.rb +0 -37
- data/app/models/shop_discountable.rb +0 -64
- data/app/models/shop_group.rb +0 -15
- data/app/models/shop_grouping.rb +0 -6
- data/app/models/shop_package.rb +0 -74
- data/app/models/shop_packing.rb +0 -22
- data/app/models/shop_product_variant.rb +0 -34
- data/app/models/shop_variant.rb +0 -23
- data/app/views/admin/pages/_shop_category.html.haml +0 -4
- data/app/views/admin/pages/_shop_product.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_foot.html.haml +0 -16
- data/app/views/admin/shop/discounts/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/discounts/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/discounts/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/discounts/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/discounts/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +0 -5
- data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +0 -6
- data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +0 -11
- data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +0 -12
- data/app/views/admin/shop/discounts/edit.html.haml +0 -11
- data/app/views/admin/shop/discounts/index/_discount.html.haml +0 -13
- data/app/views/admin/shop/discounts/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/discounts/index/_head.html.haml +0 -2
- data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +0 -1
- data/app/views/admin/shop/discounts/index.html.haml +0 -13
- data/app/views/admin/shop/discounts/new.html.haml +0 -11
- data/app/views/admin/shop/discounts/remove.html.haml +0 -12
- data/app/views/admin/shop/packages/edit/_foot.html.haml +0 -17
- data/app/views/admin/shop/packages/edit/_form.html.haml +0 -15
- data/app/views/admin/shop/packages/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/packages/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/packages/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/packages/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +0 -5
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +0 -1
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +0 -3
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +0 -7
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +0 -8
- data/app/views/admin/shop/packages/edit.html.haml +0 -11
- data/app/views/admin/shop/packages/index/_foot.html.haml +0 -8
- data/app/views/admin/shop/packages/index/_head.html.haml +0 -2
- data/app/views/admin/shop/packages/index/_package.html.haml +0 -9
- data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +0 -1
- data/app/views/admin/shop/packages/index.html.haml +0 -13
- data/app/views/admin/shop/packages/new.html.haml +0 -11
- data/app/views/admin/shop/packages/remove.html.haml +0 -12
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +0 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +0 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +0 -3
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +0 -6
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +0 -16
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +0 -6
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +0 -10
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +0 -1
- data/app/views/admin/shop/variants/edit/_foot.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_form.html.haml +0 -13
- data/app/views/admin/shop/variants/edit/_head.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +0 -2
- data/app/views/admin/shop/variants/edit/_meta.html.haml +0 -8
- data/app/views/admin/shop/variants/edit/_parts.html.haml +0 -9
- data/app/views/admin/shop/variants/edit/_popups.html.haml +0 -4
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +0 -3
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +0 -3
- data/app/views/admin/shop/variants/edit.html.haml +0 -11
- data/app/views/admin/shop/variants/index/_foot.html.haml +0 -5
- data/app/views/admin/shop/variants/index/_head.html.haml +0 -2
- data/app/views/admin/shop/variants/index/_variant.html.haml +0 -9
- data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +0 -1
- data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +0 -1
- data/app/views/admin/shop/variants/index.html.haml +0 -13
- data/app/views/admin/shop/variants/new.html.haml +0 -11
- data/app/views/admin/shop/variants/remove.html.haml +0 -12
- data/app/views/shop/categories/show.html.haml +0 -1
- data/app/views/shop/orders/show.html.haml +0 -1
- data/app/views/shop/products/index.html.haml +0 -1
- data/app/views/shop/products/show.html.haml +0 -1
- data/cucumber.yml +0 -1
- data/db/migrate/20100311053701_initial.rb +0 -153
- data/db/migrate/20100927041219_remove_payment_methods.rb +0 -16
- data/db/migrate/20100927041624_change_payments_add_gateway.rb +0 -11
- data/db/migrate/20100927140446_change_payment_add_card_type_card_number.rb +0 -11
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +0 -101
- data/db/migrate/20100929011607_drop_shop_addressables.rb +0 -25
- data/db/migrate/20100929030510_create_shop_groups.rb +0 -19
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +0 -11
- data/db/migrate/20100929081200_create_variants.rb +0 -20
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +0 -25
- data/db/migrate/20100929145641_change_created_by_to_id.rb +0 -75
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +0 -9
- data/db/migrate/20100930235221_create_packages.rb +0 -31
- data/db/migrate/20101005231713_create_page_ids.rb +0 -11
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +0 -73
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +0 -9
- data/db/migrate/20101010071143_create_discounts.rb +0 -29
- data/db/migrate/20101010072225_modify_categories_remove_variant.rb +0 -9
- data/db/migrate/20101010130034_change_discountables_add_observer.rb +0 -15
- data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +0 -11
- data/features/support/env.rb +0 -16
- data/features/support/paths.rb +0 -14
- data/lib/shop/interface/packages.rb +0 -34
- data/lib/shop/interface/variants.rb +0 -34
- data/lib/shop/tags/package.rb +0 -95
- data/lib/shop/tags/product_variant.rb +0 -52
- data/lib/shop/tags/responses.rb +0 -34
- data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
- data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
- data/mockups/discounts/new-edit.bmml +0 -492
- data/public/javascripts/admin/extensions/shop/discounts/edit.js +0 -76
- data/public/javascripts/admin/extensions/shop/packages/edit.js +0 -109
- data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +0 -125
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +0 -162
- data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +0 -73
- data/spec/controllers/admin/shop/discounts_controller_spec.rb +0 -81
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +0 -188
- data/spec/controllers/admin/shop/packages_controller_spec.rb +0 -32
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +0 -53
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +0 -116
- data/spec/controllers/admin/shop/variants_controller_spec.rb +0 -67
- data/spec/datasets/shop_discountables.rb +0 -22
- data/spec/datasets/shop_discounts.rb +0 -29
- data/spec/datasets/shop_groups.rb +0 -15
- data/spec/datasets/shop_packages.rb +0 -25
- data/spec/datasets/shop_product_variants.rb +0 -22
- data/spec/datasets/shop_variants.rb +0 -17
- data/spec/lib/shop/tags/package_spec.rb +0 -342
- data/spec/lib/shop/tags/product_variant_spec.rb +0 -175
- data/spec/lib/shop/tags/responses_spec.rb +0 -129
- data/spec/models/form_discount_spec.rb +0 -63
- data/spec/models/shop_discount_spec.rb +0 -130
- data/spec/models/shop_discountable_spec.rb +0 -114
- data/spec/models/shop_group_spec.rb +0 -38
- data/spec/models/shop_package_spec.rb +0 -117
- data/spec/models/shop_packing_spec.rb +0 -67
- data/spec/models/shop_product_variant_spec.rb +0 -92
- data/spec/models/shop_variant_spec.rb +0 -32
@@ -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
|