poundpay 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -15,6 +15,9 @@ Poundpay is a payments platform for marketplaces
15
15
 
16
16
  3. Create the file config/poundpay.yml and add your configurations
17
17
 
18
+ Note: Make sure your YAML file ends with a blank line; otherwise, Ruby
19
+ will give you a completely unintelligible error message
20
+
18
21
  development:
19
22
  developer_sid: DV0383d447360511e0bbac00264a09ff3c
20
23
  auth_token: c31155b9f944d7aed204bdb2a253fef13b4fdcc6ae1540200449cc4526b2381a
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  require 'poundpay/resource'
2
4
 
3
5
  class PaymentReleaseException < Exception
@@ -8,6 +10,25 @@ module Poundpay
8
10
  def self.me
9
11
  find(self.user)
10
12
  end
13
+
14
+ def save
15
+ validate_url callback_url
16
+ super
17
+ end
18
+
19
+ def callback_url=(url)
20
+ validate_url url
21
+ attributes['callback_url'] = url
22
+ end
23
+
24
+ protected
25
+ def validate_url(url)
26
+ begin
27
+ URI.parse(url) unless url == nil or url == ''
28
+ rescue URI::InvalidURIError
29
+ raise URI::InvalidURIError.new "Invalid URL format: #{url}"
30
+ end
31
+ end
11
32
  end
12
33
 
13
34
  class Payment < Resource
@@ -1,3 +1,3 @@
1
1
  module Poundpay
2
- VERSION = "0.2.1"
3
- end
2
+ VERSION = "0.2.2"
3
+ end
@@ -24,6 +24,33 @@ describe Developer do
24
24
  @developer = Developer.me
25
25
  end
26
26
  end
27
+
28
+ describe "#callback_url=" do
29
+ before (:all) do
30
+ @developer = Developer.new :callback_url => nil
31
+ end
32
+
33
+ it "should not allow invalid urls to be assigned" do
34
+ invalid_url = "http://71.212.135.207:3000:payments" # There's a colon after the port number instead of a backslash
35
+ expect { @developer.callback_url = invalid_url }.to raise_error(URI::InvalidURIError, /format/)
36
+ end
37
+
38
+ it "should allow a developer to set their url" do
39
+ valid_url = "http://71.212.135.207:3000/payments"
40
+ @developer.callback_url = valid_url
41
+ @developer.callback_url.should == valid_url
42
+ @developer.callback_url = nil
43
+ @developer.callback_url.should == nil
44
+ end
45
+ end
46
+
47
+ describe "#save" do
48
+ it "should not allow saving with an invalid callback_url" do
49
+ Developer.should_not_receive(:create)
50
+ developer = Developer.new :callback_url => 'i am invalid'
51
+ expect { developer.save }.to raise_error(URI::InvalidURIError)
52
+ end
53
+ end
27
54
  end
28
55
 
29
56
  describe Payment do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matin Tamizi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-19 00:00:00 -08:00
17
+ date: 2011-02-20 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency