muck-commerce 0.1.9 → 0.2.0
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/README.rdoc +6 -0
- data/VERSION +1 -1
- data/app/controllers/muck/billing_informations_controller.rb +1 -1
- data/app/controllers/muck/orders_controller.rb +22 -10
- data/app/controllers/muck/subscriptions_controller.rb +1 -1
- data/db/migrate/20100408035338_move_customer_profile_id.rb +18 -0
- data/lib/action_controller/muck_billing_application.rb +2 -2
- data/lib/active_record/acts/muck_billing_information.rb +2 -2
- data/lib/active_record/acts/muck_cart_item.rb +38 -0
- data/lib/active_record/acts/muck_commerce_user.rb +5 -0
- data/lib/active_record/acts/muck_order.rb +5 -3
- data/lib/active_record/acts/muck_order_transaction.rb +117 -73
- data/lib/test/muck_commerce_factories.rb +26 -17
- data/locales/en.yml +6 -1
- data/muck-commerce.gemspec +10 -2
- data/test/rails_root/app/models/billing_information.rb +36 -1
- data/test/rails_root/app/models/cart.rb +12 -0
- data/test/rails_root/app/models/cart_coupon.rb +11 -0
- data/test/rails_root/app/models/coupon.rb +21 -1
- data/test/rails_root/app/models/coupon_type.rb +9 -1
- data/test/rails_root/app/models/order.rb +21 -1
- data/test/rails_root/app/models/order_coupon.rb +12 -1
- data/test/rails_root/app/models/order_transaction.rb +20 -1
- data/test/rails_root/app/models/profile.rb +23 -0
- data/test/rails_root/app/models/subscription.rb +22 -1
- data/test/rails_root/app/models/subscription_plan.rb +15 -1
- data/test/rails_root/app/models/user.rb +33 -1
- data/test/rails_root/config/environment.rb +1 -1
- data/test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb +18 -0
- data/test/rails_root/remote/functional/remote_orders_controller_test.rb +58 -58
- data/test/rails_root/remote/functional/remote_subscriptions_controller_test.rb +9 -0
- data/test/rails_root/remote/remote_helper.rb +44 -15
- data/test/rails_root/remote/unit/remote_order_test.rb +7 -8
- data/test/rails_root/remote/unit/remote_order_transaction_test.rb +60 -34
- data/test/rails_root/test/functional/admin/billing_informations_controller_test.rb +7 -8
- data/test/rails_root/test/unit/billing_information_test.rb +78 -0
- data/test/rails_root/test/unit/cart_coupon_test.rb +12 -1
- data/test/rails_root/test/unit/coupon_test.rb +21 -1
- data/test/rails_root/test/unit/coupon_type_test.rb +9 -1
- data/test/rails_root/test/unit/order_test.rb +21 -1
- data/test/rails_root/test/unit/order_transaction_test.rb +19 -0
- data/test/rails_root/test/unit/subscription_test.rb +40 -9
- data/test/rails_root/test/unit/user_test.rb +33 -1
- metadata +12 -4
@@ -8,14 +8,6 @@ class Admin::Muck::BillingInformationsControllerTest < ActionController::TestCas
|
|
8
8
|
|
9
9
|
should_require_login :edit => :get, :update => :put, :login_url => '/login'
|
10
10
|
|
11
|
-
setup do
|
12
|
-
@user = Factory(:user)
|
13
|
-
@billing_information = Factory(:billing_information, :billable => @user)
|
14
|
-
@transaction_response = OrderTransaction.new
|
15
|
-
@transaction_response.stubs(:success?).returns(true)
|
16
|
-
OrderTransaction.stubs(:cim_create_update).returns(@transaction_response)
|
17
|
-
end
|
18
|
-
|
19
11
|
context "logged in not admin" do
|
20
12
|
setup do
|
21
13
|
@user = Factory(:user)
|
@@ -27,6 +19,13 @@ class Admin::Muck::BillingInformationsControllerTest < ActionController::TestCas
|
|
27
19
|
|
28
20
|
context "logged in as admin" do
|
29
21
|
setup do
|
22
|
+
User.destroy_all
|
23
|
+
@user = Factory(:user)
|
24
|
+
@billing_information = Factory(:billing_information, :billable => @user)
|
25
|
+
@transaction_response = OrderTransaction.new
|
26
|
+
@transaction_response.stubs(:success?).returns(true)
|
27
|
+
OrderTransaction.stubs(:cim_create_update).returns(@transaction_response)
|
28
|
+
|
30
29
|
activate_authlogic
|
31
30
|
@admin = Factory(:user)
|
32
31
|
@admin_role = Factory(:role, :rolename => 'administrator')
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: billing_informations
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# billable_id :integer(4)
|
7
|
+
# billable_type :string(255)
|
8
|
+
# first_name :string(128) default(""), not null
|
9
|
+
# last_name :string(128) default(""), not null
|
10
|
+
# address1 :string(512) default(""), not null
|
11
|
+
# address2 :string(512)
|
12
|
+
# city :string(128) default(""), not null
|
13
|
+
# state_id :integer(4)
|
14
|
+
# country_id :integer(4)
|
15
|
+
# postal_code :string(255) default(""), not null
|
16
|
+
# telephone :string(255) default(""), not null
|
17
|
+
# payment_method :string(255) default("CC")
|
18
|
+
# credit_card_type :string(255)
|
19
|
+
# credit_card_last_digits :string(4)
|
20
|
+
# credit_card_expiration :datetime
|
21
|
+
# achname :string(1024)
|
22
|
+
# achrouting :string(1024)
|
23
|
+
# achnumber :string(1024)
|
24
|
+
# achholder :string(1024)
|
25
|
+
# achtype :string(64)
|
26
|
+
# vault_id :string(512)
|
27
|
+
# customer_profile_id :string(512)
|
28
|
+
# customer_payment_profile_id :string(512)
|
29
|
+
# default :boolean(1)
|
30
|
+
# created_at :datetime
|
31
|
+
# updated_at :datetime
|
32
|
+
# name :string(256)
|
33
|
+
# company :string(256)
|
34
|
+
#
|
35
|
+
|
36
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
37
|
+
|
38
|
+
class BillingInformationTest < ActiveSupport::TestCase
|
39
|
+
|
40
|
+
context 'A billing_information instance that acts_as_muck_billing_information' do
|
41
|
+
setup do
|
42
|
+
@billing_information = Factory(:billing_information)
|
43
|
+
end
|
44
|
+
subject { @billing_information }
|
45
|
+
|
46
|
+
should_belong_to :billable
|
47
|
+
should_belong_to :state
|
48
|
+
should_belong_to :country
|
49
|
+
|
50
|
+
should_validate_presence_of :credit_card_number
|
51
|
+
should_validate_presence_of :credit_card_expiration
|
52
|
+
should_validate_presence_of :achname
|
53
|
+
should_validate_presence_of :achrouting
|
54
|
+
should_validate_presence_of :achnumber
|
55
|
+
should_validate_presence_of :verification_value
|
56
|
+
|
57
|
+
should "have verification value" do
|
58
|
+
assert_not_nil @billing_information.verification_value
|
59
|
+
end
|
60
|
+
|
61
|
+
context "named scope" do
|
62
|
+
should_scope_by_newest
|
63
|
+
context "scope by default" do
|
64
|
+
@default = Factory(:billing_information, :default => true)
|
65
|
+
@non_default = Factory(:billing_information, :default => false)
|
66
|
+
end
|
67
|
+
should "find default" do
|
68
|
+
assert BillingInformation.default.include?(@default)
|
69
|
+
end
|
70
|
+
should "not find nondefault" do
|
71
|
+
assert BillingInformation.default.include?(@non_default)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -1,3 +1,14 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: cart_coupons
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# cart_id :integer(4)
|
7
|
+
# coupon_id :integer(4)
|
8
|
+
# created_at :datetime
|
9
|
+
# updated_at :datetime
|
10
|
+
#
|
11
|
+
|
1
12
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
13
|
|
3
14
|
class CartCouponTest < ActiveSupport::TestCase
|
@@ -13,4 +24,4 @@ class CartCouponTest < ActiveSupport::TestCase
|
|
13
24
|
|
14
25
|
end
|
15
26
|
|
16
|
-
end
|
27
|
+
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: coupons
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# code :string(255)
|
7
|
+
# amount :integer(4) default(0), not null
|
8
|
+
# percent :integer(4) default(0), not null
|
9
|
+
# uses :integer(4) default(0), not null
|
10
|
+
# unlimited :boolean(1) not null
|
11
|
+
# expires_at :datetime
|
12
|
+
# use_limit :integer(4) default(1), not null
|
13
|
+
# created_at :datetime
|
14
|
+
# updated_at :datetime
|
15
|
+
# use_for_times :integer(4)
|
16
|
+
# use_for_months :integer(4)
|
17
|
+
# user_id :integer(4)
|
18
|
+
# coupon_type_id :integer(4)
|
19
|
+
#
|
20
|
+
|
1
21
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
22
|
|
3
23
|
class CouponTest < ActiveSupport::TestCase
|
@@ -62,4 +82,4 @@ class CouponTest < ActiveSupport::TestCase
|
|
62
82
|
|
63
83
|
end
|
64
84
|
|
65
|
-
end
|
85
|
+
end
|
@@ -1,3 +1,11 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: coupon_types
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# name :string(255)
|
7
|
+
#
|
8
|
+
|
1
9
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
10
|
|
3
11
|
class CouponTypeTest < ActiveSupport::TestCase
|
@@ -21,4 +29,4 @@ class CouponTypeTest < ActiveSupport::TestCase
|
|
21
29
|
|
22
30
|
end
|
23
31
|
|
24
|
-
end
|
32
|
+
end
|
@@ -1,3 +1,23 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: orders
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# orderable_id :integer(4)
|
7
|
+
# orderable_type :string(255)
|
8
|
+
# amount :integer(4)
|
9
|
+
# discount :integer(4)
|
10
|
+
# number :string(255)
|
11
|
+
# first_name :string(255)
|
12
|
+
# last_name :string(255)
|
13
|
+
# ip_address :string(255)
|
14
|
+
# express_token :string(255)
|
15
|
+
# express_payer_id :string(255)
|
16
|
+
# order_type :string(255)
|
17
|
+
# created_at :datetime
|
18
|
+
# updated_at :datetime
|
19
|
+
#
|
20
|
+
|
1
21
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
22
|
|
3
23
|
class OrderTest < ActiveSupport::TestCase
|
@@ -93,4 +113,4 @@ class OrderTest < ActiveSupport::TestCase
|
|
93
113
|
|
94
114
|
end
|
95
115
|
|
96
|
-
end
|
116
|
+
end
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: order_transactions
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# amount :integer(4)
|
7
|
+
# success :boolean(1)
|
8
|
+
# reference :string(255)
|
9
|
+
# message :string(255)
|
10
|
+
# action :string(255)
|
11
|
+
# params :text
|
12
|
+
# test :boolean(1)
|
13
|
+
# transactionable_id :integer(4)
|
14
|
+
# transactionable_type :string(255)
|
15
|
+
# response_code :integer(4)
|
16
|
+
# created_at :datetime
|
17
|
+
# updated_at :datetime
|
18
|
+
#
|
19
|
+
|
1
20
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
21
|
|
3
22
|
class OrderTransactionTest < ActiveSupport::TestCase
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: subscriptions
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# user_id :integer(4)
|
7
|
+
# amount :integer(4)
|
8
|
+
# next_renewal_at :datetime
|
9
|
+
# aasm_state :string(255) default("trial")
|
10
|
+
# subscription_plan_id :integer(4)
|
11
|
+
# renewal_period :integer(4)
|
12
|
+
# number :string(255)
|
13
|
+
# failed_billing_attempts :integer(4) default(0), not null
|
14
|
+
# cancelled_at :datetime
|
15
|
+
# suspended_at :datetime
|
16
|
+
# activated_at :datetime
|
17
|
+
# default :boolean(1)
|
18
|
+
# created_at :datetime
|
19
|
+
# updated_at :datetime
|
20
|
+
#
|
21
|
+
|
1
22
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
23
|
|
3
24
|
class SubscriptionTest < ActiveSupport::TestCase
|
@@ -5,17 +26,20 @@ class SubscriptionTest < ActiveSupport::TestCase
|
|
5
26
|
include MuckCommerceTestDefinitions
|
6
27
|
|
7
28
|
context "Subscription Instance" do
|
29
|
+
|
8
30
|
setup do
|
9
31
|
@subscription = Factory(:subscription)
|
10
32
|
end
|
33
|
+
|
11
34
|
subject { @subscription }
|
35
|
+
|
12
36
|
should_belong_to :user
|
13
37
|
should_belong_to :subscription_plan
|
14
38
|
|
15
39
|
should_have_many :subscription_records
|
16
40
|
should_have_many :order_coupons
|
17
41
|
should_have_many :coupons, :through => :subscription_coupons
|
18
|
-
should_have_many :order_transactions
|
42
|
+
should_have_many :order_transactions
|
19
43
|
|
20
44
|
should_validate_presence_of :amount
|
21
45
|
should_validate_presence_of :user
|
@@ -144,16 +168,23 @@ class SubscriptionTest < ActiveSupport::TestCase
|
|
144
168
|
end
|
145
169
|
end
|
146
170
|
|
147
|
-
context "
|
148
|
-
|
149
|
-
|
171
|
+
context "subscription methods" do
|
172
|
+
setup do
|
173
|
+
@user, @billing_information = setup_user_and_billing
|
174
|
+
@subscription_plan = Factory(:subscription_plan)
|
175
|
+
end
|
176
|
+
|
177
|
+
context "authorize_subscription" do
|
178
|
+
Subscription.authorize_subscription(@user)
|
179
|
+
end
|
150
180
|
|
151
|
-
|
152
|
-
|
153
|
-
|
181
|
+
context "subscribe" do
|
182
|
+
Subscription.subscribe(@user, @subscription_plan.id)
|
183
|
+
end
|
154
184
|
|
155
|
-
|
156
|
-
|
185
|
+
context "subscribe_custom" do
|
186
|
+
Subscription.subscribe_custom(@user, 1000)
|
187
|
+
end
|
157
188
|
end
|
158
189
|
|
159
190
|
end
|
@@ -1,3 +1,35 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: users
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# login :string(255)
|
7
|
+
# email :string(255)
|
8
|
+
# first_name :string(255)
|
9
|
+
# last_name :string(255)
|
10
|
+
# crypted_password :string(255)
|
11
|
+
# password_salt :string(255)
|
12
|
+
# persistence_token :string(255) not null
|
13
|
+
# single_access_token :string(255) not null
|
14
|
+
# perishable_token :string(255) not null
|
15
|
+
# login_count :integer(4) default(0), not null
|
16
|
+
# failed_login_count :integer(4) default(0), not null
|
17
|
+
# last_request_at :datetime
|
18
|
+
# current_login_at :datetime
|
19
|
+
# last_login_at :datetime
|
20
|
+
# current_login_ip :string(255)
|
21
|
+
# last_login_ip :string(255)
|
22
|
+
# terms_of_service :boolean(1) not null
|
23
|
+
# time_zone :string(255) default("UTC")
|
24
|
+
# disabled_at :datetime
|
25
|
+
# created_at :datetime
|
26
|
+
# activated_at :datetime
|
27
|
+
# updated_at :datetime
|
28
|
+
# identity_url :string(255)
|
29
|
+
# url_key :string(255)
|
30
|
+
# access_code_id :integer(4)
|
31
|
+
#
|
32
|
+
|
1
33
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
34
|
|
3
35
|
class UserTest < ActiveSupport::TestCase
|
@@ -68,4 +100,4 @@ class UserTest < ActiveSupport::TestCase
|
|
68
100
|
end
|
69
101
|
end
|
70
102
|
|
71
|
-
end
|
103
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Justin Ball
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-04-08 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -153,10 +153,12 @@ files:
|
|
153
153
|
- db/migrate/20100309183304_add_coupon_subscrption_uses.rb
|
154
154
|
- db/migrate/20100310180031_create_coupon_types.rb
|
155
155
|
- db/migrate/20100327171239_add_subscription_records.rb
|
156
|
+
- db/migrate/20100408035338_move_customer_profile_id.rb
|
156
157
|
- lib/action_controller/muck_billing_application.rb
|
157
158
|
- lib/active_record/acts/muck_billing_information.rb
|
158
159
|
- lib/active_record/acts/muck_cart.rb
|
159
160
|
- lib/active_record/acts/muck_cart_coupon.rb
|
161
|
+
- lib/active_record/acts/muck_cart_item.rb
|
160
162
|
- lib/active_record/acts/muck_commerce_user.rb
|
161
163
|
- lib/active_record/acts/muck_coupon.rb
|
162
164
|
- lib/active_record/acts/muck_coupon_type.rb
|
@@ -236,6 +238,7 @@ files:
|
|
236
238
|
- test/rails_root/db/migrate/20100309183304_add_coupon_subscrption_uses.rb
|
237
239
|
- test/rails_root/db/migrate/20100310180031_create_coupon_types.rb
|
238
240
|
- test/rails_root/db/migrate/20100327171239_add_subscription_records.rb
|
241
|
+
- test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb
|
239
242
|
- test/rails_root/features/step_definitions/webrat_steps.rb
|
240
243
|
- test/rails_root/features/support/env.rb
|
241
244
|
- test/rails_root/lib/tasks/muck.rake
|
@@ -798,6 +801,7 @@ files:
|
|
798
801
|
- test/rails_root/public/stylesheets/themes/blue/styles.css
|
799
802
|
- test/rails_root/public/stylesheets/themes/red/styles.css
|
800
803
|
- test/rails_root/remote/functional/remote_orders_controller_test.rb
|
804
|
+
- test/rails_root/remote/functional/remote_subscriptions_controller_test.rb
|
801
805
|
- test/rails_root/remote/remote_helper.rb
|
802
806
|
- test/rails_root/remote/unit/remote_order_test.rb
|
803
807
|
- test/rails_root/remote/unit/remote_order_transaction_test.rb
|
@@ -826,6 +830,7 @@ files:
|
|
826
830
|
- test/rails_root/test/functional/orders_controller_test.rb
|
827
831
|
- test/rails_root/test/functional/subscription_controller_test.rb
|
828
832
|
- test/rails_root/test/test_helper.rb
|
833
|
+
- test/rails_root/test/unit/billing_information_test.rb
|
829
834
|
- test/rails_root/test/unit/cart_coupon_test.rb
|
830
835
|
- test/rails_root/test/unit/coupon_test.rb
|
831
836
|
- test/rails_root/test/unit/coupon_type_test.rb
|
@@ -956,10 +961,12 @@ test_files:
|
|
956
961
|
- test/rails_root/db/migrate/20100309183304_add_coupon_subscrption_uses.rb
|
957
962
|
- test/rails_root/db/migrate/20100310180031_create_coupon_types.rb
|
958
963
|
- test/rails_root/db/migrate/20100327171239_add_subscription_records.rb
|
964
|
+
- test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb
|
959
965
|
- test/rails_root/features/step_definitions/webrat_steps.rb
|
960
966
|
- test/rails_root/features/support/env.rb
|
961
967
|
- test/rails_root/public/dispatch.rb
|
962
968
|
- test/rails_root/remote/functional/remote_orders_controller_test.rb
|
969
|
+
- test/rails_root/remote/functional/remote_subscriptions_controller_test.rb
|
963
970
|
- test/rails_root/remote/remote_helper.rb
|
964
971
|
- test/rails_root/remote/unit/remote_order_test.rb
|
965
972
|
- test/rails_root/remote/unit/remote_order_transaction_test.rb
|
@@ -972,6 +979,7 @@ test_files:
|
|
972
979
|
- test/rails_root/test/functional/orders_controller_test.rb
|
973
980
|
- test/rails_root/test/functional/subscription_controller_test.rb
|
974
981
|
- test/rails_root/test/test_helper.rb
|
982
|
+
- test/rails_root/test/unit/billing_information_test.rb
|
975
983
|
- test/rails_root/test/unit/cart_coupon_test.rb
|
976
984
|
- test/rails_root/test/unit/coupon_test.rb
|
977
985
|
- test/rails_root/test/unit/coupon_type_test.rb
|