killbill-litle 1.9.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +3 -0
- data/VERSION +1 -1
- data/lib/litle/models/litle_payment_method.rb +2 -1
- data/pom.xml +1 -1
- data/spec/litle/litle_payment_method_spec.rb +12 -8
- metadata +1 -1
data/NEWS
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.1
|
@@ -51,7 +51,8 @@ module Killbill::Litle
|
|
51
51
|
.or(t[:city].matches("%#{search_key}%"))
|
52
52
|
.or(t[:country].matches("%#{search_key}%"))
|
53
53
|
|
54
|
-
|
54
|
+
# Coming from Kill Bill, search_key will always be a String. Check to see if it represents a numeric for numeric-only fields
|
55
|
+
if search_key.is_a?(Numeric) or search_key.to_s =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
55
56
|
where_clause = where_clause.or(t[:cc_exp_month].eq(search_key))
|
56
57
|
.or(t[:cc_exp_year].eq(search_key))
|
57
58
|
.or(t[:cc_last_4].eq(search_key))
|
data/pom.xml
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
<groupId>com.ning.killbill.ruby</groupId>
|
26
26
|
<artifactId>litle-plugin</artifactId>
|
27
27
|
<packaging>pom</packaging>
|
28
|
-
<version>1.9.
|
28
|
+
<version>1.9.1</version>
|
29
29
|
<name>litle-plugin</name>
|
30
30
|
<url>http://github.com/killbill/killbill-litle-plugin</url>
|
31
31
|
<description>Plugin for accessing Litle as a payment gateway</description>
|
@@ -7,12 +7,14 @@ describe Killbill::Litle::LitlePaymentMethod do
|
|
7
7
|
|
8
8
|
it 'should generate the right SQL query' do
|
9
9
|
# Check count query (search query numeric)
|
10
|
-
expected_query = "SELECT COUNT(DISTINCT \"litle_payment_methods\".\"id\") FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = 1234 OR \"litle_payment_methods\".\"cc_type\" = 1234) OR \"litle_payment_methods\".\"state\" = 1234) OR \"litle_payment_methods\".\"zip\" = 1234) OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\""
|
11
|
-
|
10
|
+
expected_query = "SELECT COUNT(DISTINCT \"litle_payment_methods\".\"id\") FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = '1234' OR \"litle_payment_methods\".\"cc_type\" = '1234') OR \"litle_payment_methods\".\"state\" = '1234') OR \"litle_payment_methods\".\"zip\" = '1234') OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\""
|
11
|
+
# Note that Kill Bill will pass a String, even for numeric types
|
12
|
+
Killbill::Litle::LitlePaymentMethod.search_query('1234').to_sql.should == expected_query
|
12
13
|
|
13
14
|
# Check query with results (search query numeric)
|
14
|
-
expected_query = "SELECT DISTINCT \"litle_payment_methods\".* FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = 1234 OR \"litle_payment_methods\".\"cc_type\" = 1234) OR \"litle_payment_methods\".\"state\" = 1234) OR \"litle_payment_methods\".\"zip\" = 1234) OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\" LIMIT 10 OFFSET 0"
|
15
|
-
|
15
|
+
expected_query = "SELECT DISTINCT \"litle_payment_methods\".* FROM \"litle_payment_methods\" WHERE ((((((((((((\"litle_payment_methods\".\"litle_token\" = '1234' OR \"litle_payment_methods\".\"cc_type\" = '1234') OR \"litle_payment_methods\".\"state\" = '1234') OR \"litle_payment_methods\".\"zip\" = '1234') OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%1234%') OR \"litle_payment_methods\".\"address1\" LIKE '%1234%') OR \"litle_payment_methods\".\"address2\" LIKE '%1234%') OR \"litle_payment_methods\".\"city\" LIKE '%1234%') OR \"litle_payment_methods\".\"country\" LIKE '%1234%') OR \"litle_payment_methods\".\"cc_exp_month\" = 1234) OR \"litle_payment_methods\".\"cc_exp_year\" = 1234) OR \"litle_payment_methods\".\"cc_last_4\" = 1234) ORDER BY \"litle_payment_methods\".\"id\" LIMIT 10 OFFSET 0"
|
16
|
+
# Note that Kill Bill will pass a String, even for numeric types
|
17
|
+
Killbill::Litle::LitlePaymentMethod.search_query('1234', 0, 10).to_sql.should == expected_query
|
16
18
|
|
17
19
|
# Check count query (search query string)
|
18
20
|
expected_query = "SELECT COUNT(DISTINCT \"litle_payment_methods\".\"id\") FROM \"litle_payment_methods\" WHERE (((((((((\"litle_payment_methods\".\"litle_token\" = 'XXX' OR \"litle_payment_methods\".\"cc_type\" = 'XXX') OR \"litle_payment_methods\".\"state\" = 'XXX') OR \"litle_payment_methods\".\"zip\" = 'XXX') OR \"litle_payment_methods\".\"cc_first_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"cc_last_name\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address1\" LIKE '%XXX%') OR \"litle_payment_methods\".\"address2\" LIKE '%XXX%') OR \"litle_payment_methods\".\"city\" LIKE '%XXX%') OR \"litle_payment_methods\".\"country\" LIKE '%XXX%') ORDER BY \"litle_payment_methods\".\"id\""
|
@@ -45,8 +47,9 @@ describe Killbill::Litle::LitlePaymentMethod do
|
|
45
47
|
do_search('foo').size.should == 0
|
46
48
|
do_search(pm.litle_token).size.should == 1
|
47
49
|
do_search('ccType').size.should == 1
|
48
|
-
# Exact match
|
49
|
-
do_search(123).size.should == 0
|
50
|
+
# Exact match only for cc_last_4
|
51
|
+
do_search('123').size.should == 0
|
52
|
+
do_search('1234').size.should == 1
|
50
53
|
# Test partial match
|
51
54
|
do_search('address').size.should == 1
|
52
55
|
do_search('Name').size.should == 1
|
@@ -71,8 +74,9 @@ describe Killbill::Litle::LitlePaymentMethod do
|
|
71
74
|
do_search(pm.litle_token).size.should == 1
|
72
75
|
do_search(pm2.litle_token).size.should == 1
|
73
76
|
do_search('ccType').size.should == 2
|
74
|
-
# Exact match
|
75
|
-
do_search(123).size.should == 0
|
77
|
+
# Exact match only for cc_last_4
|
78
|
+
do_search('123').size.should == 0
|
79
|
+
do_search('1234').size.should == 2
|
76
80
|
# Test partial match
|
77
81
|
do_search('cc').size.should == 2
|
78
82
|
do_search('address').size.should == 2
|