braintree-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,6 +45,15 @@ describe BraintreeRails::Address do
45
45
  end
46
46
  end
47
47
 
48
+ describe 'customer' do
49
+ it 'should load customer for persisted address' do
50
+ stub_braintree_request(:get, '/customers/customer_id', :body => fixture('customer.xml'))
51
+ address = BraintreeRails::Customer.new('customer_id').addresses.first
52
+ address.customer.persisted?.must_equal true
53
+ address.customer.id.must_equal 'customer_id'
54
+ end
55
+ end
56
+
48
57
  describe 'validations' do
49
58
  [:first_name, :last_name, :company, :street_address, :extended_address, :locality, :region].each do |attribute|
50
59
  it "should validate length of #{attribute}" do
@@ -45,6 +45,15 @@ describe BraintreeRails::CreditCard do
45
45
  end
46
46
  end
47
47
 
48
+ describe 'customer' do
49
+ it 'should load customer for persisted credit_card' do
50
+ credit_card = BraintreeRails::CreditCard.new('credit_card_id')
51
+ stub_braintree_request(:get, '/customers/customer_id', :body => fixture('customer.xml'))
52
+ credit_card.customer.persisted?.must_equal true
53
+ credit_card.customer.id.must_equal 'customer_id'
54
+ end
55
+ end
56
+
48
57
  describe '#billing_address' do
49
58
  it 'should wrap billing_address with Address object' do
50
59
  credit_card = BraintreeRails::CreditCard.new(OpenStruct.new(:billing_address => nil))
@@ -237,4 +246,17 @@ describe BraintreeRails::CreditCard do
237
246
  credit_card.errors[:number].wont_be :blank?
238
247
  end
239
248
  end
249
+
250
+ describe 'class methods' do
251
+ it "should wrap Braintree's Model find" do
252
+ credit_card = BraintreeRails::CreditCard.find('credit_card_id')
253
+ credit_card.id.must_equal 'credit_card_id'
254
+ credit_card.persisted?.must_equal true
255
+ end
256
+
257
+ it "should delegate delete to Braintree's Model" do
258
+ stub_braintree_request(:delete, '/payment_methods/credit_card_id', :body => fixture('credit_card.xml'))
259
+ BraintreeRails::CreditCard.delete('credit_card_id').must_equal true
260
+ end
261
+ end
240
262
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-13 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: braintree
@@ -128,6 +128,7 @@ files:
128
128
  - lib/tasks/test.rake
129
129
  - lib/test_env.rb
130
130
  - log/braintree_test.log
131
+ - MIT-LICENSE
131
132
  - Rakefile
132
133
  - README.md
133
134
  - test/config/braintree_auth.yml