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 CHANGED
@@ -1 +1 @@
1
- 0.92.1
1
+ 0.92.2
@@ -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
@@ -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, :greater_than => 0.00, :allow_nil => true, :precisions => 2
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
- return @current_shop_order if defined?(@current_shop_order)
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
- shop_order = ShopOrder.find(request.session[:shop_order])
15
+ ShopOrder.find_by_session(request.session[:shop_order])
19
16
  rescue
20
- shop_order = nil
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
- shop_order = find_shop_order
23
+ return find_shop_order
31
24
  else
32
- shop_order = ShopOrder.create({ :customer_id => (current_user.id rescue nil) })
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
@@ -11,6 +11,7 @@ module Shop
11
11
  tag.expand
12
12
  end
13
13
 
14
+ desc %{ Clears the cart from the memory of the application}
14
15
  tag 'shop:cart:forget' do |tag|
15
16
  tag.locals.page.request.session[:shop_order] = nil
16
17
  end
@@ -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
- tag.locals.shop_categories = tag.locals.shop_category.categories
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.1"
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-14}
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 === ['name','email']
17
- assigns(:meta).should === ['login','password','password_confirmation']
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 === ['name','email']
31
- assigns(:meta).should === ['login','password','password_confirmation']
32
- assigns(:buttons).should === []
33
- assigns(:parts).should === ['orders','addresses']
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 === ['name','email']
45
- assigns(:meta).should === ['login','password','password_confirmation']
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 === ['name','email']
59
- assigns(:meta).should === ['login','password','password_confirmation']
60
- assigns(:buttons).should === []
61
- assigns(:parts).should === ['orders','addresses']
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 === ['items']
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 === ['items','customer']
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 === ['items','addresses','customer']
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 === ['items']
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 === ['items','customer']
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 === ['items','addresses','customer']
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 = user.is_a?(User) ? user : users(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, :shop_customers
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 => shop_customers(:customer)
9
+ :customer => users(:admin)
10
10
 
11
11
  create_record :shop_order, :several_items,
12
- :customer => shop_customers(:customer)
12
+ :customer => users(:admin)
13
13
  end
14
14
  end
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/../spec_helper"
2
2
 
3
3
  describe FormAddress do
4
4
 
5
- dataset :shop_orders, :pages, :forms, :shop_addresses
5
+ dataset :shop_orders, :pages, :forms, :shop_addresses, :shop_customers
6
6
 
7
7
  before :each do
8
8
  mock_page_with_request_and_data
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + "/../spec_helper"
2
2
 
3
3
  describe FormCheckout do
4
4
 
5
- dataset :shop_orders, :pages, :forms, :shop_addresses
5
+ dataset :shop_orders, :pages, :forms, :shop_addresses, :shop_customers
6
6
 
7
7
  before :each do
8
8
  mock_page_with_request_and_data
@@ -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 = users(:customer)
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 = users(:customer)
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
- Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
-
16
- if File.directory?(File.dirname(__FILE__) + "/matchers")
17
- Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
18
- end
19
-
20
- Spec::Runner.configure do |config|
21
- config.mock_with :rr
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: 365
4
+ hash: 363
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 92
9
- - 1
10
- version: 0.92.1
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-14 00:00:00 +08:00
20
+ date: 2010-12-17 00:00:00 +08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency