plaid_rails 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ FactoryGirl.define do
7
7
  owner_type "User"
8
8
  owner_id 1
9
9
  bank_name "Wells Fargo"
10
+ number 1234
10
11
  end
11
12
 
12
13
  end
@@ -10,39 +10,62 @@ module PlaidRails
10
10
 
11
11
  let(:account){FactoryGirl.create(:account)}
12
12
 
13
- it "expect to call delete_connect" do
14
- expect(account).to receive(:delete_connect)
15
- account.destroy
16
- end
13
+ describe 'delete_connect' do
14
+ it "from destroy" do
15
+ expect(account).to receive(:delete_connect)
16
+ account.destroy
17
+ end
17
18
 
18
- it "delete connect with error" do
19
- account = FactoryGirl.create(:account)
20
- expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_raise("boom")
21
- expect(Rails.logger).to receive(:error).exactly(2).times
22
- account.send(:delete_connect)
23
- end
19
+ it "has error" do
20
+ account = FactoryGirl.create(:account)
21
+ expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_raise("boom")
22
+ expect(Rails.logger).to receive(:error).exactly(1).times
23
+ account.send(:delete_connect)
24
+ end
24
25
 
25
- it "delete_connect" do
26
- account = FactoryGirl.create(:account)
27
- user = double
28
- expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_return(user)
29
- expect(user).to receive(:delete)
30
- account.send(:delete_connect)
31
- end
26
+ it "delete_connect" do
27
+ account = FactoryGirl.create(:account)
28
+ user = double
29
+ expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_return(user)
30
+ expect(user).to receive(:transactions).and_return([1])
31
+ expect(user).to receive(:delete)
32
+ account.send(:delete_connect)
33
+ end
32
34
 
33
- it "does not delete_connect" do
34
- FactoryGirl.create(:account)
35
- expect(Plaid::User).to_not receive(:load).with(:connect, "test_wells").and_raise("boom")
36
- account.send(:delete_connect)
37
- end
35
+ it "does not delete_connect" do
36
+ FactoryGirl.create(:account)
37
+ expect(Plaid::User).to_not receive(:load).with(:connect, "test_wells").and_raise("boom")
38
+ end
38
39
 
39
- it "before_save delete_connect" do
40
- expect(account).to receive(:delete_connect)
41
- account.update(access_token: 'foobar')
40
+ it "does not delete_connect without transactions" do
41
+ user = double
42
+ expect(Plaid::User).to receive(:load).with(:connect, "test_wells").and_return(user)
43
+ expect(user).to receive(:transactions).and_return([])
44
+ account.update(access_token: 'foobar')
45
+ end
46
+
47
+ it 'does not delete_connect with same access_token' do
48
+ 2.times{FactoryGirl.create(:account) }
49
+ expect(Plaid::User).to_not receive(:load).with(:connect, "test_wells")
50
+ Account.first.destroy
51
+ end
42
52
  end
43
- it "does not before_save delete_connect" do
44
- expect(account).to_not receive(:delete_connect)
45
- account.update(last_sync: Time.now)
53
+
54
+ describe "delete_updated_token" do
55
+ it "before_update delete_updated_token" do
56
+ expect(account).to receive(:delete_updated_token)
57
+ account.update(access_token: 'foobar')
58
+ end
59
+
60
+ it "does not before_update delete_connect" do
61
+ expect(account).to_not receive(:delete_updated_token)
62
+ account.update(last_sync: Time.now)
63
+ end
64
+
65
+ it 'does delete_connect' do
66
+ expect(account).to receive(:delete_connect)
67
+ account.send(:delete_updated_token)
68
+ end
46
69
  end
47
70
  end
48
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plaid_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curt Wilhelm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-22 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails