muck-commerce 0.2.7 → 0.2.8

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -1,3 +1,7 @@
1
1
  module MuckCommerceHelper
2
2
 
3
+ def extract_cim_transaction_id(transaction)
4
+ transaction.params['direct_response']['raw'].split(",")[6] rescue 'Not Available'
5
+ end
6
+
3
7
  end
@@ -35,7 +35,15 @@ module ActiveRecord
35
35
 
36
36
  named_scope :by_newest, :order => 'billing_informations.created_at DESC'
37
37
  named_scope :default, :conditions => 'billing_informations.default = 1'
38
-
38
+ named_scope :expired_cc, lambda { { :conditions => ["billing_informations.credit_card_expiration < ? ", DateTime.now.beginning_of_month ] } }
39
+ named_scope :will_expired_cc, lambda { |*args| { :conditions => ["billing_informations.credit_card_expiration > ? &&
40
+ billing_informations.credit_card_expiration < ? ",
41
+ DateTime.now.beginning_of_month,
42
+ args.first.end_of_month ||
43
+ (DateTime.now + 3.months).end_of_month ] } }
44
+ named_scope :expired_and_will_expired_cc, lambda { |*args| { :conditions => ["billing_informations.credit_card_expiration < ? ",
45
+ args.first.end_of_month ||
46
+ (DateTime.now + 3.months).end_of_month ] } }
39
47
  include ActiveRecord::Acts::MuckBillingInformation::InstanceMethods
40
48
  extend ActiveRecord::Acts::MuckBillingInformation::SingletonMethods
41
49
  end
@@ -49,7 +57,7 @@ module ActiveRecord
49
57
 
50
58
  # All the methods available to a record that has had <tt>acts_as_muck_billing_information</tt> specified.
51
59
  module InstanceMethods
52
-
60
+
53
61
  # Uses local checks to see if the billing information is valid
54
62
  def billing_valid?
55
63
  has_errors = false
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-commerce}
8
- s.version = "0.2.7"
8
+ s.version = "0.2.8"
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"]
@@ -70,8 +70,53 @@ class BillingInformationTest < ActiveSupport::TestCase
70
70
  should "not find nondefault" do
71
71
  assert BillingInformation.default.include?(@non_default)
72
72
  end
73
+
74
+ context "expiring credit cards" do
75
+ setup do
76
+ @expired_billing_information = Factory(:billing_information, :credit_card_expiration => Time.now - 1.month)
77
+ @soon_to_expire_billing_information = Factory(:billing_information, :credit_card_expiration => Time.now + 1.month)
78
+ @non_expired_billing_information = Factory(:billing_information, :credit_card_expiration => Time.now + 1.year)
79
+ end
80
+ context "expired_cc" do
81
+ should "find expired billing information" do
82
+ assert BillingInformation.expired_cc.include?(@expired_billing_information)
83
+ end
84
+ should "not find billing information that is close to expiring" do
85
+ assert !BillingInformation.expired_cc.include?(@soon_to_expire_billing_information)
86
+ end
87
+ should "not find billing information that are not close to expiring" do
88
+ assert !BillingInformation.expired_cc.include?(@non_expired_billing_information)
89
+ end
90
+ end
91
+ context "will_expired_cc" do
92
+ should "find billing information that are about to expire" do
93
+ assert BillingInformation.will_expired_cc.include?(@soon_to_expire_billing_information)
94
+ end
95
+ should "not find billing information that have expired" do
96
+ assert !BillingInformation.will_expired_cc.include?(@expired_billing_information)
97
+ end
98
+ should "not find billing information that are not close to expiring" do
99
+ assert !BillingInformation.will_expired_cc.include?(@non_expired_billing_information)
100
+ end
101
+ end
102
+ context "expired_and_will_expired_cc" do
103
+ should "find billing information that are about to expire" do
104
+ assert BillingInformation.expired_and_will_expired_cc.include?(@soon_to_expire_billing_information)
105
+ end
106
+ should "find billing information that have expired" do
107
+ assert BillingInformation.expired_and_will_expired_cc.include?(@expired_billing_information)
108
+ end
109
+ should "not find billing information that are not close to expiring" do
110
+ assert !BillingInformation.expired_and_will_expired_cc.include?(@non_expired_billing_information)
111
+ end
112
+ end
113
+ end
114
+
73
115
  end
74
116
 
117
+ context "credit_card_number" do
118
+ assert @billing_information.credit_card_number.include?('XXXX-XXXX-XXXX-')
119
+ end
75
120
 
76
121
  end
77
122
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-commerce
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 7
10
- version: 0.2.7
9
+ - 8
10
+ version: 0.2.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Ball