radiant-shop-extension 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +26 -0
  3. data/Gemfile.lock +75 -0
  4. data/HISTORY.md +77 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +26 -0
  7. data/Rakefile +141 -0
  8. data/VERSION +1 -0
  9. data/app/.DS_Store +0 -0
  10. data/app/controllers/admin/shop/categories_controller.rb +206 -0
  11. data/app/controllers/admin/shop/customers_controller.rb +137 -0
  12. data/app/controllers/admin/shop/orders_controller.rb +171 -0
  13. data/app/controllers/admin/shop/products/images_controller.rb +144 -0
  14. data/app/controllers/admin/shop/products_controller.rb +217 -0
  15. data/app/controllers/admin/shops_controller.rb +9 -0
  16. data/app/controllers/shop/categories_controller.rb +49 -0
  17. data/app/controllers/shop/line_items_controller.rb +165 -0
  18. data/app/controllers/shop/orders_controller.rb +16 -0
  19. data/app/controllers/shop/products_controller.rb +48 -0
  20. data/app/models/form_checkout.rb +245 -0
  21. data/app/models/shop_address.rb +13 -0
  22. data/app/models/shop_addressable.rb +11 -0
  23. data/app/models/shop_category.rb +85 -0
  24. data/app/models/shop_category_page.rb +7 -0
  25. data/app/models/shop_customer.rb +27 -0
  26. data/app/models/shop_line_item.rb +32 -0
  27. data/app/models/shop_order.rb +108 -0
  28. data/app/models/shop_payment.rb +6 -0
  29. data/app/models/shop_payment_method.rb +5 -0
  30. data/app/models/shop_product.rb +87 -0
  31. data/app/models/shop_product_attachment.rb +30 -0
  32. data/app/models/shop_product_page.rb +7 -0
  33. data/app/views/.DS_Store +0 -0
  34. data/app/views/admin/.DS_Store +0 -0
  35. data/app/views/admin/pages/_shop_category.html.haml +4 -0
  36. data/app/views/admin/pages/_shop_product.html.haml +4 -0
  37. data/app/views/admin/shop/categories/edit.html.haml +12 -0
  38. data/app/views/admin/shop/categories/edit/_fields.html.haml +28 -0
  39. data/app/views/admin/shop/categories/edit/_head.html.haml +2 -0
  40. data/app/views/admin/shop/categories/edit/_meta.html.haml +7 -0
  41. data/app/views/admin/shop/categories/edit/_part.html.haml +3 -0
  42. data/app/views/admin/shop/categories/edit/_popup.html.haml +3 -0
  43. data/app/views/admin/shop/categories/edit/meta/_handle.html.haml +5 -0
  44. data/app/views/admin/shop/categories/edit/meta/_layouts.html.haml +10 -0
  45. data/app/views/admin/shop/categories/edit/parts/_description.html.haml +1 -0
  46. data/app/views/admin/shop/categories/index/_category.html.haml +16 -0
  47. data/app/views/admin/shop/categories/new.html.haml +10 -0
  48. data/app/views/admin/shop/categories/remove.html.haml +12 -0
  49. data/app/views/admin/shop/customers/index.html.haml +36 -0
  50. data/app/views/admin/shop/orders/index.html.haml +33 -0
  51. data/app/views/admin/shop/products/edit.html.haml +14 -0
  52. data/app/views/admin/shop/products/edit/_fields.html.haml +38 -0
  53. data/app/views/admin/shop/products/edit/_head.html.haml +2 -0
  54. data/app/views/admin/shop/products/edit/_image.html.haml +12 -0
  55. data/app/views/admin/shop/products/edit/_meta.html.haml +8 -0
  56. data/app/views/admin/shop/products/edit/_part.html.haml +3 -0
  57. data/app/views/admin/shop/products/edit/_popup.html.haml +3 -0
  58. data/app/views/admin/shop/products/edit/buttons/_browse_images.html.haml +1 -0
  59. data/app/views/admin/shop/products/edit/buttons/_new_image.html.haml +1 -0
  60. data/app/views/admin/shop/products/edit/meta/_category.html.haml +5 -0
  61. data/app/views/admin/shop/products/edit/meta/_sku.html.haml +5 -0
  62. data/app/views/admin/shop/products/edit/parts/_description.html.haml +1 -0
  63. data/app/views/admin/shop/products/edit/parts/_images.html.haml +5 -0
  64. data/app/views/admin/shop/products/edit/popups/_browse_images.html.haml +6 -0
  65. data/app/views/admin/shop/products/edit/popups/_new_image.html.haml +18 -0
  66. data/app/views/admin/shop/products/index.html.haml +10 -0
  67. data/app/views/admin/shop/products/index/_bottom.html.haml +5 -0
  68. data/app/views/admin/shop/products/index/_product.html.haml +13 -0
  69. data/app/views/admin/shop/products/new.html.haml +10 -0
  70. data/app/views/admin/shop/products/remove.html.haml +12 -0
  71. data/app/views/shop/categories/show.html.haml +1 -0
  72. data/app/views/shop/orders/show.html.haml +1 -0
  73. data/app/views/shop/products/index.html.haml +1 -0
  74. data/app/views/shop/products/show.html.haml +1 -0
  75. data/config/locales/en.yml +50 -0
  76. data/config/routes.rb +38 -0
  77. data/config/shop_cart.yml +16 -0
  78. data/cucumber.yml +1 -0
  79. data/db/migrate/20100311053701_initial.rb +153 -0
  80. data/db/migrate/20100520033059_create_layouts.rb +119 -0
  81. data/db/migrate/20100903122123_create_forms.rb +44 -0
  82. data/db/migrate/20100908063639_create_snippets.rb +22 -0
  83. data/features/support/env.rb +16 -0
  84. data/features/support/paths.rb +14 -0
  85. data/lib/shop/controllers/application_controller.rb +39 -0
  86. data/lib/shop/controllers/site_controller.rb +12 -0
  87. data/lib/shop/interface/products.rb +49 -0
  88. data/lib/shop/models/image.rb +14 -0
  89. data/lib/shop/models/page.rb +14 -0
  90. data/lib/shop/tags/address.rb +40 -0
  91. data/lib/shop/tags/cart.rb +49 -0
  92. data/lib/shop/tags/category.rb +83 -0
  93. data/lib/shop/tags/core.rb +12 -0
  94. data/lib/shop/tags/helpers.rb +142 -0
  95. data/lib/shop/tags/item.rb +109 -0
  96. data/lib/shop/tags/product.rb +109 -0
  97. data/lib/shop/tags/responses.rb +34 -0
  98. data/lib/tasks/shop_extension_tasks.rake +54 -0
  99. data/mockups/balsamiq/products-retro_fun_tshirt-more.bmml +0 -0
  100. data/mockups/balsamiq/products-retro_fun_tshirt.bmml +0 -0
  101. data/public/images/admin/extensions/shop/products/sort.png +0 -0
  102. data/public/javascripts/admin/extensions/shop/products/edit.js +115 -0
  103. data/public/javascripts/admin/extensions/shop/products/index.js +65 -0
  104. data/public/stylesheets/sass/admin/extensions/shop/edit.sass +86 -0
  105. data/public/stylesheets/sass/admin/extensions/shop/products/edit.sass +158 -0
  106. data/public/stylesheets/sass/admin/extensions/shop/products/index.sass +129 -0
  107. data/radiant-shop-extension.gemspec +245 -0
  108. data/shop_extension.rb +62 -0
  109. data/spec/controllers/admin/shop/categories_controller_spec.rb +443 -0
  110. data/spec/controllers/admin/shop/products/images_controller_spec.rb +477 -0
  111. data/spec/controllers/admin/shop/products_controller_spec.rb +394 -0
  112. data/spec/controllers/admin/shops_controller_spec.rb +19 -0
  113. data/spec/controllers/shop/categories_controller_spec.rb +42 -0
  114. data/spec/controllers/shop/line_items_controller_spec.rb +256 -0
  115. data/spec/controllers/shop/orders_controller_specs.rb +37 -0
  116. data/spec/controllers/shop/products_controller_spec.rb +51 -0
  117. data/spec/datasets/forms.rb +153 -0
  118. data/spec/datasets/images.rb +13 -0
  119. data/spec/datasets/shop_addresses.rb +27 -0
  120. data/spec/datasets/shop_categories.rb +13 -0
  121. data/spec/datasets/shop_line_items.rb +9 -0
  122. data/spec/datasets/shop_orders.rb +21 -0
  123. data/spec/datasets/shop_products.rb +34 -0
  124. data/spec/helpers/nested_tag_helper.rb +33 -0
  125. data/spec/lib/shop/models/image_spec.rb +28 -0
  126. data/spec/lib/shop/models/page_spec.rb +38 -0
  127. data/spec/lib/shop/tags/address_spec.rb +196 -0
  128. data/spec/lib/shop/tags/cart_spec.rb +169 -0
  129. data/spec/lib/shop/tags/category_spec.rb +201 -0
  130. data/spec/lib/shop/tags/core_spec.rb +16 -0
  131. data/spec/lib/shop/tags/helpers_spec.rb +381 -0
  132. data/spec/lib/shop/tags/item_spec.rb +313 -0
  133. data/spec/lib/shop/tags/product_spec.rb +334 -0
  134. data/spec/matchers/comparison.rb +72 -0
  135. data/spec/matchers/render_matcher.rb +33 -0
  136. data/spec/models/form_checkout_spec.rb +376 -0
  137. data/spec/models/shop_category_page_spec.rb +10 -0
  138. data/spec/models/shop_category_spec.rb +58 -0
  139. data/spec/models/shop_line_item_spec.rb +42 -0
  140. data/spec/models/shop_order_spec.rb +228 -0
  141. data/spec/models/shop_product_attachment_spec.rb +72 -0
  142. data/spec/models/shop_product_page_spec.rb +10 -0
  143. data/spec/models/shop_product_spec.rb +135 -0
  144. data/spec/spec.opts +6 -0
  145. data/spec/spec_helper.rb +22 -0
  146. data/vendor/plugins/acts_as_list/README +23 -0
  147. data/vendor/plugins/acts_as_list/init.rb +3 -0
  148. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  149. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  150. data/vendor/plugins/json_fields/.gitignore +3 -0
  151. data/vendor/plugins/json_fields/MIT-LICENSE +20 -0
  152. data/vendor/plugins/json_fields/README.rdoc +65 -0
  153. data/vendor/plugins/json_fields/Rakefile +55 -0
  154. data/vendor/plugins/json_fields/init.rb +2 -0
  155. data/vendor/plugins/json_fields/lib/json_fields.rb +99 -0
  156. data/vendor/plugins/json_fields/spec/lib/json_fields_spec.rb +124 -0
  157. data/vendor/plugins/json_fields/spec/spec.opts +6 -0
  158. data/vendor/plugins/json_fields/spec/spec_helper.rb +29 -0
  159. data/vendor/plugins/json_fields/spec/test_models.rb +12 -0
  160. metadata +324 -0
@@ -0,0 +1,3 @@
1
+ coverage
2
+ .*.swp
3
+ Thumbs.db
@@ -0,0 +1,20 @@
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.
@@ -0,0 +1,65 @@
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
@@ -0,0 +1,55 @@
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 }
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ ActiveRecord::Base.send :include, JsonFields
@@ -0,0 +1,99 @@
1
+ ######
2
+ # JSON-Stored Fields
3
+ # (c) 2008-2009 Aurora Software (http://www.aurorasoft.com.au)
4
+ #
5
+ # http://www.github.com/aurorasoft/json_fields
6
+ #
7
+ ######
8
+
9
+ require 'json'
10
+
11
+ module JsonFields
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ base.class_eval do
15
+ include InstanceMethods
16
+ before_save :store_json_data
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+ def set_json_field(field_name)
22
+ define_method :json_backed_field_name do
23
+ field_name.to_sym
24
+ end
25
+ end
26
+
27
+ def has_json_field(*fields)
28
+ if fields.is_a? Symbol then
29
+ fields=[fields]
30
+ end
31
+ fields.each do |field|
32
+ define_method("#{field.to_s}") do
33
+ json_field_get(field)
34
+ end
35
+ define_method("#{field.to_s}=") do |value|
36
+ json_field_set(field, value)
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ module InstanceMethods
43
+ # Default field name
44
+ def json_backed_field_name
45
+ :json_field
46
+ end
47
+
48
+ def json_field_get(field)
49
+ load_json_data
50
+ # NOTE: to_json forces symbols to string! So, convert here so as that
51
+ # we don't get caught out!
52
+ @json_data[field.to_s]
53
+ end
54
+
55
+ def json_field_set(field, value)
56
+ load_json_data
57
+ # NOTE: to_json forces symbols to string! So, convert here so as that
58
+ # we don't get caught out!
59
+ @json_data ||= {}
60
+ @json_data[field.to_s]=value
61
+ end
62
+
63
+ def load_json_data
64
+ if !respond_to?(:json_backed_field_name) then
65
+ # We don't know which field to use
66
+ raise 'Not a JSON-backed field'
67
+ else
68
+ if @json_data then
69
+ # The data is already loaded - use the version in memory
70
+ else
71
+ # It's not loaded yet - do we have anything to load?
72
+ if self.send(json_backed_field_name).blank? then
73
+ # No data saved as yet - prepare an empty hash
74
+ @json_data = {}
75
+ else
76
+ # We have data - parse it from JSON
77
+ @json_data=JSON.parse(self.send(json_backed_field_name))
78
+ end
79
+ end
80
+ return @json_data
81
+ end
82
+ end
83
+
84
+ # before_save
85
+ # Takes the current data in @json_data and stores it as test_results
86
+ def store_json_data
87
+ if !respond_to?(:json_backed_field_name) then
88
+ # This model doesn't have the data field, so skip it
89
+ return true
90
+ else
91
+ if !@json_data then
92
+ # The JSON data hasn't even been loaded - so, leave the field as is
93
+ else
94
+ self.send("#{json_backed_field_name}=", @json_data.to_json)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,124 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe 'JsonFields' do
4
+ it "should add class methods to ActiveRecord::Base" do
5
+ ActiveRecord::Base.should respond_to(:has_json_field)
6
+ ActiveRecord::Base.should respond_to(:set_json_field)
7
+ end
8
+
9
+ it "should add relevant hooks to before_save" do
10
+ JsonFieldsDefaultTestModel.expects(:before_save).with(:store_json_data)
11
+ JsonFieldsDefaultTestModel.class_eval do
12
+ include JsonFields
13
+ has_json_field :field_1, :field_2, :field_3
14
+ end
15
+ end
16
+
17
+ it "should accept single field to add" do
18
+ JsonFieldsSimpleTestModel.expects(:before_save).with(:store_json_data)
19
+ JsonFieldsSimpleTestModel.class_eval do
20
+ include JsonFields
21
+ has_json_field :field_1
22
+ end
23
+ @i=JsonFieldsSimpleTestModel.new
24
+ @i.should respond_to(:field_1)
25
+ end
26
+
27
+ describe "instance with default field name" do
28
+ before do
29
+ JsonFieldsDefaultTestModel.expects(:before_save).with(:store_json_data)
30
+ JsonFieldsDefaultTestModel.class_eval do
31
+ include JsonFields
32
+ has_json_field :field_1, :field_2, :field_3
33
+ end
34
+ @i=JsonFieldsDefaultTestModel.new
35
+ end
36
+
37
+ it "should respond to added methods" do
38
+ @i.should respond_to(:json_field_get)
39
+ @i.should respond_to(:json_field_set)
40
+ %w( field_1 field_2 field_3 ).each do |field|
41
+ @i.should respond_to(field.to_sym)
42
+ @i.should respond_to("#{field}=".to_sym)
43
+ end
44
+ end
45
+
46
+ it "should get and set fields manually by strings" do
47
+ @i.json_field_set('foo', 100)
48
+ @i.json_field_set('bar', 200)
49
+ @i.instance_variable_get(:@json_data).should == { 'foo' => 100, 'bar' => 200 }
50
+ @i.json_field_get('foo').should == 100
51
+ @i.json_field_get('bar').should == 200
52
+ end
53
+
54
+ it "should manually get missing fields OK" do
55
+ @i.json_field_get('missingfield').should be_nil
56
+ @i.json_field_get(:missingfield).should be_nil
57
+ end
58
+
59
+ it "should get and set fields manually by symbols" do
60
+ @i.json_field_set(:foo, 100)
61
+ @i.json_field_set(:bar, 200)
62
+ # Internally, we store everything as strings because JSON can't handle symbols correctly
63
+ @i.instance_variable_get(:@json_data).should == { 'foo' => 100, 'bar' => 200 }
64
+ @i.json_field_get(:foo).should == 100
65
+ @i.json_field_get(:bar).should == 200
66
+ end
67
+
68
+ it "should get and set fields by the added methods" do
69
+ @i.field_1=100
70
+ @i.field_2=200
71
+ @i.json_field_set(:field_3, 300)
72
+ @i.instance_variable_get(:@json_data).should == { 'field_1' => 100, 'field_2' => 200, 'field_3' => 300 }
73
+ @i.field_1.should == 100
74
+ @i.field_2.should == 200
75
+ @i.field_3.should == 300
76
+ @i.json_field_get(:field_1).should == 100
77
+ @i.json_field_get(:field_2).should == 200
78
+ @i.json_field_get(:field_3).should == 300
79
+ end
80
+
81
+ it "should set field data as JSON before_save" do
82
+ data={ :foo => 100, :bar => 200 }
83
+ data.each do |key, value|
84
+ @i.json_field_set(key, value)
85
+ end
86
+ @i.store_json_data
87
+ @i.json_field.should == '{"foo":100,"bar":200}'
88
+ end
89
+
90
+ it "should load the field data from JSON on first read" do
91
+ @i.stubs(:json_field).returns("{\"a\":50,\"b\":150}")
92
+ @i.json_field_get(:a).should == 50
93
+ @i.json_field_get(:b).should == 150
94
+ end
95
+ end
96
+
97
+ describe "instance with custom field name" do
98
+ before do
99
+ JsonFieldsCustomTestModel.expects(:before_save).with(:store_json_data)
100
+ JsonFieldsCustomTestModel.class_eval do
101
+ include JsonFields
102
+ has_json_field :field_1, :field_2, :field_3
103
+ set_json_field :custom_json_field
104
+ end
105
+ @i=JsonFieldsCustomTestModel.new
106
+ end
107
+
108
+ it "should set field data as JSON before_save" do
109
+ @i.stubs(:custom_json_field).with(nil)
110
+ @i.expects(:custom_json_field=).with('{"foo":100,"bar":200}')
111
+ data={ :foo => 100, :bar => 200 }
112
+ data.each do |key, value|
113
+ @i.json_field_set(key, value)
114
+ end
115
+ @i.store_json_data
116
+ end
117
+
118
+ it "should load the field data from JSON on first read" do
119
+ @i.stubs(:custom_json_field).returns("{\"a\":50,\"b\":150}")
120
+ @i.json_field_get(:a).should == 50
121
+ @i.json_field_get(:b).should == 150
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,29 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
3
+
4
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
5
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
6
+ end
7
+
8
+ require File.dirname(__FILE__) + '/test_models.rb'
9
+ require 'mocha'
10
+
11
+ Spec::Runner.configure do |config|
12
+ # config.use_transactional_fixtures = true
13
+ # config.use_instantiated_fixtures = false
14
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
15
+
16
+ config.mock_with :mocha
17
+
18
+ # You can declare fixtures for each behaviour like this:
19
+ # describe "...." do
20
+ # fixtures :table_a, :table_b
21
+ #
22
+ # Alternatively, if you prefer to declare them only once, you can
23
+ # do so here, like so ...
24
+ #
25
+ # config.global_fixtures = :table_a, :table_b
26
+ #
27
+ # If you declare global fixtures, be aware that they will be declared
28
+ # for all of your examples, even those that don't use them.
29
+ end
@@ -0,0 +1,12 @@
1
+ class JsonFieldsDefaultTestModel
2
+ def json_field
3
+ @json_field
4
+ end
5
+ def json_field=(new)
6
+ @json_field=new
7
+ end
8
+ end
9
+ class JsonFieldsSimpleTestModel < JsonFieldsDefaultTestModel
10
+ end
11
+ class JsonFieldsCustomTestModel < JsonFieldsDefaultTestModel
12
+ end
metadata ADDED
@@ -0,0 +1,324 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-shop-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 63
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 2
10
+ version: 0.9.2
11
+ platform: ruby
12
+ authors:
13
+ - Dirk Kelly
14
+ - John Barker
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-09-23 00:00:00 +08:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: radiant-forms-extension
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 3
33
+ - 1
34
+ - 0
35
+ version: 3.1.0
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: radiant-images-extension
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 25
47
+ segments:
48
+ - 0
49
+ - 1
50
+ - 1
51
+ version: 0.1.1
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: radiant-layouts-extension
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 57
63
+ segments:
64
+ - 0
65
+ - 9
66
+ - 1
67
+ version: 0.9.1
68
+ type: :runtime
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: radiant-settings-extension
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 17
79
+ segments:
80
+ - 1
81
+ - 1
82
+ - 1
83
+ version: 1.1.1
84
+ type: :runtime
85
+ version_requirements: *id004
86
+ description: Shop adds an easy to use api for creating products sold in a shop
87
+ email: dk@dirkkelly.com
88
+ executables: []
89
+
90
+ extensions: []
91
+
92
+ extra_rdoc_files:
93
+ - README.md
94
+ files:
95
+ - .gitignore
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - HISTORY.md
99
+ - MIT-LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - VERSION
103
+ - app/.DS_Store
104
+ - app/controllers/admin/shop/categories_controller.rb
105
+ - app/controllers/admin/shop/customers_controller.rb
106
+ - app/controllers/admin/shop/orders_controller.rb
107
+ - app/controllers/admin/shop/products/images_controller.rb
108
+ - app/controllers/admin/shop/products_controller.rb
109
+ - app/controllers/admin/shops_controller.rb
110
+ - app/controllers/shop/categories_controller.rb
111
+ - app/controllers/shop/line_items_controller.rb
112
+ - app/controllers/shop/orders_controller.rb
113
+ - app/controllers/shop/products_controller.rb
114
+ - app/models/form_checkout.rb
115
+ - app/models/shop_address.rb
116
+ - app/models/shop_addressable.rb
117
+ - app/models/shop_category.rb
118
+ - app/models/shop_category_page.rb
119
+ - app/models/shop_customer.rb
120
+ - app/models/shop_line_item.rb
121
+ - app/models/shop_order.rb
122
+ - app/models/shop_payment.rb
123
+ - app/models/shop_payment_method.rb
124
+ - app/models/shop_product.rb
125
+ - app/models/shop_product_attachment.rb
126
+ - app/models/shop_product_page.rb
127
+ - app/views/.DS_Store
128
+ - app/views/admin/.DS_Store
129
+ - app/views/admin/pages/_shop_category.html.haml
130
+ - app/views/admin/pages/_shop_product.html.haml
131
+ - app/views/admin/shop/categories/edit.html.haml
132
+ - app/views/admin/shop/categories/edit/_fields.html.haml
133
+ - app/views/admin/shop/categories/edit/_head.html.haml
134
+ - app/views/admin/shop/categories/edit/_meta.html.haml
135
+ - app/views/admin/shop/categories/edit/_part.html.haml
136
+ - app/views/admin/shop/categories/edit/_popup.html.haml
137
+ - app/views/admin/shop/categories/edit/meta/_handle.html.haml
138
+ - app/views/admin/shop/categories/edit/meta/_layouts.html.haml
139
+ - app/views/admin/shop/categories/edit/parts/_description.html.haml
140
+ - app/views/admin/shop/categories/index/_category.html.haml
141
+ - app/views/admin/shop/categories/new.html.haml
142
+ - app/views/admin/shop/categories/remove.html.haml
143
+ - app/views/admin/shop/customers/index.html.haml
144
+ - app/views/admin/shop/orders/index.html.haml
145
+ - app/views/admin/shop/products/edit.html.haml
146
+ - app/views/admin/shop/products/edit/_fields.html.haml
147
+ - app/views/admin/shop/products/edit/_head.html.haml
148
+ - app/views/admin/shop/products/edit/_image.html.haml
149
+ - app/views/admin/shop/products/edit/_meta.html.haml
150
+ - app/views/admin/shop/products/edit/_part.html.haml
151
+ - app/views/admin/shop/products/edit/_popup.html.haml
152
+ - app/views/admin/shop/products/edit/buttons/_browse_images.html.haml
153
+ - app/views/admin/shop/products/edit/buttons/_new_image.html.haml
154
+ - app/views/admin/shop/products/edit/meta/_category.html.haml
155
+ - app/views/admin/shop/products/edit/meta/_sku.html.haml
156
+ - app/views/admin/shop/products/edit/parts/_description.html.haml
157
+ - app/views/admin/shop/products/edit/parts/_images.html.haml
158
+ - app/views/admin/shop/products/edit/popups/_browse_images.html.haml
159
+ - app/views/admin/shop/products/edit/popups/_new_image.html.haml
160
+ - app/views/admin/shop/products/index.html.haml
161
+ - app/views/admin/shop/products/index/_bottom.html.haml
162
+ - app/views/admin/shop/products/index/_product.html.haml
163
+ - app/views/admin/shop/products/new.html.haml
164
+ - app/views/admin/shop/products/remove.html.haml
165
+ - app/views/shop/categories/show.html.haml
166
+ - app/views/shop/orders/show.html.haml
167
+ - app/views/shop/products/index.html.haml
168
+ - app/views/shop/products/show.html.haml
169
+ - config/locales/en.yml
170
+ - config/routes.rb
171
+ - config/shop_cart.yml
172
+ - cucumber.yml
173
+ - db/migrate/20100311053701_initial.rb
174
+ - db/migrate/20100520033059_create_layouts.rb
175
+ - db/migrate/20100903122123_create_forms.rb
176
+ - db/migrate/20100908063639_create_snippets.rb
177
+ - features/support/env.rb
178
+ - features/support/paths.rb
179
+ - lib/shop/controllers/application_controller.rb
180
+ - lib/shop/controllers/site_controller.rb
181
+ - lib/shop/interface/products.rb
182
+ - lib/shop/models/image.rb
183
+ - lib/shop/models/page.rb
184
+ - lib/shop/tags/address.rb
185
+ - lib/shop/tags/cart.rb
186
+ - lib/shop/tags/category.rb
187
+ - lib/shop/tags/core.rb
188
+ - lib/shop/tags/helpers.rb
189
+ - lib/shop/tags/item.rb
190
+ - lib/shop/tags/product.rb
191
+ - lib/shop/tags/responses.rb
192
+ - lib/tasks/shop_extension_tasks.rake
193
+ - mockups/balsamiq/products-retro_fun_tshirt-more.bmml
194
+ - mockups/balsamiq/products-retro_fun_tshirt.bmml
195
+ - public/images/admin/extensions/shop/products/sort.png
196
+ - public/javascripts/admin/extensions/shop/products/edit.js
197
+ - public/javascripts/admin/extensions/shop/products/index.js
198
+ - public/stylesheets/sass/admin/extensions/shop/edit.sass
199
+ - public/stylesheets/sass/admin/extensions/shop/products/edit.sass
200
+ - public/stylesheets/sass/admin/extensions/shop/products/index.sass
201
+ - radiant-shop-extension.gemspec
202
+ - shop_extension.rb
203
+ - spec/controllers/admin/shop/categories_controller_spec.rb
204
+ - spec/controllers/admin/shop/products/images_controller_spec.rb
205
+ - spec/controllers/admin/shop/products_controller_spec.rb
206
+ - spec/controllers/admin/shops_controller_spec.rb
207
+ - spec/controllers/shop/categories_controller_spec.rb
208
+ - spec/controllers/shop/line_items_controller_spec.rb
209
+ - spec/controllers/shop/orders_controller_specs.rb
210
+ - spec/controllers/shop/products_controller_spec.rb
211
+ - spec/datasets/forms.rb
212
+ - spec/datasets/images.rb
213
+ - spec/datasets/shop_addresses.rb
214
+ - spec/datasets/shop_categories.rb
215
+ - spec/datasets/shop_line_items.rb
216
+ - spec/datasets/shop_orders.rb
217
+ - spec/datasets/shop_products.rb
218
+ - spec/helpers/nested_tag_helper.rb
219
+ - spec/lib/shop/models/image_spec.rb
220
+ - spec/lib/shop/models/page_spec.rb
221
+ - spec/lib/shop/tags/address_spec.rb
222
+ - spec/lib/shop/tags/cart_spec.rb
223
+ - spec/lib/shop/tags/category_spec.rb
224
+ - spec/lib/shop/tags/core_spec.rb
225
+ - spec/lib/shop/tags/helpers_spec.rb
226
+ - spec/lib/shop/tags/item_spec.rb
227
+ - spec/lib/shop/tags/product_spec.rb
228
+ - spec/matchers/comparison.rb
229
+ - spec/matchers/render_matcher.rb
230
+ - spec/models/form_checkout_spec.rb
231
+ - spec/models/shop_category_page_spec.rb
232
+ - spec/models/shop_category_spec.rb
233
+ - spec/models/shop_line_item_spec.rb
234
+ - spec/models/shop_order_spec.rb
235
+ - spec/models/shop_product_attachment_spec.rb
236
+ - spec/models/shop_product_page_spec.rb
237
+ - spec/models/shop_product_spec.rb
238
+ - spec/spec.opts
239
+ - spec/spec_helper.rb
240
+ - vendor/plugins/acts_as_list/README
241
+ - vendor/plugins/acts_as_list/init.rb
242
+ - vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
243
+ - vendor/plugins/acts_as_list/test/list_test.rb
244
+ - vendor/plugins/json_fields/.gitignore
245
+ - vendor/plugins/json_fields/MIT-LICENSE
246
+ - vendor/plugins/json_fields/README.rdoc
247
+ - vendor/plugins/json_fields/Rakefile
248
+ - vendor/plugins/json_fields/init.rb
249
+ - vendor/plugins/json_fields/lib/json_fields.rb
250
+ - vendor/plugins/json_fields/spec/lib/json_fields_spec.rb
251
+ - vendor/plugins/json_fields/spec/spec.opts
252
+ - vendor/plugins/json_fields/spec/spec_helper.rb
253
+ - vendor/plugins/json_fields/spec/test_models.rb
254
+ has_rdoc: true
255
+ homepage: http://github.com/squaretalent/radiant-shop-extension
256
+ licenses: []
257
+
258
+ post_install_message:
259
+ rdoc_options:
260
+ - --charset=UTF-8
261
+ require_paths:
262
+ - lib
263
+ required_ruby_version: !ruby/object:Gem::Requirement
264
+ none: false
265
+ requirements:
266
+ - - ">="
267
+ - !ruby/object:Gem::Version
268
+ hash: 3
269
+ segments:
270
+ - 0
271
+ version: "0"
272
+ required_rubygems_version: !ruby/object:Gem::Requirement
273
+ none: false
274
+ requirements:
275
+ - - ">="
276
+ - !ruby/object:Gem::Version
277
+ hash: 3
278
+ segments:
279
+ - 0
280
+ version: "0"
281
+ requirements: []
282
+
283
+ rubyforge_project:
284
+ rubygems_version: 1.3.7
285
+ signing_key:
286
+ specification_version: 3
287
+ summary: Shop Extension for Radiant CMS
288
+ test_files:
289
+ - spec/controllers/admin/shop/categories_controller_spec.rb
290
+ - spec/controllers/admin/shop/products/images_controller_spec.rb
291
+ - spec/controllers/admin/shop/products_controller_spec.rb
292
+ - spec/controllers/admin/shops_controller_spec.rb
293
+ - spec/controllers/shop/categories_controller_spec.rb
294
+ - spec/controllers/shop/line_items_controller_spec.rb
295
+ - spec/controllers/shop/orders_controller_specs.rb
296
+ - spec/controllers/shop/products_controller_spec.rb
297
+ - spec/datasets/forms.rb
298
+ - spec/datasets/images.rb
299
+ - spec/datasets/shop_addresses.rb
300
+ - spec/datasets/shop_categories.rb
301
+ - spec/datasets/shop_line_items.rb
302
+ - spec/datasets/shop_orders.rb
303
+ - spec/datasets/shop_products.rb
304
+ - spec/helpers/nested_tag_helper.rb
305
+ - spec/lib/shop/models/image_spec.rb
306
+ - spec/lib/shop/models/page_spec.rb
307
+ - spec/lib/shop/tags/address_spec.rb
308
+ - spec/lib/shop/tags/cart_spec.rb
309
+ - spec/lib/shop/tags/category_spec.rb
310
+ - spec/lib/shop/tags/core_spec.rb
311
+ - spec/lib/shop/tags/helpers_spec.rb
312
+ - spec/lib/shop/tags/item_spec.rb
313
+ - spec/lib/shop/tags/product_spec.rb
314
+ - spec/matchers/comparison.rb
315
+ - spec/matchers/render_matcher.rb
316
+ - spec/models/form_checkout_spec.rb
317
+ - spec/models/shop_category_page_spec.rb
318
+ - spec/models/shop_category_spec.rb
319
+ - spec/models/shop_line_item_spec.rb
320
+ - spec/models/shop_order_spec.rb
321
+ - spec/models/shop_product_attachment_spec.rb
322
+ - spec/models/shop_product_page_spec.rb
323
+ - spec/models/shop_product_spec.rb
324
+ - spec/spec_helper.rb