radiant-shop-extension 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -1
- data/VERSION +1 -1
- data/app/controllers/admin/shop/categories_controller.rb +32 -65
- data/app/controllers/admin/shop/customers_controller.rb +8 -7
- data/app/controllers/admin/shop/orders_controller.rb +37 -159
- data/app/controllers/admin/shop/packages/packings_controller.rb +90 -0
- data/app/controllers/admin/shop/packages_controller.rb +65 -0
- data/app/controllers/admin/shop/products/images_controller.rb +5 -8
- data/app/controllers/admin/shop/products/variant_templates_controller.rb +27 -0
- data/app/controllers/admin/shop/products/variants_controller.rb +60 -0
- data/app/controllers/admin/shop/products_controller.rb +67 -64
- data/app/controllers/admin/shop/variants_controller.rb +49 -0
- data/app/helpers/shop_helper.rb +5 -0
- data/app/models/form_address.rb +144 -0
- data/app/models/form_checkout.rb +200 -307
- data/app/models/form_line_item.rb +60 -0
- data/app/models/shop_address.rb +2 -2
- data/app/models/shop_category.rb +48 -51
- data/app/models/shop_customer.rb +25 -5
- data/app/models/shop_group.rb +15 -0
- data/app/models/shop_grouping.rb +6 -0
- data/app/models/shop_line_item.rb +7 -6
- data/app/models/shop_order.rb +44 -16
- data/app/models/shop_package.rb +74 -0
- data/app/models/shop_packing.rb +22 -0
- data/app/models/shop_page.rb +7 -0
- data/app/models/shop_payment.rb +5 -1
- data/app/models/shop_product.rb +86 -48
- data/app/models/shop_product_attachment.rb +5 -2
- data/app/models/shop_product_variant.rb +31 -0
- data/app/models/shop_variant.rb +25 -0
- data/app/views/admin/shop/categories/edit.html.haml +9 -10
- data/app/views/admin/shop/categories/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_form.html.haml +14 -0
- data/app/views/admin/shop/categories/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/categories/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/categories/edit/_meta.html.haml +8 -7
- data/app/views/admin/shop/categories/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/categories/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +6 -5
- data/app/views/admin/shop/categories/edit/meta/_page.html.haml +3 -0
- data/app/views/admin/shop/categories/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/categories/index/_category.html.haml +11 -10
- data/app/views/admin/shop/categories/new.html.haml +10 -9
- data/app/views/admin/shop/customers/edit.html.haml +8 -10
- data/app/views/admin/shop/customers/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/customers/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/customers/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/customers/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/customers/edit/_parts.html.haml +9 -4
- data/app/views/admin/shop/customers/edit/inputs/_email.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/customers/edit/parts/_orders.html.haml +10 -6
- data/app/views/admin/shop/customers/index.html.haml +4 -1
- data/app/views/admin/shop/customers/index/_customer.html.haml +3 -3
- data/app/views/admin/shop/customers/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/customers/index/_head.html.haml +4 -0
- data/app/views/admin/shop/customers/new.html.haml +9 -9
- data/app/views/admin/shop/orders/edit.html.haml +11 -0
- data/app/views/admin/shop/orders/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/orders/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/orders/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/orders/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/orders/edit/parts/_address.html.haml +7 -0
- data/app/views/admin/shop/orders/edit/parts/_addresses.html.haml +9 -0
- data/app/views/admin/shop/orders/edit/parts/_customer.html.haml +3 -0
- data/app/views/admin/shop/orders/edit/parts/_items.html.haml +8 -0
- data/app/views/admin/shop/orders/index.html.haml +10 -30
- data/app/views/admin/shop/orders/index/_foot.html.haml +3 -0
- data/app/views/admin/shop/orders/index/_head.html.haml +4 -0
- data/app/views/admin/shop/orders/index/_order.html.haml +13 -0
- data/app/views/admin/shop/orders/index/buttons/_all.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_new.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_paid.html.haml +1 -0
- data/app/views/admin/shop/orders/index/buttons/_shipped.html.haml +1 -0
- data/app/views/admin/shop/packages/edit.html.haml +11 -0
- data/app/views/admin/shop/packages/edit/_foot.html.haml +17 -0
- data/app/views/admin/shop/packages/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/packages/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/packages/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/packages/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/packages/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +5 -0
- data/app/views/admin/shop/packages/edit/parts/_description.html.haml +1 -0
- data/app/views/admin/shop/packages/edit/parts/_products.html.haml +3 -0
- data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +7 -0
- data/app/views/admin/shop/packages/edit/shared/_product.html.haml +8 -0
- data/app/views/admin/shop/packages/index.html.haml +13 -0
- data/app/views/admin/shop/packages/index/_foot.html.haml +7 -0
- data/app/views/admin/shop/packages/index/_head.html.haml +4 -0
- data/app/views/admin/shop/packages/index/_package.html.haml +9 -0
- data/app/views/admin/shop/packages/new.html.haml +11 -0
- data/app/views/admin/shop/packages/remove.html.haml +12 -0
- data/app/views/admin/shop/products/edit.html.haml +9 -12
- data/app/views/admin/shop/products/edit/_foot.html.haml +19 -0
- data/app/views/admin/shop/products/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/products/edit/_head.html.haml +4 -2
- data/app/views/admin/shop/products/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/products/edit/_meta.html.haml +8 -8
- data/app/views/admin/shop/products/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/products/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_browse_templates.html.haml +1 -0
- data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -1
- data/app/views/admin/shop/products/edit/buttons/_new_variant.html.haml +1 -0
- data/app/views/admin/shop/products/edit/inputs/_name.html.haml +4 -0
- data/app/views/admin/shop/products/edit/inputs/_price.html.haml +3 -0
- data/app/views/admin/shop/products/edit/meta/_category.html.haml +6 -5
- data/app/views/admin/shop/products/edit/meta/_page.html.haml +2 -0
- data/app/views/admin/shop/products/edit/meta/_sku.html.haml +6 -5
- data/app/views/admin/shop/products/edit/parts/_customers.html.haml +5 -0
- data/app/views/admin/shop/products/edit/parts/_description.html.haml +4 -1
- data/app/views/admin/shop/products/edit/parts/_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/parts/_variants.html.haml +3 -0
- data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +1 -1
- data/app/views/admin/shop/products/edit/popups/_browse_templates.html.haml +6 -0
- data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +4 -4
- data/app/views/admin/shop/products/edit/popups/_new_variant.html.haml +16 -0
- data/app/views/admin/shop/products/edit/{_image.html.haml → shared/_image.html.haml} +0 -0
- data/app/views/admin/shop/products/edit/shared/_template.html.haml +6 -0
- data/app/views/admin/shop/products/edit/shared/_variant.html.haml +10 -0
- data/app/views/admin/shop/products/index.html.haml +6 -3
- data/app/views/admin/shop/products/index/_foot.html.haml +10 -0
- data/app/views/admin/shop/products/index/_head.html.haml +4 -0
- data/app/views/admin/shop/products/index/_product.html.haml +18 -10
- data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_packages.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -0
- data/app/views/admin/shop/products/new.html.haml +10 -9
- data/app/views/admin/shop/variants/edit.html.haml +11 -0
- data/app/views/admin/shop/variants/edit/_foot.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_form.html.haml +13 -0
- data/app/views/admin/shop/variants/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/variants/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/variants/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/variants/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/variants/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/variants/edit/inputs/_options.html.haml +3 -0
- data/app/views/admin/shop/variants/index.html.haml +13 -0
- data/app/views/admin/shop/variants/index/_foot.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_head.html.haml +4 -0
- data/app/views/admin/shop/variants/index/_variant.html.haml +9 -0
- data/app/views/admin/shop/variants/new.html.haml +11 -0
- data/app/views/admin/shop/variants/remove.html.haml +12 -0
- data/config/locales/en.yml +8 -1
- data/config/routes.rb +11 -22
- data/db/migrate/20100929011106_fix_relationship_foreign_keys.rb +101 -0
- data/db/migrate/20100929011607_drop_shop_addressables.rb +25 -0
- data/db/migrate/20100929030510_create_shop_groups.rb +19 -0
- data/db/migrate/20100929080301_shop_groups_change_add_description.rb +11 -0
- data/db/migrate/20100929081200_create_variants.rb +20 -0
- data/db/migrate/20100929143531_change_variants_add_updated_by.rb +25 -0
- data/db/migrate/20100929145641_change_created_by_to_id.rb +75 -0
- data/db/migrate/20100929235221_change_category_add_variant_id.rb +9 -0
- data/db/migrate/20100930235221_create_packages.rb +31 -0
- data/db/migrate/20101005231713_create_page_ids.rb +11 -0
- data/db/migrate/20101006051214_create_pages_for_products_and_categories.rb +73 -0
- data/db/migrate/20101007111845_add_default_position_to_attachment.rb +9 -0
- data/lib/shop/controllers/application_controller.rb +1 -1
- data/lib/shop/interface/categories.rb +29 -0
- data/lib/shop/interface/customers.rb +15 -15
- data/lib/shop/interface/orders.rb +34 -0
- data/lib/shop/interface/packages.rb +34 -0
- data/lib/shop/interface/products.rb +18 -31
- data/lib/shop/interface/variants.rb +34 -0
- data/lib/shop/models/form_extension.rb +23 -0
- data/lib/shop/models/page.rb +3 -2
- data/lib/shop/tags/address.rb +3 -3
- data/lib/shop/tags/cart.rb +12 -16
- data/lib/shop/tags/category.rb +4 -6
- data/lib/shop/tags/helpers.rb +131 -30
- data/lib/shop/tags/item.rb +16 -33
- data/lib/shop/tags/package.rb +95 -0
- data/lib/shop/tags/product.rb +11 -16
- data/lib/shop/tags/product_variant.rb +52 -0
- data/mockups/discounts/new-edit.bmml +492 -0
- data/public/javascripts/admin/extensions/shop/edit.js +20 -0
- data/public/javascripts/admin/extensions/shop/packages/edit.js +109 -0
- data/public/javascripts/admin/extensions/shop/products/edit.js +64 -65
- data/public/javascripts/admin/extensions/shop/products/index.js +31 -36
- data/public/stylesheets/sass/admin/extensions/shop/edit.sass +58 -11
- data/public/stylesheets/sass/admin/extensions/shop/index.sass +104 -53
- data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +162 -0
- data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +115 -36
- data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +12 -20
- data/radiant-shop-extension.gemspec +182 -38
- data/shop_extension.rb +29 -25
- data/spec/controllers/admin/shop/categories_controller_spec.rb +76 -191
- data/spec/controllers/admin/shop/customers_controller_spec.rb +67 -0
- data/spec/controllers/admin/shop/orders_controller_spec.rb +85 -0
- data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +188 -0
- data/spec/controllers/admin/shop/packages_controller_spec.rb +32 -0
- data/spec/controllers/admin/shop/products/images_controller_spec.rb +10 -15
- data/spec/controllers/admin/shop/products/variant_templates_controller_spec.rb +53 -0
- data/spec/controllers/admin/shop/products/variants_controller_spec.rb +116 -0
- data/spec/controllers/admin/shop/products_controller_spec.rb +80 -148
- data/spec/controllers/admin/shop/variants_controller_spec.rb +67 -0
- data/spec/datasets/forms.rb +23 -8
- data/spec/datasets/shop_addresses.rb +1 -4
- data/spec/datasets/shop_categories.rb +25 -4
- data/spec/datasets/shop_groups.rb +15 -0
- data/spec/datasets/shop_line_items.rb +4 -3
- data/spec/datasets/shop_orders.rb +6 -15
- data/spec/datasets/shop_packages.rb +25 -0
- data/spec/datasets/shop_payments.rb +12 -0
- data/spec/datasets/{images.rb → shop_product_attachments.rb} +9 -1
- data/spec/datasets/shop_product_variants.rb +22 -0
- data/spec/datasets/shop_products.rb +28 -18
- data/spec/datasets/shop_variants.rb +17 -0
- data/spec/lib/shop/models/image_spec.rb +4 -4
- data/spec/lib/shop/tags/address_spec.rb +3 -3
- data/spec/lib/shop/tags/cart_spec.rb +32 -43
- data/spec/lib/shop/tags/category_spec.rb +58 -93
- data/spec/lib/shop/tags/helpers_spec.rb +162 -69
- data/spec/lib/shop/tags/item_spec.rb +116 -158
- data/spec/lib/shop/tags/package_spec.rb +342 -0
- data/spec/lib/shop/tags/product_spec.rb +29 -26
- data/spec/lib/shop/tags/product_variant_spec.rb +175 -0
- data/spec/models/form_address_spec.rb +166 -0
- data/spec/models/form_checkout_spec.rb +27 -157
- data/spec/models/shop_address_spec.rb +81 -0
- data/spec/models/shop_category_spec.rb +114 -31
- data/spec/models/shop_customer_spec.rb +105 -0
- data/spec/models/shop_group_spec.rb +38 -0
- data/spec/models/shop_line_item_spec.rb +5 -5
- data/spec/models/shop_order_spec.rb +89 -83
- data/spec/models/shop_package_spec.rb +117 -0
- data/spec/models/shop_packing_spec.rb +67 -0
- data/spec/models/shop_payment_spec.rb +19 -0
- data/spec/models/shop_product_attachment_spec.rb +4 -3
- data/spec/models/shop_product_spec.rb +171 -92
- data/spec/models/shop_product_variant_spec.rb +92 -0
- data/spec/models/shop_variant_spec.rb +47 -0
- metadata +183 -39
- data/app/controllers/shop/categories_controller.rb +0 -45
- data/app/controllers/shop/line_items_controller.rb +0 -165
- data/app/controllers/shop/orders_controller.rb +0 -16
- data/app/controllers/shop/products_controller.rb +0 -48
- data/app/models/shop_addressable.rb +0 -11
- data/app/views/admin/shop/categories/edit/_fields.html.haml +0 -28
- data/app/views/admin/shop/categories/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/categories/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/customers/edit/_fields.html.haml +0 -33
- data/app/views/admin/shop/customers/index/_bottom.html.haml +0 -4
- data/app/views/admin/shop/products/edit/_fields.html.haml +0 -38
- data/app/views/admin/shop/products/edit/_part.html.haml +0 -3
- data/app/views/admin/shop/products/edit/_popup.html.haml +0 -3
- data/app/views/admin/shop/products/index/_bottom.html.haml +0 -5
- data/spec/controllers/shop/categories_controller_spec.rb +0 -42
- data/spec/controllers/shop/line_items_controller_spec.rb +0 -256
- data/spec/controllers/shop/orders_controller_specs.rb +0 -37
- data/spec/controllers/shop/products_controller_spec.rb +0 -51
- data/vendor/plugins/json_fields/.gitignore +0 -3
- data/vendor/plugins/json_fields/MIT-LICENSE +0 -20
- data/vendor/plugins/json_fields/README.rdoc +0 -65
- data/vendor/plugins/json_fields/Rakefile +0 -55
- data/vendor/plugins/json_fields/init.rb +0 -2
- data/vendor/plugins/json_fields/lib/json_fields.rb +0 -99
- data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +0 -124
- data/vendor/plugins/json_fields/spec/spec.opts +0 -6
- data/vendor/plugins/json_fields/spec/spec_helper.rb +0 -29
- data/vendor/plugins/json_fields/spec/test_models.rb +0 -12
@@ -0,0 +1,67 @@
|
|
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
|
data/spec/datasets/forms.rb
CHANGED
@@ -89,7 +89,7 @@ CONFIG
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def mock_valid_form_checkout_request
|
92
|
-
@form
|
92
|
+
@form = forms(:checkout)
|
93
93
|
@form[:extensions] = {
|
94
94
|
:checkout => {
|
95
95
|
:test => true,
|
@@ -112,6 +112,27 @@ CONFIG
|
|
112
112
|
:year => 2012,
|
113
113
|
:type => 'visa'
|
114
114
|
},
|
115
|
+
:options => {
|
116
|
+
:address => {
|
117
|
+
:address1 => 'address',
|
118
|
+
:zip => 'zip'
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
@request.session = { :shop_order => @order.id }
|
124
|
+
end
|
125
|
+
|
126
|
+
def mock_valid_form_address_request
|
127
|
+
@form = forms(:checkout)
|
128
|
+
@form[:extensions] = {
|
129
|
+
:address => {
|
130
|
+
:billing => true,
|
131
|
+
:shipping => true
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
@data = {
|
115
136
|
:billing => {
|
116
137
|
:id => shop_addresses(:billing).id,
|
117
138
|
:name => shop_addresses(:billing).name,
|
@@ -131,15 +152,9 @@ CONFIG
|
|
131
152
|
:state => shop_addresses(:shipping).state,
|
132
153
|
:country => shop_addresses(:shipping).country,
|
133
154
|
:postcode => shop_addresses(:shipping).postcode
|
134
|
-
},
|
135
|
-
:options => {
|
136
|
-
:address => {
|
137
|
-
:address1 => 'address',
|
138
|
-
:zip => 'zip'
|
139
|
-
}
|
140
155
|
}
|
141
156
|
}
|
142
|
-
|
157
|
+
|
143
158
|
@request.session = { :shop_order => @order.id }
|
144
159
|
end
|
145
160
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
class ShopAddressesDataset < Dataset::Base
|
2
2
|
def load
|
3
|
-
|
4
3
|
# TODO Investigate why inflectors are breaking here
|
5
|
-
|
6
4
|
create_record :shop_addresss, :billing,
|
7
5
|
:name => 'Billing Address',
|
8
6
|
:email => 'billing@address.com',
|
@@ -21,7 +19,6 @@ class ShopAddressesDataset < Dataset::Base
|
|
21
19
|
:city => 'Shipvilles',
|
22
20
|
:state => 'SH',
|
23
21
|
:country=> 'Shippington',
|
24
|
-
:postcode=> '
|
25
|
-
|
22
|
+
:postcode=> '1234'
|
26
23
|
end
|
27
24
|
end
|
@@ -1,12 +1,33 @@
|
|
1
1
|
class ShopCategoriesDataset < Dataset::Base
|
2
|
+
|
3
|
+
uses :shop_variants, :pages
|
4
|
+
|
2
5
|
def load
|
3
6
|
categories = [:bread, :milk, :salad]
|
4
7
|
|
5
|
-
|
8
|
+
create_record :layout, :category,
|
9
|
+
:name => 'category'
|
10
|
+
|
11
|
+
create_record :layout, :product,
|
12
|
+
:name => 'product'
|
13
|
+
|
14
|
+
categories.each_with_index do |category, i|
|
15
|
+
create_record :page, category,
|
16
|
+
:title => category.to_s,
|
17
|
+
:slug => category.to_s,
|
18
|
+
:breadcrumb => category.to_s,
|
19
|
+
:parent => Page.first,
|
20
|
+
:class_name => 'ShopCategoryPage',
|
21
|
+
:layout => layouts(:category)
|
22
|
+
|
6
23
|
create_record :shop_category, category,
|
7
|
-
:
|
8
|
-
:
|
9
|
-
|
24
|
+
:product_layout => layouts(:product),
|
25
|
+
:page => pages(category).id
|
26
|
+
|
27
|
+
create_record :page_part, category,
|
28
|
+
:name => 'description',
|
29
|
+
:content => "*#{category.to_s}*",
|
30
|
+
:page => pages(category)
|
10
31
|
end
|
11
32
|
|
12
33
|
end
|
@@ -0,0 +1,15 @@
|
|
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,9 +1,10 @@
|
|
1
1
|
class ShopLineItemsDataset < Dataset::Base
|
2
2
|
|
3
|
-
uses :shop_products
|
3
|
+
uses :shop_products, :shop_orders
|
4
4
|
|
5
5
|
def load
|
6
|
-
create_record :shop_line_item, :one,
|
7
|
-
create_record :shop_line_item, :two,
|
6
|
+
create_record :shop_line_item, :one, :item_id => shop_products(:crusty_bread).id, :order => shop_orders(:one_item), :item_type => 'ShopProduct'
|
7
|
+
create_record :shop_line_item, :two, :item_id => shop_products(:soft_bread).id, :order => shop_orders(:several_items), :item_type => 'ShopProduct', :quantity => 2
|
8
|
+
create_record :shop_line_item, :three, :item_id => shop_products(:choc_milk).id, :order => shop_orders(:several_items), :item_type => 'ShopProduct', :quantity => 3
|
8
9
|
end
|
9
10
|
end
|
@@ -4,22 +4,13 @@ class ShopOrdersDataset < Dataset::Base
|
|
4
4
|
|
5
5
|
def load
|
6
6
|
create_record :shop_order, :empty
|
7
|
+
|
7
8
|
create_record :shop_order, :one_item,
|
8
|
-
:customer
|
9
|
+
:customer => shop_customers(:customer)
|
10
|
+
|
9
11
|
create_record :shop_order, :several_items,
|
10
|
-
:customer
|
11
|
-
:billing
|
12
|
-
:shipping
|
13
|
-
|
14
|
-
create_record :shop_line_item, :crusty_bread, :item_id => shop_products(:crusty_bread).id, :item_type => 'ShopProduct'
|
15
|
-
create_record :shop_line_item, :soft_bread, :item_id => shop_products(:soft_bread).id, :item_type => 'ShopProduct'
|
16
|
-
create_record :shop_line_item, :choc_milk, :item_id => shop_products(:choc_milk).id, :item_type => 'ShopProduct'
|
17
|
-
create_record :shop_line_item, :full_milk, :item_id => shop_products(:full_milk).id, :item_type => 'ShopProduct'
|
18
|
-
|
19
|
-
shop_orders(:one_item).line_items << shop_line_items(:crusty_bread)
|
20
|
-
|
21
|
-
shop_orders(:several_items).line_items << shop_line_items(:soft_bread)
|
22
|
-
shop_orders(:several_items).line_items << shop_line_items(:choc_milk)
|
23
|
-
shop_orders(:several_items).line_items << shop_line_items(:full_milk)
|
12
|
+
:customer => shop_customers(:customer),
|
13
|
+
:billing => shop_addresses(:billing),
|
14
|
+
:shipping => shop_addresses(:shipping)
|
24
15
|
end
|
25
16
|
end
|
@@ -0,0 +1,25 @@
|
|
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
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ShopPaymentsDataset < Dataset::Base
|
2
|
+
|
3
|
+
uses :shop_orders
|
4
|
+
|
5
|
+
def load
|
6
|
+
create_record :shop_payments, :visa,
|
7
|
+
:amount => shop_orders(:several_items).price,
|
8
|
+
:card_type => 'visa',
|
9
|
+
:card_number => 'xxxx-xxxx-xxxx-1234',
|
10
|
+
:order_id => shop_orders(:several_items).id
|
11
|
+
end
|
12
|
+
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
class
|
1
|
+
class ShopProductAttachmentsDataset < Dataset::Base
|
2
|
+
|
3
|
+
uses :shop_products
|
4
|
+
|
2
5
|
def load
|
3
6
|
images = [ :soft_bread_front, :soft_bread_back, :soft_bread_top, :crusty_bread_front, :warm_bread_front ]
|
4
7
|
|
@@ -8,6 +11,11 @@ class ImagesDataset < Dataset::Base
|
|
8
11
|
:asset_file_name => "#{image.to_s}_file_name.png",
|
9
12
|
:asset_content_type => "image/png",
|
10
13
|
:asset_file_size => i+1*1000
|
14
|
+
|
15
|
+
create_record :shop_product_attachment, image,
|
16
|
+
:image => images(image.to_sym),
|
17
|
+
:product => shop_products(image.to_s.split('_')[0,2].join('_').to_sym),
|
18
|
+
:position => i + 1
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
@@ -0,0 +1,22 @@
|
|
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,6 +1,6 @@
|
|
1
1
|
class ShopProductsDataset < Dataset::Base
|
2
2
|
|
3
|
-
uses :shop_categories
|
3
|
+
uses :shop_categories
|
4
4
|
|
5
5
|
def load
|
6
6
|
categories = {
|
@@ -10,26 +10,36 @@ class ShopProductsDataset < Dataset::Base
|
|
10
10
|
|
11
11
|
categories.each do |category, products|
|
12
12
|
products.each_with_index do |product, i|
|
13
|
+
create_record :page, product,
|
14
|
+
:title => "#{product.to_s} #{category.to_s}",
|
15
|
+
:slug => "#{product.to_s}_#{category.to_s}",
|
16
|
+
:breadcrumb => "#{product.to_s}_#{category.to_s}",
|
17
|
+
:parent => shop_categories(category).page,
|
18
|
+
:class_name => 'ShopProductPage',
|
19
|
+
:layout => layouts(:product)
|
20
|
+
|
13
21
|
create_record :shop_product, "#{product.to_s}_#{category.to_s}".to_sym,
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
|
18
|
-
|
19
|
-
:
|
20
|
-
:
|
22
|
+
:price => i + 1 * 10,
|
23
|
+
:weight => i + 2 * 10,
|
24
|
+
:page => pages(product).id
|
25
|
+
|
26
|
+
create_record :page_part, product,
|
27
|
+
:name => 'description',
|
28
|
+
:content => "*#{product.to_s} #{category.to_s}*",
|
29
|
+
:page => pages(product)
|
30
|
+
|
31
|
+
create_record :image, product,
|
32
|
+
:title => product,
|
33
|
+
:asset_file_name => product,
|
34
|
+
:asset_content_type => 'image/png',
|
35
|
+
:asset_file_size => i + 1 * 10
|
36
|
+
|
37
|
+
create_record :shop_product_attachment, product,
|
38
|
+
:image => images(product),
|
39
|
+
:product => shop_products("#{product.to_s}_#{category.to_s}".to_sym),
|
40
|
+
:position => 1
|
21
41
|
end
|
22
42
|
end
|
23
|
-
|
24
|
-
shop_products(:soft_bread).images = [
|
25
|
-
images(:soft_bread_front),
|
26
|
-
images(:soft_bread_back),
|
27
|
-
images(:soft_bread_top)
|
28
|
-
]
|
29
|
-
|
30
|
-
shop_products(:crusty_bread).images << images(:crusty_bread_front)
|
31
|
-
|
32
|
-
shop_products(:warm_bread).images << images(:warm_bread_front)
|
33
43
|
end
|
34
44
|
|
35
45
|
end
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec/spec_helper'
|
2
2
|
|
3
3
|
#
|
4
|
-
# Tests for
|
4
|
+
# Tests for image model extensions
|
5
5
|
#
|
6
6
|
describe Shop::Models::Image do
|
7
7
|
|
8
|
-
dataset :
|
8
|
+
dataset :shop_products, :shop_product_attachments
|
9
9
|
|
10
10
|
before :each do
|
11
11
|
@image = images(:soft_bread_front)
|
@@ -13,8 +13,8 @@ describe Shop::Models::Image do
|
|
13
13
|
|
14
14
|
context 'relationships' do
|
15
15
|
|
16
|
-
describe '
|
17
|
-
it 'should accept and return a
|
16
|
+
describe 'product' do
|
17
|
+
it 'should accept and return a product object' do
|
18
18
|
@shop_product = shop_products(:soft_bread)
|
19
19
|
|
20
20
|
@image.shop_products << @shop_product
|
@@ -30,7 +30,7 @@ describe Shop::Tags::Address do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
before :each do
|
33
|
-
@order = shop_orders(:
|
33
|
+
@order = shop_orders(:several_items)
|
34
34
|
@billing = shop_addresses(:billing)
|
35
35
|
mock(Shop::Tags::Helpers).current_order(anything) { @order }
|
36
36
|
end
|
@@ -81,8 +81,8 @@ describe Shop::Tags::Address do
|
|
81
81
|
it 'should not expand' do
|
82
82
|
stub(@order).billing { nil }
|
83
83
|
|
84
|
-
tag = %{<r:shop:cart:address type='billing'><r:unless_address>
|
85
|
-
exp = %{
|
84
|
+
tag = %{<r:shop:cart:address type='billing'><r:unless_address>failure</r:unless_address></r:shop:cart:address>}
|
85
|
+
exp = %{}
|
86
86
|
|
87
87
|
@page.should render(tag).as(exp)
|
88
88
|
end
|