aptible-auth 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca4a9d2b5c68eb6a3bc594cf68004a13c3843b61
4
- data.tar.gz: f0d1cb3b938429bdb1b6205c50fc29213e99cfd9
3
+ metadata.gz: 4cfd8c31974a234d4545587c92c9fe21bf9f1f98
4
+ data.tar.gz: 5b2fe6153c8124af9b8b65eb2d13f9aa69b66156
5
5
  SHA512:
6
- metadata.gz: 366eb12cc1b762232a46f846bf85f2aa5c8d4f38dd8462c0a3552e82876ab74c4cfef3f0f1e01f8f630866287640de4e6013c8742cc1e42411446c261209e764
7
- data.tar.gz: c26709fb7730c6c2f195a5a82412111ad35ceffeb28212d429bc5b1e962efb640354f0a0d7d301ed37f694e8e967951b230f2dfcc7c8cc20800df599c1f69714
6
+ metadata.gz: cecda29c55a88eae8fc329e811ba6eca4c7d625e4dafb3bbb847532acfb7525944496d3582edadb8c722aca4c5b06de231848aa797d0cc149341166d0e4db722
7
+ data.tar.gz: b70a7aafca2524677db22776879b449dc6c739a644794eb213843507f1689810cb6f87ecd889f40bb935e51af8379033661a8ce89f066fe37579cf83b6e92b36
@@ -2,6 +2,7 @@ module Aptible
2
2
  module Auth
3
3
  class Role < Resource
4
4
  belongs_to :organization
5
+ has_many :memberships
5
6
 
6
7
  field :id
7
8
  field :name
@@ -28,6 +28,12 @@ module Aptible
28
28
  def privileged_roles
29
29
  @privileged_roles ||= roles.select(&:privileged?)
30
30
  end
31
+
32
+ # rubocop:disable PredicateName
33
+ def has_role?(role)
34
+ roles.select { |user_role| role.id == user_role.id }.count > 0
35
+ end
36
+ # rubocop:enable PredicateName
31
37
  end
32
38
  end
33
39
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Auth
3
- VERSION = '0.5.3'
3
+ VERSION = '0.5.4'
4
4
  end
5
5
  end
@@ -23,4 +23,20 @@ describe Aptible::Auth::User do
23
23
  end
24
24
 
25
25
  end
26
+ describe '#roles' do
27
+
28
+ let(:so) { double 'Aptible::Auth::Role' }
29
+ let(:owner) { double 'Aptible::Auth::Role' }
30
+
31
+ before do
32
+ so.stub(:id) { 1 }
33
+ owner.stub(:id) { 2 }
34
+ end
35
+
36
+ it 'should have role' do
37
+ subject.stub(:roles) { [so] }
38
+ expect(subject.has_role?(so)).to eq true
39
+ expect(subject.has_role?(owner)).to eq false
40
+ end
41
+ end
26
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
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-05-09 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource