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
@@ -1,256 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe Shop::LineItemsController do
|
4
|
-
before :each do
|
5
|
-
request.env["HTTP_REFERER"] = '/back'
|
6
|
-
|
7
|
-
@order = Object.new
|
8
|
-
stub(@order).id { '1' }
|
9
|
-
|
10
|
-
@line_item = Object.new
|
11
|
-
stub(@line_item).id { '1' }
|
12
|
-
|
13
|
-
@attr_hash = {
|
14
|
-
:include => :product,
|
15
|
-
:only => ShopLineItem.params
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#index' do
|
20
|
-
before :each do
|
21
|
-
@line_items = Object.new
|
22
|
-
mock(controller).find_or_create_shop_order.mock!.line_items.mock!.all { @line_items }
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should list all items' do
|
26
|
-
get :index
|
27
|
-
response.should be_success
|
28
|
-
response.should render_template(:index)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should list all items in js' do
|
32
|
-
get :index, :format => 'js'
|
33
|
-
response.should be_success
|
34
|
-
response.should render_template('/shop/line_items/_line_item')
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should list all items in json' do
|
38
|
-
get :index, :format => 'json'
|
39
|
-
response.should be_success
|
40
|
-
response.body.should == @line_items.to_json(@attr_hash)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#show' do
|
45
|
-
before :each do
|
46
|
-
@line_items = Object.new
|
47
|
-
mock(controller).find_or_create_shop_order.mock!.line_items.mock!.find(@line_item.id.to_s) { @line_items }
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should list all items' do
|
51
|
-
get :show, :id => @line_item.id
|
52
|
-
response.should be_success
|
53
|
-
response.should render_template(:show)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should list all items in js' do
|
57
|
-
get :show, :format => 'js', :id => @line_item.id
|
58
|
-
response.should be_success
|
59
|
-
response.should render_template('/shop/line_items/_line_item')
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should list all items in json' do
|
63
|
-
get :show, :format => 'json', :id => @line_item.id
|
64
|
-
response.should be_success
|
65
|
-
response.body.should == @line_item.to_json(@attr_hash)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#create' do
|
70
|
-
context 'success' do
|
71
|
-
context 'defined quantity' do
|
72
|
-
it 'should assign the custom quantity' do
|
73
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, 5, nil) { @line_item }
|
74
|
-
|
75
|
-
post :create, :line_item => { :item_id => 1, :quantity => 5 }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
context 'no quantity defined' do
|
79
|
-
it 'should assign a quantity of 1' do
|
80
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, nil, nil) { @line_item }
|
81
|
-
|
82
|
-
post :create, :line_item => { :item_id => 1}
|
83
|
-
end
|
84
|
-
end
|
85
|
-
context 'defined type' do
|
86
|
-
it 'should redirect back' do
|
87
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, nil, 'ShopPackage') { @line_item }
|
88
|
-
|
89
|
-
post :create, :line_item => { :item_id => 1, :item_type => 'ShopPackage' }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
context 'no type defined' do
|
93
|
-
it 'should not assign a type and redirect back' do
|
94
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, nil, nil) { @line_item }
|
95
|
-
|
96
|
-
post :create, :line_item => { :item_id => 1 }
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'responses' do
|
101
|
-
before :each do
|
102
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, nil, nil) { @line_item }
|
103
|
-
end
|
104
|
-
it 'HTML should assign a notice and redirect' do
|
105
|
-
post :create, :line_item => { :item_id => 1 }
|
106
|
-
|
107
|
-
flash.now[:notice] === 'Item added to Cart.'
|
108
|
-
response.should redirect_to('/back')
|
109
|
-
end
|
110
|
-
it 'JS should list all items in' do
|
111
|
-
post :create, :line_item => { :item_id => 1 }, :format => 'js'
|
112
|
-
|
113
|
-
response.should be_success
|
114
|
-
response.should render_template('/shop/line_items/_line_item')
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'JSON should list all items in' do
|
118
|
-
post :create, :line_item => { :item_id => 1 }, :format => 'json'
|
119
|
-
|
120
|
-
response.should be_success
|
121
|
-
response.body.should === @line_item.to_json(@attr_hash)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'failure' do
|
127
|
-
before :each do
|
128
|
-
mock(controller).find_or_create_shop_order.mock!.add!(1, 1, nil) { raise ActiveRecord::RecordNotSaved }
|
129
|
-
end
|
130
|
-
it 'should list all items' do
|
131
|
-
post :create, :line_item => { :item_id => 1, :quantity => 1 }
|
132
|
-
|
133
|
-
flash.now[:error].should === 'Could not add Item to Cart.'
|
134
|
-
response.should redirect_to('/back')
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'should list all items in js' do
|
138
|
-
post :create, :line_item => { :item_id => 1, :quantity => 1 }, :format => 'js'
|
139
|
-
|
140
|
-
response.should_not be_success
|
141
|
-
response.body.should === 'Could not add Item to Cart.'
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'should list all items in json' do
|
145
|
-
post :create, :line_item => { :item_id => 1, :quantity => 1 }, :format => 'json'
|
146
|
-
|
147
|
-
response.should_not be_success
|
148
|
-
JSON.parse(response.body)['error'].should === 'Could not add Item to Cart.'
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe '#update' do
|
154
|
-
context 'success' do
|
155
|
-
before :each do
|
156
|
-
mock(controller).find_or_create_shop_order.mock!.update!(@line_item.id, 1) { @line_item }
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'should redirect back' do
|
160
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }
|
161
|
-
|
162
|
-
flash.now[:notice].should === 'Item updated successfully.'
|
163
|
-
response.should redirect_to('/back')
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'should list all items in js' do
|
167
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }, :format => 'js'
|
168
|
-
|
169
|
-
response.should be_success
|
170
|
-
response.should render_template('/shop/line_items/_line_item')
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'should list all items in json' do
|
174
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }, :format => 'json'
|
175
|
-
|
176
|
-
response.should be_success
|
177
|
-
response.body.should === @line_item.to_json(@attr_hash)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
context 'failure' do
|
182
|
-
before :each do
|
183
|
-
mock(controller).find_or_create_shop_order.mock!.update!(@line_item.id, 1) { raise ActiveRecord::RecordNotSaved }
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'HTML should list all items' do
|
187
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }
|
188
|
-
flash.now[:error].should === 'Could not update Item.'
|
189
|
-
response.should redirect_to('/back')
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'JS should list all items' do
|
193
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }, :format => 'js'
|
194
|
-
response.should_not be_success
|
195
|
-
response.body.should === 'Could not update Item.'
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'JSON should list all items' do
|
199
|
-
put :update, :id => 'x', :line_item => { :id => @line_item.id }, :format => 'json'
|
200
|
-
response.should_not be_success
|
201
|
-
JSON.parse(response.body)['error'].should === 'Could not update Item.'
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe '#destroy' do
|
207
|
-
context 'success' do
|
208
|
-
before :each do
|
209
|
-
mock(controller).find_or_create_shop_order.mock!.remove!(@line_item.id) { true }
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'should redirect back' do
|
213
|
-
delete :destroy, :id => @line_item.id
|
214
|
-
flash.now[:notice].should === 'Item removed from Cart.'
|
215
|
-
response.should redirect_to('/back')
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'should list all items in js' do
|
219
|
-
delete :destroy, :id => @line_item.id, :format => 'js'
|
220
|
-
response.should be_success
|
221
|
-
response.body.should === 'Item removed from Cart.'
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'should list all items in json' do
|
225
|
-
delete :destroy, :id => @line_item.id, :format => 'json'
|
226
|
-
response.should be_success
|
227
|
-
JSON.parse(response.body)['notice'].should === 'Item removed from Cart.'
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
context 'failure' do
|
232
|
-
before :each do
|
233
|
-
mock(controller).find_or_create_shop_order.mock!.remove!(@line_item.id.to_s) { raise ActiveRecord::RecordNotFound }
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'should list all items' do
|
237
|
-
delete :destroy, :id => @line_item.id
|
238
|
-
flash.now[:error].should === 'Could not remove Item from Cart.'
|
239
|
-
response.should redirect_to('/back')
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'should list all items in js' do
|
243
|
-
delete :destroy, :format => 'js', :id => @line_item.id
|
244
|
-
response.should_not be_success
|
245
|
-
response.body.should === 'Could not remove Item from Cart.'
|
246
|
-
end
|
247
|
-
|
248
|
-
it 'should list all items in json' do
|
249
|
-
delete :destroy, :format => 'json', :id => @line_item.id
|
250
|
-
response.should_not be_success
|
251
|
-
JSON.parse(response.body)['error'].should === 'Could not remove Item from Cart.'
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe Shop::OrdersController do
|
4
|
-
|
5
|
-
dataset :shop_orders
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@order = shop_orders(:one_item)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#finalize' do
|
12
|
-
context 'paid order' do
|
13
|
-
it 'should redirect to the thanks page' do
|
14
|
-
stub(@order).new? { false }
|
15
|
-
mock(controller).current_shop_order { @order }
|
16
|
-
|
17
|
-
get :finalize
|
18
|
-
|
19
|
-
response.should redirect_to("/#{Radiant::Config['shop.cart_thanks_path']}")
|
20
|
-
end
|
21
|
-
it 'should set the session shop_order to nil'
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'new order' do
|
25
|
-
it 'should redirect to the cart page' do
|
26
|
-
stub(@order).new? { true }
|
27
|
-
mock(controller).current_shop_order { @order }
|
28
|
-
|
29
|
-
get :finalize
|
30
|
-
|
31
|
-
response.should redirect_to("/#{Radiant::Config['shop.cart_path']}")
|
32
|
-
end
|
33
|
-
it 'should not touch the session shop_order'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe Shop::ProductsController do
|
4
|
-
before(:each) do
|
5
|
-
@shop_product = ShopProduct.new
|
6
|
-
@shop_category = ShopCategory.new
|
7
|
-
|
8
|
-
stub(@shop_product).sku { 'a' }
|
9
|
-
stub(@shop_product).name { 'Bob' }
|
10
|
-
stub(@shop_product).category { @shop_category }
|
11
|
-
|
12
|
-
stub(@shop_category).handle { 'b' }
|
13
|
-
stub(@shop_category).product_layout.stub!.name { 'Layout' }
|
14
|
-
|
15
|
-
@shop_products = [ @shop_product ]
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#index' do
|
19
|
-
it 'should expose products list' do
|
20
|
-
mock(ShopProduct).search(nil) { @shop_products }
|
21
|
-
get :index
|
22
|
-
|
23
|
-
response.should be_success
|
24
|
-
assigns(:shop_products).should === @shop_products
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#show' do
|
29
|
-
it 'should expose product' do
|
30
|
-
mock(ShopProduct).find(:first, :conditions => { :sku => @shop_product.sku }) { @shop_product }
|
31
|
-
|
32
|
-
get :show, :sku => @shop_product.sku, :handle => @shop_category.handle
|
33
|
-
|
34
|
-
response.should be_success
|
35
|
-
assigns(:shop_product).should === @shop_product
|
36
|
-
assigns(:shop_category).should == @shop_product.category
|
37
|
-
assigns(:radiant_layout).should == 'Layout'
|
38
|
-
assigns(:title).should === 'Bob'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'should return 404 if product empty' do
|
42
|
-
mock(ShopProduct).find(:first, :conditions => { :sku => @shop_product.sku }) { false }
|
43
|
-
|
44
|
-
get :show, :sku => @shop_product.sku, :handle => @shop_category.handle
|
45
|
-
|
46
|
-
response.should render_template('site/not_found')
|
47
|
-
response.should_not be_success
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,65 +0,0 @@
|
|
1
|
-
= JSON-Stored Fields
|
2
|
-
|
3
|
-
Allows for a group of "unimportant" fields to be stored as a JSON hash, rather than as real database columns.
|
4
|
-
|
5
|
-
This is useful in cases where you have many classes inheriting from a base class, but with drastically different fields which would clutter up the database.
|
6
|
-
|
7
|
-
Obviously this prevents you from searching for these records based upon this data.
|
8
|
-
|
9
|
-
However, it does enable you to dynamically add and remove fields from your models at runtime. For example, you can allow the user to specify extra fields for a model, and then get and set them at runtime using json_field_get() and json_field_set().
|
10
|
-
|
11
|
-
== Installation
|
12
|
-
|
13
|
-
ruby script/plugin install git://github.com/aurorasoft/json_fields.git
|
14
|
-
|
15
|
-
== Usage
|
16
|
-
|
17
|
-
Fields are defined using the following syntax :
|
18
|
-
|
19
|
-
has_json_field :field1, :field2, :field3
|
20
|
-
|
21
|
-
These fields can then be accessed as per usual, but are stored as a JSON hash in the "json_field" column (which you will need to add as a :text field).
|
22
|
-
|
23
|
-
Example for migration:
|
24
|
-
add_column :pages, :json_field, :text
|
25
|
-
|
26
|
-
If you don't like the field named "json_field", you can change it using :
|
27
|
-
|
28
|
-
set_json_field :another_field_here
|
29
|
-
|
30
|
-
Then, all data will be stored in the specified field.
|
31
|
-
|
32
|
-
== Example
|
33
|
-
|
34
|
-
An entirely contrived example:
|
35
|
-
|
36
|
-
class TestBase < ActiveRecord::Base
|
37
|
-
end
|
38
|
-
|
39
|
-
class SimpleTest < TestBase
|
40
|
-
has_json_field :your_name, :your_quest, :your_favourite_colour
|
41
|
-
end
|
42
|
-
|
43
|
-
class ComplexTest < TestBase
|
44
|
-
has_json_field :square_root_of_pi, :distance_to_moon_in_meters
|
45
|
-
end
|
46
|
-
|
47
|
-
class ImpossibleTest < TestBase
|
48
|
-
has_json_field :air_speed_velocity_of_an_unladen_swallow
|
49
|
-
end
|
50
|
-
|
51
|
-
== Runtime-Defined Fields
|
52
|
-
|
53
|
-
In cases where you need to dynamically add and use fields at runtime (eg. custom fields) you can also set and get arbitrary fields using:
|
54
|
-
|
55
|
-
json_field_get(:field_name, 'foo') # => "foo"
|
56
|
-
json_field_get(:field_name) # => "foo"
|
57
|
-
|
58
|
-
== Caveats
|
59
|
-
|
60
|
-
* Internally we use .to_json, which means that symbols will be converted to strings. As such, you may need to take care.
|
61
|
-
* Any Rails code handling whether the instance has changed will likely not report changes to the JSON fields.
|
62
|
-
|
63
|
-
== Licensing
|
64
|
-
|
65
|
-
Copyright (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au), released under the MIT license
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/rdoctask'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
require 'spec/rake/spectask'
|
6
|
-
|
7
|
-
plugin_root = File.expand_path(File.dirname(__FILE__))
|
8
|
-
|
9
|
-
task :default => :spec
|
10
|
-
task :stats => "spec:statsetup"
|
11
|
-
|
12
|
-
desc "Run all specs in spec directory"
|
13
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
14
|
-
t.spec_opts = ['--options', "\"#{plugin_root}/spec/spec.opts\""]
|
15
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
16
|
-
end
|
17
|
-
|
18
|
-
namespace :spec do
|
19
|
-
desc "Run all specs in spec directory with RCov"
|
20
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
21
|
-
t.spec_opts = ['--options', "\"#{plugin_root}/spec/spec.opts\""]
|
22
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
23
|
-
t.rcov = true
|
24
|
-
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "Print Specdoc for all specs"
|
28
|
-
Spec::Rake::SpecTask.new(:doc) do |t|
|
29
|
-
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
30
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
-
end
|
32
|
-
|
33
|
-
[:models, :controllers, :views, :helpers].each do |sub|
|
34
|
-
desc "Run the specs under spec/#{sub}"
|
35
|
-
Spec::Rake::SpecTask.new(sub) do |t|
|
36
|
-
t.spec_opts = ['--options', "\"#{plugin_root}/spec/spec.opts\""]
|
37
|
-
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
namespace :db do
|
42
|
-
namespace :fixtures do
|
43
|
-
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
44
|
-
task :load => :environment do
|
45
|
-
require 'active_record/fixtures'
|
46
|
-
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
47
|
-
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
48
|
-
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
#Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|