radiant-shop-extension 0.92.1 → 0.92.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/app/models/shop_order.rb +5 -0
- data/app/models/shop_product.rb +1 -1
- data/lib/shop/controllers/application_controller.rb +6 -14
- data/lib/shop/tags/cart.rb +1 -0
- data/lib/shop/tags/category.rb +4 -2
- data/radiant-shop-extension.gemspec +2 -2
- data/spec/controllers/admin/shop/customers_controller_spec.rb +20 -20
- data/spec/controllers/admin/shop/orders_controller_spec.rb +30 -30
- data/spec/datasets/shop_customers.rb +1 -1
- data/spec/datasets/shop_orders.rb +3 -3
- data/spec/models/form_address_spec.rb +1 -1
- data/spec/models/form_checkout_spec.rb +1 -1
- data/spec/models/shop_product_spec.rb +3 -3
- data/spec/spec_helper.rb +14 -8
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.92.
|
1
|
+
0.92.2
|
data/app/models/shop_order.rb
CHANGED
@@ -130,6 +130,11 @@ class ShopOrder < ActiveRecord::Base
|
|
130
130
|
|
131
131
|
class << self
|
132
132
|
|
133
|
+
# A hookable method used by the site controller
|
134
|
+
def find_by_session(session)
|
135
|
+
find(session)
|
136
|
+
end
|
137
|
+
|
133
138
|
# Will scope the contained find calls to a specific status
|
134
139
|
def scope_by_status(status)
|
135
140
|
case status
|
data/app/models/shop_product.rb
CHANGED
@@ -14,7 +14,7 @@ class ShopProduct < ActiveRecord::Base
|
|
14
14
|
before_validation :assign_slug, :assign_breadcrumb, :assign_page_class_name
|
15
15
|
validates_presence_of :page
|
16
16
|
|
17
|
-
validates_numericality_of :price, :
|
17
|
+
validates_numericality_of :price, :greater_than_or_equal_to => 0.00, :allow_nil => false, :precisions => 2
|
18
18
|
|
19
19
|
accepts_nested_attributes_for :page
|
20
20
|
|
@@ -7,33 +7,25 @@ module Shop
|
|
7
7
|
filter_parameter_logging :password, :password_confirmation, :credit
|
8
8
|
|
9
9
|
def current_shop_order
|
10
|
-
|
11
|
-
@current_shop_order = find_or_create_shop_order if request.session[:shop_order]
|
10
|
+
find_or_create_shop_order
|
12
11
|
end
|
13
12
|
|
14
13
|
def find_shop_order
|
15
|
-
shop_order = nil
|
16
|
-
|
17
14
|
begin
|
18
|
-
|
15
|
+
ShopOrder.find_by_session(request.session[:shop_order])
|
19
16
|
rescue
|
20
|
-
|
17
|
+
nil
|
21
18
|
end
|
22
|
-
|
23
|
-
shop_order
|
24
19
|
end
|
25
20
|
|
26
21
|
def find_or_create_shop_order
|
27
|
-
shop_order = nil
|
28
|
-
|
29
22
|
if find_shop_order
|
30
|
-
|
23
|
+
return find_shop_order
|
31
24
|
else
|
32
|
-
shop_order = ShopOrder.create(
|
25
|
+
shop_order = ShopOrder.create(:customer_id => (current_user.id rescue nil))
|
33
26
|
request.session[:shop_order] = shop_order.id
|
27
|
+
return shop_order
|
34
28
|
end
|
35
|
-
|
36
|
-
shop_order
|
37
29
|
end
|
38
30
|
end
|
39
31
|
end
|
data/lib/shop/tags/cart.rb
CHANGED
data/lib/shop/tags/category.rb
CHANGED
@@ -33,8 +33,10 @@ module Shop
|
|
33
33
|
|
34
34
|
tag 'shop:category' do |tag|
|
35
35
|
tag.locals.shop_category = Helpers.current_category(tag)
|
36
|
-
|
37
|
-
|
36
|
+
if tag.locals.shop_category.present?
|
37
|
+
tag.locals.shop_categories = tag.locals.shop_category.categories
|
38
|
+
end
|
39
|
+
|
38
40
|
tag.expand unless tag.locals.shop_category.nil?
|
39
41
|
end
|
40
42
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-shop-extension}
|
8
|
-
s.version = "0.92.
|
8
|
+
s.version = "0.92.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dirk Kelly", "John Barker", "Darcy Laycock"]
|
12
|
-
s.date = %q{2010-12-
|
12
|
+
s.date = %q{2010-12-17}
|
13
13
|
s.description = %q{Radiant Shop is an attempt at a simple but complete store. It includes Products, Categories, Orders and Credit Card Payments}
|
14
14
|
s.email = %q{dk@dirkkelly.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -13,11 +13,11 @@ describe Admin::Shop::CustomersController do
|
|
13
13
|
it 'should be assigned' do
|
14
14
|
get :new
|
15
15
|
|
16
|
-
assigns(:inputs).should
|
17
|
-
assigns(:meta).should
|
18
|
-
assigns(:buttons).should
|
19
|
-
assigns(:parts).should
|
20
|
-
assigns(:popups).should
|
16
|
+
assigns(:inputs).should include('name','email')
|
17
|
+
assigns(:meta).should include('login','password','password_confirmation')
|
18
|
+
assigns(:buttons).should include()
|
19
|
+
assigns(:parts).should include()
|
20
|
+
assigns(:popups).should include()
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -27,11 +27,11 @@ describe Admin::Shop::CustomersController do
|
|
27
27
|
it 'should be assigned' do
|
28
28
|
get :edit, :id => shop_customers(:customer).id
|
29
29
|
|
30
|
-
assigns(:inputs).should
|
31
|
-
assigns(:meta).should
|
32
|
-
assigns(:buttons).should
|
33
|
-
assigns(:parts).should
|
34
|
-
assigns(:popups).should
|
30
|
+
assigns(:inputs).should include('name','email')
|
31
|
+
assigns(:meta).should include('login','password','password_confirmation')
|
32
|
+
assigns(:buttons).should include()
|
33
|
+
assigns(:parts).should include('orders','addresses')
|
34
|
+
assigns(:popups).should include()
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -41,11 +41,11 @@ describe Admin::Shop::CustomersController do
|
|
41
41
|
it 'should be assigned' do
|
42
42
|
post :create, :shop_customer => {}
|
43
43
|
|
44
|
-
assigns(:inputs).should
|
45
|
-
assigns(:meta).should
|
46
|
-
assigns(:buttons).should
|
47
|
-
assigns(:parts).should
|
48
|
-
assigns(:popups).should
|
44
|
+
assigns(:inputs).should include('name','email')
|
45
|
+
assigns(:meta).should include('login','password','password_confirmation')
|
46
|
+
assigns(:buttons).should include()
|
47
|
+
assigns(:parts).should include()
|
48
|
+
assigns(:popups).should include()
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -55,11 +55,11 @@ describe Admin::Shop::CustomersController do
|
|
55
55
|
it 'should be assigned' do
|
56
56
|
put :update, :id => shop_customers(:customer).id, :shop_customer => {}
|
57
57
|
|
58
|
-
assigns(:inputs).should
|
59
|
-
assigns(:meta).should
|
60
|
-
assigns(:buttons).should
|
61
|
-
assigns(:parts).should
|
62
|
-
assigns(:popups).should
|
58
|
+
assigns(:inputs).should include('name','email')
|
59
|
+
assigns(:meta).should include('login','password','password_confirmation')
|
60
|
+
assigns(:buttons).should include()
|
61
|
+
assigns(:parts).should include('orders','addresses')
|
62
|
+
assigns(:popups).should include()
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -45,33 +45,33 @@ describe Admin::Shop::OrdersController do
|
|
45
45
|
it 'should assign the following' do
|
46
46
|
get :edit, :id => shop_orders(:empty).id
|
47
47
|
|
48
|
-
assigns(:inputs).should
|
49
|
-
assigns(:meta).should
|
50
|
-
assigns(:buttons).should
|
51
|
-
assigns(:parts).should
|
52
|
-
assigns(:popups).should
|
48
|
+
assigns(:inputs).should include()
|
49
|
+
assigns(:meta).should include()
|
50
|
+
assigns(:buttons).should include()
|
51
|
+
assigns(:parts).should include('items')
|
52
|
+
assigns(:popups).should include()
|
53
53
|
end
|
54
54
|
end
|
55
55
|
context 'order with no address and customer' do
|
56
56
|
it 'should assign the following' do
|
57
57
|
get :edit, :id => shop_orders(:one_item).id
|
58
58
|
|
59
|
-
assigns(:inputs).should
|
60
|
-
assigns(:meta).should
|
61
|
-
assigns(:buttons).should
|
62
|
-
assigns(:parts).should
|
63
|
-
assigns(:popups).should
|
59
|
+
assigns(:inputs).should include()
|
60
|
+
assigns(:meta).should include()
|
61
|
+
assigns(:buttons).should include()
|
62
|
+
assigns(:parts).should include('items','customer')
|
63
|
+
assigns(:popups).should include()
|
64
64
|
end
|
65
65
|
end
|
66
66
|
context 'order with no address and customer' do
|
67
67
|
it 'should assign the following' do
|
68
68
|
get :edit, :id => shop_orders(:several_items).id
|
69
69
|
|
70
|
-
assigns(:inputs).should
|
71
|
-
assigns(:meta).should
|
72
|
-
assigns(:buttons).should
|
73
|
-
assigns(:parts).should
|
74
|
-
assigns(:popups).should
|
70
|
+
assigns(:inputs).should include()
|
71
|
+
assigns(:meta).should include()
|
72
|
+
assigns(:buttons).should include()
|
73
|
+
assigns(:parts).should include('items','addresses','customer')
|
74
|
+
assigns(:popups).should include()
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -82,33 +82,33 @@ describe Admin::Shop::OrdersController do
|
|
82
82
|
it 'should assign the following' do
|
83
83
|
put :update, :id => shop_orders(:empty).id, :shop_order => {}
|
84
84
|
|
85
|
-
assigns(:inputs).should
|
86
|
-
assigns(:meta).should
|
87
|
-
assigns(:buttons).should
|
88
|
-
assigns(:parts).should
|
89
|
-
assigns(:popups).should
|
85
|
+
assigns(:inputs).should include()
|
86
|
+
assigns(:meta).should include()
|
87
|
+
assigns(:buttons).should include()
|
88
|
+
assigns(:parts).should include('items')
|
89
|
+
assigns(:popups).should include()
|
90
90
|
end
|
91
91
|
end
|
92
92
|
context 'order with no address and customer' do
|
93
93
|
it 'should assign the following' do
|
94
94
|
put :update, :id => shop_orders(:one_item).id, :shop_order => {}
|
95
95
|
|
96
|
-
assigns(:inputs).should
|
97
|
-
assigns(:meta).should
|
98
|
-
assigns(:buttons).should
|
99
|
-
assigns(:parts).should
|
100
|
-
assigns(:popups).should
|
96
|
+
assigns(:inputs).should include()
|
97
|
+
assigns(:meta).should include()
|
98
|
+
assigns(:buttons).should include()
|
99
|
+
assigns(:parts).should include('items','customer')
|
100
|
+
assigns(:popups).should include()
|
101
101
|
end
|
102
102
|
end
|
103
103
|
context 'order with no address and customer' do
|
104
104
|
it 'should assign the following' do
|
105
105
|
put :update, :id => shop_orders(:several_items).id, :shop_order => {}
|
106
106
|
|
107
|
-
assigns(:inputs).should
|
108
|
-
assigns(:meta).should
|
109
|
-
assigns(:buttons).should
|
110
|
-
assigns(:parts).should
|
111
|
-
assigns(:popups).should
|
107
|
+
assigns(:inputs).should include()
|
108
|
+
assigns(:meta).should include()
|
109
|
+
assigns(:buttons).should include()
|
110
|
+
assigns(:parts).should include('items','addresses','customer')
|
111
|
+
assigns(:popups).should include()
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -18,7 +18,7 @@ class ShopCustomersDataset < Dataset::Base
|
|
18
18
|
|
19
19
|
helpers do
|
20
20
|
def login_as(user)
|
21
|
-
login_user =
|
21
|
+
login_user = users(user)
|
22
22
|
flunk "Can't login as non-existing user #{user.to_s}." unless login_user
|
23
23
|
UserActionObserver.current_user = login_user
|
24
24
|
login_user
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class ShopOrdersDataset < Dataset::Base
|
2
2
|
|
3
|
-
uses :shop_products, :
|
3
|
+
uses :shop_products, :users
|
4
4
|
|
5
5
|
def load
|
6
6
|
create_record :shop_order, :empty
|
7
7
|
|
8
8
|
create_record :shop_order, :one_item,
|
9
|
-
:customer =>
|
9
|
+
:customer => users(:admin)
|
10
10
|
|
11
11
|
create_record :shop_order, :several_items,
|
12
|
-
:customer =>
|
12
|
+
:customer => users(:admin)
|
13
13
|
end
|
14
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../spec_helper"
|
2
2
|
|
3
3
|
describe ShopProduct do
|
4
|
-
dataset :shop_products, :shop_line_items
|
4
|
+
dataset :shop_products, :shop_line_items, :shop_customers
|
5
5
|
|
6
6
|
describe 'relationships' do
|
7
7
|
before :each do
|
@@ -13,12 +13,12 @@ describe ShopProduct do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have a created_by User' do
|
16
|
-
@product.created_by =
|
16
|
+
@product.created_by = shop_customers(:customer)
|
17
17
|
@product.created_by.is_a?(User).should be_true
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should have a updated_by User' do
|
21
|
-
@product.updated_by =
|
21
|
+
@product.updated_by = shop_customers(:customer)
|
22
22
|
@product.updated_by.is_a?(User).should be_true
|
23
23
|
end
|
24
24
|
|
data/spec/spec_helper.rb
CHANGED
@@ -11,12 +11,18 @@ unless defined? RADIANT_ROOT
|
|
11
11
|
end
|
12
12
|
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
unless defined? SHOP_ROOT
|
15
|
+
|
16
|
+
SHOP_ROOT = ShopExtension.root + '/spec'
|
17
|
+
|
18
|
+
Dataset::Resolver.default << (SHOP_ROOT + "/datasets")
|
19
|
+
|
20
|
+
if File.directory?(SHOP_ROOT + "/matchers")
|
21
|
+
Dir[SHOP_ROOT + "/matchers/**/*.rb"].each {|file| require file }
|
22
|
+
end
|
23
|
+
|
24
|
+
Spec::Runner.configure do |config|
|
25
|
+
config.mock_with :rr
|
26
|
+
end
|
27
|
+
|
22
28
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-shop-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 363
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 92
|
9
|
-
-
|
10
|
-
version: 0.92.
|
9
|
+
- 2
|
10
|
+
version: 0.92.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dirk Kelly
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-12-
|
20
|
+
date: 2010-12-17 00:00:00 +08:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|