radiant-shop-extension 0.11.1 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -33,4 +33,4 @@ pppps: love heart
33
33
 
34
34
  # Migrating in Development
35
35
 
36
- rm db/development.sqlite3.db; rake db:migrate; rake radiant:extensions:scoped:migrate; rake radiant:extensions:settings:migrate; rake radiant:extensions:drag:migrate; rake radiant:extensions:forms:migrate; rake radiant:extensions:images:migrate; rake radiant:extensions:shop:migrate; rake radiant:extensions:shop_mg:migrate; rake radiant:extensions:export:load;
36
+ rm db/development.sqlite3.db; rake db:migrate; rake radiant:extensions:scoped:migrate; rake radiant:extensions:settings:migrate; rake radiant:extensions:drag:migrate; rake radiant:extensions:forms:migrate; rake radiant:extensions:images:migrate; rake radiant:extensions:shop:migrate; rake radiant:extensions:export:load;
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.authors = ["Dirk Kelly", "John Barker"]
10
10
  gem.add_dependency 'radiant', '>= 0.9.1'
11
11
  gem.add_dependency 'radiant-forms-extension', '>= 3.1.1'
12
- gem.add_dependency 'radiant-images-extension', '>= 0.2.0'
12
+ gem.add_dependency 'radiant-images-extension', '>= 0.3.2'
13
13
  gem.add_dependency 'radiant-layouts-extension', '>= 0.9.1'
14
14
  gem.add_dependency 'radiant-settings-extension', '>= 1.1.1'
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.1
1
+ 0.11.3
@@ -21,7 +21,7 @@ class ShopCategory < ActiveRecord::Base
21
21
  def handle; ShopProduct.to_sku(page.url); end
22
22
 
23
23
  # Returns the content of the product's page's description part
24
- def description; page.parts.find_by_name('description').content end
24
+ def description; page.parts.find_by_name('description').content; rescue ''; end
25
25
 
26
26
  # Returns products through the pages children
27
27
  def products; page.children.map(&:shop_product); end
@@ -38,7 +38,7 @@ class ShopCategory < ActiveRecord::Base
38
38
  class << self
39
39
 
40
40
  # Sorts a group of categories based on their ID and position in an array
41
- def sort(*category_ids)
41
+ def sort(category_ids)
42
42
  category_ids.each_with_index do |id, index|
43
43
  ShopCategory.find(id).page.update_attributes!(
44
44
  :position => index+1
@@ -36,7 +36,7 @@ class ShopProduct < ActiveRecord::Base
36
36
  def category_id; category.id; end
37
37
 
38
38
  # Returns the content of the product's page's description part
39
- def description; page.parts.find_by_name('description').content rescue nil; end
39
+ def description; page.parts.find_by_name('description').content rescue ''; end
40
40
 
41
41
  # Returns the url of the page
42
42
  def url; page.url; end
@@ -71,7 +71,7 @@ class ShopProduct < ActiveRecord::Base
71
71
  class << self
72
72
 
73
73
  # Sorts products within a category
74
- def sort(category_id, *product_ids)
74
+ def sort(category_id, product_ids)
75
75
  parent_id = ShopCategory.find(category_id).page_id
76
76
 
77
77
  product_ids.each_with_index do |id, index|
@@ -1,4 +1,4 @@
1
1
  - f.fields_for :page do |pf|
2
2
  - pf.fields_for :parts do |pfp|
3
- = pfp.hidden_field :name, :value => 'Description'
3
+ = pfp.hidden_field :name, :value => 'description'
4
4
  ~ pfp.text_area :content, :class => "textarea large", :style => "width: 100%"
@@ -1,4 +1,4 @@
1
1
  - f.fields_for :page do |pf|
2
2
  - pf.fields_for :parts do |pfp|
3
- = pfp.hidden_field :name, :value => 'Description'
3
+ = pfp.hidden_field :name, :value => 'description'
4
4
  ~ pfp.text_area :content, :class => "textarea large", :style => "width: 100%"
data/db/seeds/forms.rb CHANGED
@@ -3,17 +3,29 @@ puts "Seed Shop Forms";
3
3
  # Add Cart Item
4
4
 
5
5
  Form.create({
6
- :title => 'AddCartItem',
7
- :action => '/shop/cart/items',
6
+ :title => 'CartAddProduct',
7
+ :action => '/shop/cart', # Redirects to the cart listing
8
8
  :body => <<-BODY
9
9
  <r:shop:product>
10
10
  <input type="hidden" name="line_item[item_id]" value="<r:id />" />
11
- <!-- Your Customisation Below -->
11
+ <input type="hidden" name="line_item[item_type]" value="ShopProduct" />
12
12
 
13
- <r:form:text name='line_item[quantity]' value="1" /> <!-- Amount of items to add -->
14
- <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Add To Cart" />
13
+ <input type="hidden" name="line_item[quantity]" value="1" />
14
+ <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Buy Now" />
15
+ </r:shop:product>
16
+ BODY
17
+ })
18
+
19
+ Form.create({
20
+ :title => 'CartAddProductVariant',
21
+ :action => '/shop/cart', # Redirects to the cart listing
22
+ :body => <<-BODY
23
+ <r:shop:product>
24
+ <input type="hidden" name="line_item[item_id]" value="<r:id />" />
25
+ <input type="hidden" name="line_item[item_type]" value="ShopProduct" />
15
26
 
16
- <!-- Your Customisation Above -->
27
+ <input type="hidden" name="line_item[quantity]" value="1" />
28
+ <input type="submit" name="add_to_cart" id="add_to_cart_<r:id />" value="Buy Now" />
17
29
  </r:shop:product>
18
30
  BODY
19
31
  })
@@ -21,19 +33,18 @@ BODY
21
33
  # Update Cart Item
22
34
 
23
35
  Form.create({
24
- :title => 'UpdateCartItem',
25
- :action => '/shop/cart/items/x',
36
+ :title => 'CartUpdateItem',
37
+ :action => '',
26
38
  :body => <<-BODY
27
- <r:shop:cart:item>
28
- <input type="hidden" name="_method" value="put" />
29
- <input type="hidden" name="line_item[id]" value="<r:id />" />
30
- <!-- Your Customisation Below -->
31
-
32
- <input type="text" name="line_item[quantity]" value="<r:quantity />" />
33
- <input type="submit" name="add_to_cart" id="update_<r:id />" value="Update" />
34
-
35
- <!-- Your Customisation Above -->
36
- </r:shop:cart:item>
39
+ <r:shop:cart>
40
+ <r:item>
41
+ <input type="hidden" name="_method" value="put" />
42
+ <input type="hidden" name="line_item[id]" value="<r:item:id />" />
43
+
44
+ <input type="text" name="line_item[quantity]" value="<r:quantity />" />
45
+ <input type="submit" name="add_to_cart" id="update_<r:id />" value="Update" />
46
+ </r:item>
47
+ </r:shop:cart>
37
48
  BODY
38
49
  })
39
50
 
@@ -3,19 +3,19 @@ module Shop
3
3
  module Category
4
4
  include Radiant::Taggable
5
5
 
6
- desc %{ expands if there are shop categories within the context }
7
- tag 'shop:if_categories' do |tag|
8
- tag.expand if Helpers.current_categories(tag).present?
6
+ tag 'shop:categories' do |tag|
7
+ tag.locals.shop_categories = Helpers.current_categories(tag)
8
+ tag.expand
9
9
  end
10
10
 
11
- desc %{ expands if there are not shop categories within the context }
12
- tag 'shop:unless_categories' do |tag|
13
- tag.expand unless Helpers.current_categories(tag).present?
11
+ desc %{ expands if there are shop categories within the context }
12
+ tag 'shop:categories:if_categories' do |tag|
13
+ tag.expand if tag.locals.shop_categories.present?
14
14
  end
15
15
 
16
- tag 'shop:categories' do |tag|
17
- tag.locals.shop_categories = Helpers.current_categories(tag)
18
- tag.expand if tag.locals.shop_categories.present?
16
+ desc %{ expands if there are not shop categories within the context }
17
+ tag 'shop:categories:unless_categories' do |tag|
18
+ tag.expand if tag.locals.shop_categories.empty?
19
19
  end
20
20
 
21
21
  desc %{ iterates through each product category }
@@ -73,7 +73,7 @@ module Shop
73
73
 
74
74
  text = tag.double? ? tag.expand : category.name
75
75
 
76
- %{<a href="#{category.slug}"#{attributes}>#{text}</a>}
76
+ %{<a href="#{category.url}"#{attributes}>#{text}</a>}
77
77
  end
78
78
 
79
79
  end
@@ -57,7 +57,7 @@ module Shop
57
57
 
58
58
  text = tag.double? ? tag.expand : tag.locals.shop_product.name
59
59
 
60
- %{<a href="#{tag.locals.shop_product.slug}"#{attributes}>#{text}</a>}
60
+ %{<a href="#{tag.locals.shop_product.url}"#{attributes}>#{text}</a>}
61
61
  end
62
62
 
63
63
  desc %{ outputs the slug to the products generated page }
@@ -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.11.1"
8
+ s.version = "0.11.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"]
12
- s.date = %q{2010-10-08}
12
+ s.date = %q{2010-10-09}
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 = [
@@ -399,20 +399,20 @@ Gem::Specification.new do |s|
399
399
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
400
400
  s.add_runtime_dependency(%q<radiant>, [">= 0.9.1"])
401
401
  s.add_runtime_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
402
- s.add_runtime_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
402
+ s.add_runtime_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
403
403
  s.add_runtime_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
404
404
  s.add_runtime_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
405
405
  else
406
406
  s.add_dependency(%q<radiant>, [">= 0.9.1"])
407
407
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
408
- s.add_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
408
+ s.add_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
409
409
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
410
410
  s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
411
411
  end
412
412
  else
413
413
  s.add_dependency(%q<radiant>, [">= 0.9.1"])
414
414
  s.add_dependency(%q<radiant-forms-extension>, [">= 3.1.1"])
415
- s.add_dependency(%q<radiant-images-extension>, [">= 0.2.0"])
415
+ s.add_dependency(%q<radiant-images-extension>, [">= 0.3.2"])
416
416
  s.add_dependency(%q<radiant-layouts-extension>, [">= 0.9.1"])
417
417
  s.add_dependency(%q<radiant-settings-extension>, [">= 1.1.1"])
418
418
  end
data/shop_extension.rb CHANGED
@@ -29,11 +29,6 @@ class ShopExtension < Radiant::Extension
29
29
  admin.variants = Radiant::AdminUI.load_default_shop_variants_regions
30
30
  end
31
31
 
32
- # if admin.respond_to? :page
33
- # admin.page.edit.add :layout_row, 'shop_category'
34
- # admin.page.edit.add :layout_row, 'shop_product'
35
- # end
36
-
37
32
  # Tags
38
33
  Page.send :include, Shop::Tags::Core, Shop::Tags::Address, Shop::Tags::Card, Shop::Tags::Cart, Shop::Tags::Category, Shop::Tags::Item, Shop::Tags::Package, Shop::Tags::Product, Shop::Tags::ProductVariant, Shop::Tags::Responses
39
34
 
@@ -4,6 +4,22 @@ describe Shop::Tags::Category do
4
4
 
5
5
  dataset :pages, :shop_categories, :shop_products
6
6
 
7
+ it 'should describe these tags' do
8
+ Shop::Tags::Category.tags.sort.should == [
9
+ 'shop:categories',
10
+ 'shop:categories:each',
11
+ 'shop:categories:if_categories',
12
+ 'shop:categories:unless_categories',
13
+ 'shop:category',
14
+ 'shop:category:description',
15
+ 'shop:category:handle',
16
+ 'shop:category:id',
17
+ 'shop:category:if_current',
18
+ 'shop:category:link',
19
+ 'shop:category:name',
20
+ 'shop:category:slug'].sort
21
+ end
22
+
7
23
  before :each do
8
24
  @page = pages(:home)
9
25
  end
@@ -12,14 +28,33 @@ describe Shop::Tags::Category do
12
28
  @category = shop_categories(:bread)
13
29
  end
14
30
 
15
- describe '<r:shop:if_categories>' do
16
- context 'success' do
31
+ describe '<r:shop:categories>' do
32
+ context 'categories exist' do
17
33
  it 'should render' do
18
34
  mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
19
-
20
- tag = %{<r:shop:if_categories>success</r:shop:if_categories>}
35
+ tag = %{<r:shop:categories>success</r:shop:categories>}
21
36
  exp = %{success}
22
-
37
+
38
+ @page.should render(tag).as(exp)
39
+ end
40
+ end
41
+ context 'categories dont exist' do
42
+ it 'should render' do
43
+ mock(Shop::Tags::Helpers).current_categories(anything) { [] }
44
+ tag = %{<r:shop:categories>success</r:shop:categories>}
45
+ exp = %{success}
46
+
47
+ @page.should render(tag).as(exp)
48
+ end
49
+ end
50
+ end
51
+
52
+ describe '<r:shop:categories:if_categories>' do
53
+ context 'success' do
54
+ it 'should render' do
55
+ tag = %{<r:shop:categories:if_categories>success</r:shop:categories:if_categories>}
56
+ exp = %{success}
57
+
23
58
  @page.should render(tag).as(exp)
24
59
  end
25
60
  end
@@ -27,44 +62,32 @@ describe Shop::Tags::Category do
27
62
  it 'should not render' do
28
63
  mock(Shop::Tags::Helpers).current_categories(anything) { [] }
29
64
 
30
- tag = %{<r:shop:if_categories>failure</r:shop:if_categories>}
65
+ tag = %{<r:shop:categories:if_categories>failure</r:shop:categories:if_categories>}
31
66
  exp = %{}
32
67
  @page.should render(tag).as(exp)
33
68
  end
34
69
  end
35
70
  end
36
71
 
37
- describe '<r:shop:unless_categories>' do
72
+ describe '<r:shop:categories:unless_categories>' do
38
73
  context 'success' do
39
74
  it 'should render' do
40
75
  mock(Shop::Tags::Helpers).current_categories(anything) { [] }
41
76
 
42
- tag = %{<r:shop:unless_categories>success</r:shop:unless_categories>}
77
+ tag = %{<r:shop:categories:unless_categories>success</r:shop:categories:unless_categories>}
43
78
  exp = %{success}
44
79
  @page.should render(tag).as(exp)
45
80
  end
46
81
  end
47
82
  context 'failure' do
48
83
  it 'should not render' do
49
- mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
50
-
51
- tag = %{<r:shop:unless_categories>failure</r:shop:unless_categories>}
84
+ tag = %{<r:shop:categories:unless_categories>failure</r:shop:categories:unless_categories>}
52
85
  exp = %{}
53
86
  @page.should render(tag).as(exp)
54
87
  end
55
88
  end
56
89
  end
57
90
 
58
- describe '<r:shop:categories>' do
59
- it 'should render' do
60
- mock(Shop::Tags::Helpers).current_categories(anything) { [@category] }
61
- tag = %{<r:shop:categories>success</r:shop:categories>}
62
- exp = %{success}
63
-
64
- @page.should render(tag).as(exp)
65
- end
66
- end
67
-
68
91
  describe '<r:shop:category:if_current>' do
69
92
  before :each do
70
93
  mock(Shop::Tags::Helpers).current_category(anything) { @category }
@@ -141,13 +164,13 @@ describe Shop::Tags::Category do
141
164
  context 'standalone' do
142
165
  it 'should render an anchor element' do
143
166
  tag = %{<r:shop:category:link />}
144
- exp = %{<a href="#{@category.slug}">#{@category.name}</a>}
167
+ exp = %{<a href="#{@category.url}">#{@category.name}</a>}
145
168
 
146
169
  @page.should render(tag).as(exp)
147
170
  end
148
171
  it 'should assign attributes' do
149
172
  tag = %{<r:shop:category:link title="title" data-title="data-title"/>}
150
- exp = %{<a href="#{@category.slug}" data-title="data-title" title="title">#{@category.name}</a>}
173
+ exp = %{<a href="#{@category.url}" data-title="data-title" title="title">#{@category.name}</a>}
151
174
 
152
175
  @page.should render(tag).as(exp)
153
176
  end
@@ -156,7 +179,7 @@ describe Shop::Tags::Category do
156
179
  context 'wrapped' do
157
180
  it 'should render an anchor element' do
158
181
  tag = %{<r:shop:category:link>title</r:shop:category:link>}
159
- exp = %{<a href="#{@category.slug}">title</a>}
182
+ exp = %{<a href="#{@category.url}">title</a>}
160
183
 
161
184
  @page.should render(tag).as(exp)
162
185
  end
@@ -218,12 +218,12 @@ describe Shop::Tags::Product do
218
218
  context 'standalone' do
219
219
  it 'should render an anchor element' do
220
220
  tag = %{<r:shop:product:link />}
221
- exp = %{<a href="#{@product.slug}">#{@product.name}</a>}
221
+ exp = %{<a href="#{@product.url}">#{@product.name}</a>}
222
222
  @page.should render(tag).as(exp)
223
223
  end
224
224
  it 'should assign attributes' do
225
225
  tag = %{<r:shop:product:link title="title" data-title="data-title"/>}
226
- exp = %{<a href="#{@product.slug}" data-title="data-title" title="title">#{@product.name}</a>}
226
+ exp = %{<a href="#{@product.url}" data-title="data-title" title="title">#{@product.name}</a>}
227
227
  @page.should render(tag).as(exp)
228
228
  end
229
229
  end
@@ -231,7 +231,7 @@ describe Shop::Tags::Product do
231
231
  context 'wrapped' do
232
232
  it 'should render an anchor element' do
233
233
  tag = %{<r:shop:product:link>title</r:shop:product:link>}
234
- exp = %{<a href="#{@product.slug}">title</a>}
234
+ exp = %{<a href="#{@product.url}">title</a>}
235
235
  @page.should render(tag).as(exp)
236
236
  end
237
237
  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: 49
4
+ hash: 53
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 1
10
- version: 0.11.1
9
+ - 3
10
+ version: 0.11.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Kelly
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-08 00:00:00 +08:00
19
+ date: 2010-10-09 00:00:00 +08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -62,9 +62,9 @@ dependencies:
62
62
  hash: 23
63
63
  segments:
64
64
  - 0
65
+ - 3
65
66
  - 2
66
- - 0
67
- version: 0.2.0
67
+ version: 0.3.2
68
68
  type: :runtime
69
69
  version_requirements: *id003
70
70
  - !ruby/object:Gem::Dependency