aptible-auth 0.5.15 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc0c014308bf64c168ebe65c038aa66856b66928
4
- data.tar.gz: f7545453c5366a9343a5fb44c720137b032bd7bd
3
+ metadata.gz: 3cbb943790b2f247eba3b6dcf76ca588e5bbd28d
4
+ data.tar.gz: ff2172167641f191244cf8ee19274c74d0bf9b05
5
5
  SHA512:
6
- metadata.gz: 4f1a2454bde64eb256dc08e19f1e060dd0b39d529e727258915623f3f5f9988ecc317a292e092798d00ae769ee8ed822610d30141d5146478cd4fb702b565bfb
7
- data.tar.gz: a952dac04ec1506cd25c531817e054caeade252608ee736634c913e411cbae81d12d49ba5486ce2f58f75b89163d67f8c25e40366e0a841e89c3d62d742c1912
6
+ metadata.gz: bcf5e325bc82d3030ddfde97ab3d944724f03290eccfbe8ea64b996e8874c8eea4a254150799e437c3453ad3cbc721cbd1fb582d6a66232140c807bffc84141a
7
+ data.tar.gz: 63d9111dde96c48b47d192f9c12743311c812a5241a2a1db80153ee77ca7b55c1540931ad9319cd5b908e19ba4cc116b6ab147c671ae3919301dba7668bb07fe
@@ -23,24 +23,31 @@ module Aptible
23
23
  field :plan
24
24
 
25
25
  def stripe_customer
26
- return if stripe_customer_id.nil?
26
+ return nil if stripe_customer_id.nil?
27
27
  @stripe_customer ||= Stripe::Customer.retrieve(stripe_customer_id)
28
28
  end
29
29
 
30
30
  def can_manage_compliance?
31
- # TODO: Refactor once Stripe migration from accounts is complete
32
- return false if %w(development platform).include?(plan)
33
- accounts.map(&:type).include? 'production'
31
+ %w(production).include?(plan)
32
+ end
33
+
34
+ def subscription
35
+ return nil if stripe_subscription_id.nil?
36
+ subscriptions = stripe_customer.subscriptions
37
+ @subscription ||= subscriptions.retrieve(stripe_subscription_id)
38
+ end
39
+
40
+ def subscribed?
41
+ !!stripe_subscription_id
34
42
  end
35
43
 
36
44
  def billing_contact
37
45
  return nil unless stripe_customer
38
46
  return nil unless stripe_customer.metadata['billing_contact']
39
47
 
40
- @billing_contact ||=
41
- User.find_by_url(
42
- stripe_customer.metadata['billing_contact'],
43
- token: token)
48
+ @billing_contact ||= User.find_by_url(
49
+ stripe_customer.metadata['billing_contact'], token: token
50
+ )
44
51
  end
45
52
 
46
53
  def security_officer
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Auth
3
- VERSION = '0.5.15'
3
+ VERSION = '0.6.0'
4
4
  end
5
5
  end
@@ -1,24 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Aptible::Auth::Organization do
4
- describe '#can_manage_compliance?' do
5
- let(:production) { double 'Aptible::Auth::Resource' }
6
- let(:development) { double 'Aptible::Auth::Resource' }
7
-
8
- before { production.stub(:type) { 'production' } }
9
- before { development.stub(:type) { 'development' } }
10
-
11
- it 'should return true with a production account' do
12
- subject.stub(:accounts) { [development] }
13
- expect(subject.can_manage_compliance?).to eq false
14
- end
15
-
16
- it 'should return false without a production account' do
17
- subject.stub(:accounts) { [development, production] }
18
- expect(subject.can_manage_compliance?).to eq true
19
- end
20
- end
21
-
22
4
  describe '#security_officer' do
23
5
  let(:role) { double 'Aptible::Auth::Role' }
24
6
  let(:user) { double 'Aptible::Auth::User' }
@@ -36,4 +18,27 @@ describe Aptible::Auth::Organization do
36
18
  expect(subject.security_officer).to be_nil
37
19
  end
38
20
  end
21
+
22
+ describe '#can_manage_compliance?' do
23
+ it 'should return true with compliance plan' do
24
+ subject.stub(:plan) { 'production' }
25
+ expect(subject.can_manage_compliance?).to be_true
26
+ end
27
+
28
+ it 'should return false without compliance plan' do
29
+ subject.stub(:plan) { 'platform' }
30
+ expect(subject.can_manage_compliance?).to be_false
31
+ end
32
+ end
33
+
34
+ describe '#subscribed?' do
35
+ it 'should return true with valid subscription ID' do
36
+ subject.stub(:stripe_subscription_id) { 'sub_4YrmiVa3vMpaGA' }
37
+ expect(subject.subscribed?).to be_true
38
+ end
39
+
40
+ it 'should return false without valid subscription ID' do
41
+ expect(subject.subscribed?).to be_false
42
+ end
43
+ end
39
44
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.15
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-10 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: stripe
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gem_config
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: oauth2-aptible
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: aptible-tasks
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.2.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.2.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '2.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '2.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Ruby client for auth.aptible.com
@@ -143,9 +143,9 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .rspec
148
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
149
  - Gemfile
150
150
  - LICENSE.md
151
151
  - Procfile
@@ -182,12 +182,12 @@ require_paths:
182
182
  - lib
183
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []