radiant-shop-extension 0.92.2 → 0.92.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.92.2
1
+ 0.92.3
@@ -67,10 +67,15 @@ class FormAddress
67
67
 
68
68
  end
69
69
  else
70
- if @order.shipping.nil?
71
- @shipping = ShopShipping.new(@billing.attributes)
72
- if @shipping.save
73
- @order.update_attribute(:shipping, @shipping)
70
+ if @order.shipping.present?
71
+ @shipping = @order.shipping
72
+
73
+ else
74
+ if @order.shipping.nil?
75
+ @shipping = ShopShipping.new(@billing.attributes)
76
+ if @shipping.save
77
+ @order.update_attribute(:shipping, @shipping)
78
+ end
74
79
  end
75
80
  end
76
81
 
@@ -5,13 +5,20 @@ class FixAddressableColumnType < ActiveRecord::Migration
5
5
  ShopAddress.find_each do |address|
6
6
  address.update_attribute(:addressable_integer, :addressable_id)
7
7
  end
8
- remove_column :shop_addresses, :addressable_id
9
8
 
10
- add_column :shop_addresses, :addressable_id, :integer
11
- ShopAddress.reset_column_information
12
- ShopAddress.find_each do |address|
13
- address.update_attribute(:addressable_id, :addressable_integer)
14
- end
9
+ begin
10
+ remove_column :shop_addresses, :addressable_id
11
+ add_column :shop_addresses, :addressable_id, :integer
12
+ ShopAddress.reset_column_information
13
+ ShopAddress.find_each do |address|
14
+ address.update_attribute(:addressable_id, :addressable_integer)
15
+ end
16
+
17
+ remove_column :shop_addresses, :addressable_integer
18
+ rescue
19
+ # Yay sqlite
20
+ end
21
+
15
22
  end
16
23
 
17
24
  def self.down
@@ -56,7 +56,24 @@ module Shop
56
56
 
57
57
  end
58
58
 
59
- [:id, :name, :handle, :slug].each do |symbol|
59
+ tag 'shop:category:unless_current' do |tag|
60
+
61
+ if tag.locals.page.shop_product.present?
62
+ # A product page
63
+ if tag.locals.page.shop_product.category != tag.locals.shop_category
64
+ # Where the products category is this category
65
+ tag.expand
66
+ end
67
+
68
+ elsif tag.locals.page.shop_category != tag.locals.shop_category
69
+ # Looking at the shop_category generated page
70
+ tag.expand
71
+
72
+ end
73
+
74
+ end
75
+
76
+ [:id, :name, :handle, :slug, :url].each do |symbol|
60
77
  desc %{ outputs the #{symbol} of the current shop category }
61
78
  tag "shop:category:#{symbol}" do |tag|
62
79
  tag.locals.shop_category.send(symbol)
@@ -37,6 +37,24 @@ module Shop
37
37
  tag.expand if tag.locals.shop_product.present?
38
38
  end
39
39
 
40
+ tag 'shop:product:page' do |tag|
41
+ tag.locals.page = tag.locals.shop_product.page
42
+
43
+ tag.expand
44
+ end
45
+
46
+ tag 'shop:product:if_current' do |tag|
47
+ if tag.locals.page.shop_product == tag.locals.shop_product
48
+ tag.expand
49
+ end
50
+ end
51
+
52
+ tag 'shop:product:unless_current' do |tag|
53
+ if tag.locals.page.shop_product != tag.locals.shop_product
54
+ tag.expand
55
+ end
56
+ end
57
+
40
58
  [:id, :name, :sku, :slug].each do |symbol|
41
59
  desc %{ outputs the #{symbol} of the current shop product }
42
60
  tag "shop:product:#{symbol}" do |tag|
@@ -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.2"
8
+ s.version = "0.92.3"
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-17}
12
+ s.date = %q{2010-12-21}
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 = [
@@ -15,7 +15,9 @@ describe Shop::Tags::Category do
15
15
  'shop:category:handle',
16
16
  'shop:category:id',
17
17
  'shop:category:if_current',
18
+ 'shop:category:unless_current',
18
19
  'shop:category:link',
20
+ 'shop:category:url',
19
21
  'shop:category:name',
20
22
  'shop:category:slug',
21
23
  'shop:category:images'].sort
@@ -119,6 +121,36 @@ describe Shop::Tags::Category do
119
121
  end
120
122
  end
121
123
 
124
+ describe '<r:shop:category:unless_current>' do
125
+ before :each do
126
+ mock(Shop::Tags::Helpers).current_category(anything) { @category }
127
+ end
128
+ context 'this categories page' do
129
+ it 'should not expand' do
130
+ tag = %{<r:shop:category:unless_current>failure</r:shop:category:unless_current>}
131
+ exp = %{}
132
+
133
+ @category.page.should render(tag).as(exp)
134
+ end
135
+ end
136
+ context 'categories product page' do
137
+ it 'should not expand' do
138
+ tag = %{<r:shop:category:unless_current>failure</r:shop:category:unless_current>}
139
+ exp = %{}
140
+
141
+ @category.products.first.page.should render(tag).as(exp)
142
+ end
143
+ end
144
+ context 'failure' do
145
+ it 'should expand' do
146
+ tag = %{<r:shop:category:unless_current>success</r:shop:category:unless_current>}
147
+ exp = %{success}
148
+
149
+ @page.should render(tag).as(exp)
150
+ end
151
+ end
152
+ end
153
+
122
154
  describe 'simple attributes' do
123
155
  before :each do
124
156
  mock(Shop::Tags::Helpers).current_category(anything) { @category }
@@ -147,6 +179,12 @@ describe Shop::Tags::Category do
147
179
 
148
180
  @page.should render(tag).as(exp)
149
181
  end
182
+ it 'should render <r:url />' do
183
+ tag = %{<r:shop:category:url />}
184
+ exp = @category.url
185
+
186
+ @page.should render(tag).as(exp)
187
+ end
150
188
  describe '<r:description />' do
151
189
  it 'should render a textile filtered result' do
152
190
  tag = %{<r:shop:category:description />}
@@ -11,6 +11,9 @@ describe Shop::Tags::Product do
11
11
  'shop:products:unless_products',
12
12
  'shop:products:each',
13
13
  'shop:product',
14
+ 'shop:product:if_current',
15
+ 'shop:product:unless_current',
16
+ 'shop:product:page',
14
17
  'shop:product:id',
15
18
  'shop:product:name',
16
19
  'shop:product:price',
@@ -164,6 +167,54 @@ describe Shop::Tags::Product do
164
167
  end
165
168
  end
166
169
 
170
+ context '<r:shop:product:page>' do
171
+ before :each do
172
+ mock(Shop::Tags::Helpers).current_product(anything) { @product }
173
+ end
174
+
175
+ it 'should set the page context from the product' do
176
+ tag = %{<r:shop:product:page><r:title/></r:shop:product:page>}
177
+ exp = @product.page.title.to_s
178
+ @page.should render(tag).as(exp)
179
+ end
180
+ end
181
+
182
+ context '<r:shop:product:if_current>' do
183
+ before :each do
184
+ mock(Shop::Tags::Helpers).current_product(anything) { @product }
185
+ end
186
+
187
+ it 'should render if the page belongs to the product' do
188
+ tag = %{<r:shop:product:if_current>success</r:shop:product:if_current>}
189
+ exp = %{success}
190
+ @product.page.should render(tag).as(exp)
191
+ end
192
+
193
+ it 'should not render if the page does not belong to the product' do
194
+ tag = %{<r:shop:product:if_current>failure</r:shop:product:if_current>}
195
+ exp = %{}
196
+ @page.should render(tag).as(exp)
197
+ end
198
+ end
199
+
200
+ context '<r:shop:product:unless_current>' do
201
+ before :each do
202
+ mock(Shop::Tags::Helpers).current_product(anything) { @product }
203
+ end
204
+
205
+ it 'should render if the page does not belong to the product' do
206
+ tag = %{<r:shop:product:unless_current>success</r:shop:product:unless_current>}
207
+ exp = %{success}
208
+ @page.should render(tag).as(exp)
209
+ end
210
+
211
+ it 'should not render if the page belongs to the product' do
212
+ tag = %{<r:shop:product:unless_current>failure</r:shop:product:unless_current>}
213
+ exp = %{}
214
+ @product.page.should render(tag).as(exp)
215
+ end
216
+ end
217
+
167
218
  context '#attributes' do
168
219
  before :each do
169
220
  mock(Shop::Tags::Helpers).current_product(anything) { @product }
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: 363
4
+ hash: 361
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 92
9
- - 2
10
- version: 0.92.2
9
+ - 3
10
+ version: 0.92.3
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-17 00:00:00 +08:00
20
+ date: 2010-12-21 00:00:00 +08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency