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.
Files changed (44) hide show
  1. data/README.rdoc +6 -0
  2. data/VERSION +1 -1
  3. data/app/controllers/muck/billing_informations_controller.rb +1 -1
  4. data/app/controllers/muck/orders_controller.rb +22 -10
  5. data/app/controllers/muck/subscriptions_controller.rb +1 -1
  6. data/db/migrate/20100408035338_move_customer_profile_id.rb +18 -0
  7. data/lib/action_controller/muck_billing_application.rb +2 -2
  8. data/lib/active_record/acts/muck_billing_information.rb +2 -2
  9. data/lib/active_record/acts/muck_cart_item.rb +38 -0
  10. data/lib/active_record/acts/muck_commerce_user.rb +5 -0
  11. data/lib/active_record/acts/muck_order.rb +5 -3
  12. data/lib/active_record/acts/muck_order_transaction.rb +117 -73
  13. data/lib/test/muck_commerce_factories.rb +26 -17
  14. data/locales/en.yml +6 -1
  15. data/muck-commerce.gemspec +10 -2
  16. data/test/rails_root/app/models/billing_information.rb +36 -1
  17. data/test/rails_root/app/models/cart.rb +12 -0
  18. data/test/rails_root/app/models/cart_coupon.rb +11 -0
  19. data/test/rails_root/app/models/coupon.rb +21 -1
  20. data/test/rails_root/app/models/coupon_type.rb +9 -1
  21. data/test/rails_root/app/models/order.rb +21 -1
  22. data/test/rails_root/app/models/order_coupon.rb +12 -1
  23. data/test/rails_root/app/models/order_transaction.rb +20 -1
  24. data/test/rails_root/app/models/profile.rb +23 -0
  25. data/test/rails_root/app/models/subscription.rb +22 -1
  26. data/test/rails_root/app/models/subscription_plan.rb +15 -1
  27. data/test/rails_root/app/models/user.rb +33 -1
  28. data/test/rails_root/config/environment.rb +1 -1
  29. data/test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb +18 -0
  30. data/test/rails_root/remote/functional/remote_orders_controller_test.rb +58 -58
  31. data/test/rails_root/remote/functional/remote_subscriptions_controller_test.rb +9 -0
  32. data/test/rails_root/remote/remote_helper.rb +44 -15
  33. data/test/rails_root/remote/unit/remote_order_test.rb +7 -8
  34. data/test/rails_root/remote/unit/remote_order_transaction_test.rb +60 -34
  35. data/test/rails_root/test/functional/admin/billing_informations_controller_test.rb +7 -8
  36. data/test/rails_root/test/unit/billing_information_test.rb +78 -0
  37. data/test/rails_root/test/unit/cart_coupon_test.rb +12 -1
  38. data/test/rails_root/test/unit/coupon_test.rb +21 -1
  39. data/test/rails_root/test/unit/coupon_type_test.rb +9 -1
  40. data/test/rails_root/test/unit/order_test.rb +21 -1
  41. data/test/rails_root/test/unit/order_transaction_test.rb +19 -0
  42. data/test/rails_root/test/unit/subscription_test.rb +40 -9
  43. data/test/rails_root/test/unit/user_test.rb +33 -1
  44. metadata +12 -4
@@ -3,11 +3,11 @@ Factory.sequence :sku do |n|
3
3
  end
4
4
 
5
5
  Factory.define :billing_information do |f|
6
- f.first_name 'test'
7
- f.last_name 'guy'
8
- f.name 'test guy'
6
+ f.first_name { Factory.next(:name) }
7
+ f.last_name { Factory.next(:name) }
8
+ f.name { Factory.next(:name) }
9
9
  f.company { Factory.next(:name) }
10
- f.address1 '345 E'
10
+ f.address1 { Factory.next(:address) }
11
11
  f.city { Factory.next(:name) }
12
12
  f.state {|a| a.association(:state) }
13
13
  f.country {|a| a.association(:country) }
@@ -23,10 +23,10 @@ Factory.define :billing_information do |f|
23
23
  end
24
24
 
25
25
  Factory.define :live_billing_information, :class => BillingInformation do |f|
26
- f.first_name 'test'
27
- f.last_name 'guy'
28
- f.address1 '345 E'
29
- f.city 'smalltown'
26
+ f.first_name { Factory.next(:name) }
27
+ f.last_name { Factory.next(:name) }
28
+ f.address1 { Factory.next(:address) }
29
+ f.city { Factory.next(:name) }
30
30
  f.state {|a| a.association(:state) }
31
31
  f.country {|a| a.association(:country) }
32
32
  f.postal_code '88888'
@@ -36,20 +36,21 @@ Factory.define :live_billing_information, :class => BillingInformation do |f|
36
36
  f.credit_card_number MuckCommerceTestDefinitions::PAYPAL_VISA
37
37
  f.credit_card_expiration { Date.new((DateTime.now.year + 2), 10, 10) }
38
38
  f.verification_value '999'
39
+ f.default true
39
40
  f.billable {|a| a.association(:user) }
40
41
  end
41
42
 
42
43
  Factory.define :ach_billing, :class => BillingInformation do |f|
43
- f.first_name 'test'
44
- f.last_name 'guy'
45
- f.address1 '345 E'
46
- f.city 'smalltown'
47
- f.state {|a| a.association(:state)}
48
- f.country {|a| a.association(:country)}
44
+ f.first_name { Factory.next(:name) }
45
+ f.last_name { Factory.next(:name) }
46
+ f.address1 { Factory.next(:address) }
47
+ f.city { Factory.next(:name) }
48
+ f.state {|a| a.association(:state) }
49
+ f.country {|a| a.association(:country) }
49
50
  f.postal_code '88888'
50
51
  f.telephone '333-444-5555'
51
52
  f.payment_method 'ACH'
52
- f.achname 'name of ach'
53
+ f.achname { Factory.next(:name) }
53
54
  f.achrouting '3333'
54
55
  f.achnumber '22222'
55
56
  f.achholder GlobalConfig.achholder_types[0][0]
@@ -132,7 +133,15 @@ def setup_live_user_and_billing(options = {})
132
133
  cart = populate_cart(user)
133
134
  country = Factory(:country, :name => 'United States of America', :abbreviation => 'US')
134
135
  state = Factory(:state, :name => 'Illinois', :abbreviation => 'IL', :country => country)
135
- billing = Factory.build(:live_billing_information, {:billable => user, :state => state, :country => country, :city => 'Chicago'}.merge(options))
136
- user.billing_informations << billing
136
+ billing = user.billing_informations.create(Factory.attributes_for(:live_billing_information, :city => 'Chicago').merge(options))
137
137
  [user, billing]
138
138
  end
139
+
140
+ def setup_user_and_billing(options = {})
141
+ user = Factory(:user)
142
+ cart = populate_cart(user)
143
+ country = Factory(:country, :name => 'United States of America', :abbreviation => 'US')
144
+ state = Factory(:state, :name => 'Illinois', :abbreviation => 'IL', :country => country)
145
+ billing = user.billing_informations.create(Factory.attributes_for(:billing_information, :city => 'Chicago').merge(options))
146
+ [user, billing]
147
+ end
data/locales/en.yml CHANGED
@@ -1,13 +1,16 @@
1
1
  ---
2
2
  en:
3
3
  muck:
4
- commerce:
4
+ commerce:
5
+ missing_billing_information: No valid billing information was provided.
5
6
  subscription_plans_amount: Amount
6
7
  save: Save
7
8
  invalid_credit_card_information: Invalid credit card information
8
9
  authorization_cim: authorization using cim
9
10
  billing_information_problem: "There was a problem with your billing information: {{message}}."
11
+ invalid_billing_information: "Invalid billing information"
10
12
  cim_update_user: update cim user
13
+ cim_update_payment_profile: update cim payment profile
11
14
  subscription_plan_updated: Subscription plan updated
12
15
  create_new_subscription_plan: Create new subscription plan
13
16
  subscription_plans_renewal_period: Renewal Period
@@ -57,6 +60,8 @@ en:
57
60
  capture: capture
58
61
  billing_information_updated_friendly: Your billing information has been updated successfully.
59
62
  cim_validate_profile: cim validate profile
63
+ cim_get_customer_profile: cim get customer profile
64
+ cim_get_payment_customer_profile: cim get customer payment profile
60
65
  subscription_plan_sku: Sku
61
66
  card_expiration: Credit Card Expiration
62
67
  verification_value: Security Code
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-commerce}
8
- s.version = "0.1.9"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
12
- s.date = %q{2010-03-29}
12
+ s.date = %q{2010-04-08}
13
13
  s.description = %q{Add ecommerce functionality to your muck project. This includes integration with Paypal and Authorize.net. This gem uses active merchant and so adding other gateways should be simple.}
14
14
  s.email = %q{justin@tatemae.com}
15
15
  s.extra_rdoc_files = [
@@ -82,10 +82,12 @@ Gem::Specification.new do |s|
82
82
  "db/migrate/20100309183304_add_coupon_subscrption_uses.rb",
83
83
  "db/migrate/20100310180031_create_coupon_types.rb",
84
84
  "db/migrate/20100327171239_add_subscription_records.rb",
85
+ "db/migrate/20100408035338_move_customer_profile_id.rb",
85
86
  "lib/action_controller/muck_billing_application.rb",
86
87
  "lib/active_record/acts/muck_billing_information.rb",
87
88
  "lib/active_record/acts/muck_cart.rb",
88
89
  "lib/active_record/acts/muck_cart_coupon.rb",
90
+ "lib/active_record/acts/muck_cart_item.rb",
89
91
  "lib/active_record/acts/muck_commerce_user.rb",
90
92
  "lib/active_record/acts/muck_coupon.rb",
91
93
  "lib/active_record/acts/muck_coupon_type.rb",
@@ -165,6 +167,7 @@ Gem::Specification.new do |s|
165
167
  "test/rails_root/db/migrate/20100309183304_add_coupon_subscrption_uses.rb",
166
168
  "test/rails_root/db/migrate/20100310180031_create_coupon_types.rb",
167
169
  "test/rails_root/db/migrate/20100327171239_add_subscription_records.rb",
170
+ "test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb",
168
171
  "test/rails_root/features/step_definitions/webrat_steps.rb",
169
172
  "test/rails_root/features/support/env.rb",
170
173
  "test/rails_root/lib/tasks/muck.rake",
@@ -727,6 +730,7 @@ Gem::Specification.new do |s|
727
730
  "test/rails_root/public/stylesheets/themes/blue/styles.css",
728
731
  "test/rails_root/public/stylesheets/themes/red/styles.css",
729
732
  "test/rails_root/remote/functional/remote_orders_controller_test.rb",
733
+ "test/rails_root/remote/functional/remote_subscriptions_controller_test.rb",
730
734
  "test/rails_root/remote/remote_helper.rb",
731
735
  "test/rails_root/remote/unit/remote_order_test.rb",
732
736
  "test/rails_root/remote/unit/remote_order_transaction_test.rb",
@@ -755,6 +759,7 @@ Gem::Specification.new do |s|
755
759
  "test/rails_root/test/functional/orders_controller_test.rb",
756
760
  "test/rails_root/test/functional/subscription_controller_test.rb",
757
761
  "test/rails_root/test/test_helper.rb",
762
+ "test/rails_root/test/unit/billing_information_test.rb",
758
763
  "test/rails_root/test/unit/cart_coupon_test.rb",
759
764
  "test/rails_root/test/unit/coupon_test.rb",
760
765
  "test/rails_root/test/unit/coupon_type_test.rb",
@@ -861,10 +866,12 @@ Gem::Specification.new do |s|
861
866
  "test/rails_root/db/migrate/20100309183304_add_coupon_subscrption_uses.rb",
862
867
  "test/rails_root/db/migrate/20100310180031_create_coupon_types.rb",
863
868
  "test/rails_root/db/migrate/20100327171239_add_subscription_records.rb",
869
+ "test/rails_root/db/migrate/20100408035338_move_customer_profile_id.rb",
864
870
  "test/rails_root/features/step_definitions/webrat_steps.rb",
865
871
  "test/rails_root/features/support/env.rb",
866
872
  "test/rails_root/public/dispatch.rb",
867
873
  "test/rails_root/remote/functional/remote_orders_controller_test.rb",
874
+ "test/rails_root/remote/functional/remote_subscriptions_controller_test.rb",
868
875
  "test/rails_root/remote/remote_helper.rb",
869
876
  "test/rails_root/remote/unit/remote_order_test.rb",
870
877
  "test/rails_root/remote/unit/remote_order_transaction_test.rb",
@@ -877,6 +884,7 @@ Gem::Specification.new do |s|
877
884
  "test/rails_root/test/functional/orders_controller_test.rb",
878
885
  "test/rails_root/test/functional/subscription_controller_test.rb",
879
886
  "test/rails_root/test/test_helper.rb",
887
+ "test/rails_root/test/unit/billing_information_test.rb",
880
888
  "test/rails_root/test/unit/cart_coupon_test.rb",
881
889
  "test/rails_root/test/unit/coupon_test.rb",
882
890
  "test/rails_root/test/unit/coupon_type_test.rb",
@@ -1,5 +1,40 @@
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
+
1
36
  class BillingInformation < ActiveRecord::Base
2
37
 
3
38
  acts_as_muck_billing_information
4
39
 
5
- end
40
+ end
@@ -1,3 +1,15 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: carts
4
+ #
5
+ # id :integer(4) not null, primary key
6
+ # cartable_id :integer(4)
7
+ # cartable_type :string(255)
8
+ # token :string(255)
9
+ # created_at :datetime
10
+ # updated_at :datetime
11
+ #
12
+
1
13
  class Cart < ActiveRecord::Base
2
14
  acts_as_muck_cart
3
15
  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
  class CartCoupon < ActiveRecord::Base
2
13
  acts_as_muck_cart_coupon
3
14
  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
  class Coupon < ActiveRecord::Base
2
22
  acts_as_muck_coupon
3
- end
23
+ 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
  class CouponType < ActiveRecord::Base
2
10
  acts_as_muck_coupon_type
3
- end
11
+ 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
  class Order < ActiveRecord::Base
2
22
  acts_as_muck_order
3
- end
23
+ end
@@ -1,3 +1,14 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: order_coupons
4
+ #
5
+ # id :integer(4) not null, primary key
6
+ # order_id :integer(4)
7
+ # coupon_id :integer(4)
8
+ # created_at :datetime
9
+ # updated_at :datetime
10
+ #
11
+
1
12
  class OrderCoupon < ActiveRecord::Base
2
13
  acts_as_muck_order_coupon
3
- end
14
+ 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
  class OrderTransaction < ActiveRecord::Base
2
21
  acts_as_muck_order_transaction
3
- end
22
+ end
@@ -1,3 +1,26 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: profiles
4
+ #
5
+ # id :integer(4) not null, primary key
6
+ # user_id :integer(4)
7
+ # photo_file_name :string(255)
8
+ # photo_content_type :string(255)
9
+ # photo_file_size :integer(4)
10
+ # created_at :datetime
11
+ # updated_at :datetime
12
+ # location :string(255)
13
+ # lat :decimal(15, 10)
14
+ # lng :decimal(15, 10)
15
+ # about :text
16
+ # city :string(255)
17
+ # state_id :integer(4)
18
+ # country_id :integer(4)
19
+ # language_id :integer(4)
20
+ # profile_views :integer(4)
21
+ # policy :text
22
+ #
23
+
1
24
  class Profile < ActiveRecord::Base
2
25
  acts_as_muck_profile
3
26
  end
@@ -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
  class Subscription < ActiveRecord::Base
2
23
  acts_as_muck_subscription
3
- end
24
+ end
@@ -1,3 +1,17 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: subscription_plans
4
+ #
5
+ # id :integer(4) not null, primary key
6
+ # name :string(255)
7
+ # sku :string(255)
8
+ # amount :integer(4)
9
+ # renewal_period :integer(4)
10
+ # trial_period :integer(4)
11
+ # created_at :datetime
12
+ # updated_at :datetime
13
+ #
14
+
1
15
  class SubscriptionPlan < ActiveRecord::Base
2
16
  acts_as_muck_subscription_plan
3
- end
17
+ 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
  class User < ActiveRecord::Base
2
34
  acts_as_authentic do |c|
3
35
  c.crypto_provider = Authlogic::CryptoProviders::BCrypt
@@ -5,4 +37,4 @@ class User < ActiveRecord::Base
5
37
  acts_as_muck_user
6
38
  has_muck_profile
7
39
  acts_as_muck_commerce_user
8
- end
40
+ end