radiant-shop_discounts-extension 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +1 -0
  3. data/README +3 -0
  4. data/Rakefile +138 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/admin/shop/discounts/discountables_controller.rb +44 -0
  7. data/app/controllers/admin/shop/discounts_controller.rb +64 -0
  8. data/app/models/form_discount.rb +39 -0
  9. data/app/models/shop_discount.rb +37 -0
  10. data/app/models/shop_discountable.rb +64 -0
  11. data/app/views/admin/shop/discounts/edit.html.haml +11 -0
  12. data/app/views/admin/shop/discounts/edit/_foot.html.haml +16 -0
  13. data/app/views/admin/shop/discounts/edit/_form.html.haml +15 -0
  14. data/app/views/admin/shop/discounts/edit/_head.html.haml +4 -0
  15. data/app/views/admin/shop/discounts/edit/_inputs.html.haml +2 -0
  16. data/app/views/admin/shop/discounts/edit/_meta.html.haml +8 -0
  17. data/app/views/admin/shop/discounts/edit/_parts.html.haml +9 -0
  18. data/app/views/admin/shop/discounts/edit/_popups.html.haml +4 -0
  19. data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +1 -0
  20. data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +1 -0
  21. data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +3 -0
  22. data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +3 -0
  23. data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +3 -0
  24. data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +5 -0
  25. data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +5 -0
  26. data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +3 -0
  27. data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +3 -0
  28. data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +6 -0
  29. data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +6 -0
  30. data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +11 -0
  31. data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +12 -0
  32. data/app/views/admin/shop/discounts/index.html.haml +13 -0
  33. data/app/views/admin/shop/discounts/index/_discount.html.haml +13 -0
  34. data/app/views/admin/shop/discounts/index/_foot.html.haml +5 -0
  35. data/app/views/admin/shop/discounts/index/_head.html.haml +2 -0
  36. data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +1 -0
  37. data/app/views/admin/shop/discounts/new.html.haml +11 -0
  38. data/app/views/admin/shop/discounts/remove.html.haml +12 -0
  39. data/config/locales/en.yml +17 -0
  40. data/config/routes.rb +17 -0
  41. data/cucumber.yml +1 -0
  42. data/db/migrate/20101015162137_setup_shop_discounts.rb +30 -0
  43. data/features/support/env.rb +16 -0
  44. data/features/support/paths.rb +14 -0
  45. data/lib/shop_discounts/models/discountable.rb +14 -0
  46. data/lib/shop_discounts/models/product.rb +20 -0
  47. data/lib/shop_discounts/models/purchaseable.rb +33 -0
  48. data/lib/shop_discounts/tags/cart.rb +18 -0
  49. data/lib/shop_discounts/tags/item.rb +30 -0
  50. data/lib/tasks/shop_discounts_extension_tasks.rake +55 -0
  51. data/public/javascripts/admin/extensions/shop/discounts/edit.js +76 -0
  52. data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +125 -0
  53. data/radiant-shop_discounts-extension.gemspec +124 -0
  54. data/shop_discounts_extension.rb +31 -0
  55. data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +72 -0
  56. data/spec/controllers/admin/shop/discounts_controller_spec.rb +81 -0
  57. data/spec/datasets/forms_discount.rb +24 -0
  58. data/spec/datasets/shop_discountables.rb +22 -0
  59. data/spec/datasets/shop_discounts.rb +34 -0
  60. data/spec/lib/shop_discounts/models/discountable_spec.rb +114 -0
  61. data/spec/lib/shop_discounts/models/purchaseable_spec.rb +55 -0
  62. data/spec/lib/shop_discounts/tags/item_spec.rb +96 -0
  63. data/spec/models/form_discount_spec.rb +63 -0
  64. data/spec/models/shop_category_spec.rb +19 -0
  65. data/spec/models/shop_discount_spec.rb +130 -0
  66. data/spec/models/shop_line_item_spec.rb +15 -0
  67. data/spec/models/shop_product_spec.rb +40 -0
  68. data/spec/spec.opts +3 -0
  69. data/spec/spec_helper.rb +23 -0
  70. metadata +161 -0
@@ -0,0 +1,15 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe ShopLineItem do
4
+
5
+ dataset :shop_line_items, :shop_products, :shop_discountables
6
+
7
+ context 'line item with a discount' do
8
+ it 'should calculate a reduced price' do
9
+ price = shop_line_items(:one).price
10
+ ShopDiscountable.create(:discount => shop_discounts(:ten_percent), :discounted => shop_line_items(:one))
11
+ shop_line_items(:one).price.should === (price-price*0.1)
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe ShopProduct do
4
+ dataset :shop_products, :shop_line_items, :shop_discountables
5
+
6
+
7
+ describe 'relationships' do
8
+ before :each do
9
+ @product = shop_products(:crusty_bread)
10
+ end
11
+
12
+ it 'should have many discountables' do
13
+ @product.discountables.is_a?(Array).should be_true
14
+ end
15
+
16
+ it 'should have many discounts' do
17
+ @product.discounts.is_a?(Array).should be_true
18
+ end
19
+ end
20
+
21
+ context 'discounts' do
22
+ context 'after_create' do
23
+ it 'should assign its categories discounts to itself' do
24
+ @product = ShopProduct.new(
25
+ :price => 11.11,
26
+ :page_attributes => {
27
+ :title => 'New Page With Discounts',
28
+ :slug => 'new_page_with_discounts',
29
+ :parent_id => shop_categories(:bread).id
30
+ }
31
+ )
32
+ @product.discounts.empty?.should === true
33
+ @product.save
34
+
35
+ ShopProduct.find(@product).discounts.should === shop_categories(:bread).discounts
36
+ end
37
+ end
38
+ end
39
+
40
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format specdoc
3
+ --loadby mtime
@@ -0,0 +1,23 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/../../shop/spec/datasets")
15
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
16
+
17
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
18
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
19
+ end
20
+
21
+ Spec::Runner.configure do |config|
22
+ config.mock_with :rr
23
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-shop_discounts-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Dirk Kelly
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-10 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ name: radiant-shop-extension
34
+ requirement: *id001
35
+ description: "RadiantShop: Apply discounts to Products and Categories and have them accessed through codes"
36
+ email: dk@dirkkelly.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README
43
+ files:
44
+ - .DS_Store
45
+ - .gitignore
46
+ - README
47
+ - Rakefile
48
+ - VERSION
49
+ - app/controllers/admin/shop/discounts/discountables_controller.rb
50
+ - app/controllers/admin/shop/discounts_controller.rb
51
+ - app/models/form_discount.rb
52
+ - app/models/shop_discount.rb
53
+ - app/models/shop_discountable.rb
54
+ - app/views/admin/shop/discounts/edit.html.haml
55
+ - app/views/admin/shop/discounts/edit/_foot.html.haml
56
+ - app/views/admin/shop/discounts/edit/_form.html.haml
57
+ - app/views/admin/shop/discounts/edit/_head.html.haml
58
+ - app/views/admin/shop/discounts/edit/_inputs.html.haml
59
+ - app/views/admin/shop/discounts/edit/_meta.html.haml
60
+ - app/views/admin/shop/discounts/edit/_parts.html.haml
61
+ - app/views/admin/shop/discounts/edit/_popups.html.haml
62
+ - app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml
63
+ - app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml
64
+ - app/views/admin/shop/discounts/edit/inputs/_amount.html.haml
65
+ - app/views/admin/shop/discounts/edit/inputs/_code.html.haml
66
+ - app/views/admin/shop/discounts/edit/inputs/_name.html.haml
67
+ - app/views/admin/shop/discounts/edit/meta/_finish.html.haml
68
+ - app/views/admin/shop/discounts/edit/meta/_start.html.haml
69
+ - app/views/admin/shop/discounts/edit/parts/_categories.html.haml
70
+ - app/views/admin/shop/discounts/edit/parts/_products.html.haml
71
+ - app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml
72
+ - app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml
73
+ - app/views/admin/shop/discounts/edit/shared/_category.html.haml
74
+ - app/views/admin/shop/discounts/edit/shared/_product.html.haml
75
+ - app/views/admin/shop/discounts/index.html.haml
76
+ - app/views/admin/shop/discounts/index/_discount.html.haml
77
+ - app/views/admin/shop/discounts/index/_foot.html.haml
78
+ - app/views/admin/shop/discounts/index/_head.html.haml
79
+ - app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml
80
+ - app/views/admin/shop/discounts/new.html.haml
81
+ - app/views/admin/shop/discounts/remove.html.haml
82
+ - config/locales/en.yml
83
+ - config/routes.rb
84
+ - cucumber.yml
85
+ - db/migrate/20101015162137_setup_shop_discounts.rb
86
+ - features/support/env.rb
87
+ - features/support/paths.rb
88
+ - lib/shop_discounts/models/discountable.rb
89
+ - lib/shop_discounts/models/product.rb
90
+ - lib/shop_discounts/models/purchaseable.rb
91
+ - lib/shop_discounts/tags/cart.rb
92
+ - lib/shop_discounts/tags/item.rb
93
+ - lib/tasks/shop_discounts_extension_tasks.rake
94
+ - public/javascripts/admin/extensions/shop/discounts/edit.js
95
+ - public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass
96
+ - radiant-shop_discounts-extension.gemspec
97
+ - shop_discounts_extension.rb
98
+ - spec/controllers/admin/shop/discounts/discountables_controller_spec.rb
99
+ - spec/controllers/admin/shop/discounts_controller_spec.rb
100
+ - spec/datasets/forms_discount.rb
101
+ - spec/datasets/shop_discountables.rb
102
+ - spec/datasets/shop_discounts.rb
103
+ - spec/lib/shop_discounts/models/discountable_spec.rb
104
+ - spec/lib/shop_discounts/models/purchaseable_spec.rb
105
+ - spec/lib/shop_discounts/tags/item_spec.rb
106
+ - spec/models/form_discount_spec.rb
107
+ - spec/models/shop_category_spec.rb
108
+ - spec/models/shop_discount_spec.rb
109
+ - spec/models/shop_line_item_spec.rb
110
+ - spec/models/shop_product_spec.rb
111
+ - spec/spec.opts
112
+ - spec/spec_helper.rb
113
+ has_rdoc: true
114
+ homepage: http://github.com/thefrontiergroup/shop_discounts
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options:
119
+ - --charset=UTF-8
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.7
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Shop Discounts Extension for Radiant CMS
147
+ test_files:
148
+ - spec/controllers/admin/shop/discounts/discountables_controller_spec.rb
149
+ - spec/controllers/admin/shop/discounts_controller_spec.rb
150
+ - spec/datasets/forms_discount.rb
151
+ - spec/datasets/shop_discountables.rb
152
+ - spec/datasets/shop_discounts.rb
153
+ - spec/lib/shop_discounts/models/discountable_spec.rb
154
+ - spec/lib/shop_discounts/models/purchaseable_spec.rb
155
+ - spec/lib/shop_discounts/tags/item_spec.rb
156
+ - spec/models/form_discount_spec.rb
157
+ - spec/models/shop_category_spec.rb
158
+ - spec/models/shop_discount_spec.rb
159
+ - spec/models/shop_line_item_spec.rb
160
+ - spec/models/shop_product_spec.rb
161
+ - spec/spec_helper.rb