bouncer-client 0.3.1 → 0.3.2

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: 71349750645c6431c2cc2885a822adf6407cc7a6
4
- data.tar.gz: 30e979346953bb2420ce72113f753093dff91acf
3
+ metadata.gz: 32d93c1192da325437b8fc12ca10b5da56142c22
4
+ data.tar.gz: 831ce5a22205a3c9db3bcaf306411bd018b3b563
5
5
  SHA512:
6
- metadata.gz: 299e21f5dec93723d96d9d4000425d20392369409354bd1ff762bad1bea85088af809271e6d3ff1b019c1f0a6a5a59173fc064cc4e743f3b34091a4a1f9d3d49
7
- data.tar.gz: 79683b32dba63e17e1c7105a0719e5f9dc30cc2d0f891d3ed6d190424ae9c905ef603798d06ab20c50e6d87cff3850129d294fec5736e96d46d02f18476a3591
6
+ metadata.gz: a66e9dc0ab9ded482191bfb877605c2a08b6381444fb5926b4df98f2b816dba32ed11112ea030bf46da2c2900c495fff2cd23db87961ca5a695a610e629f3834
7
+ data.tar.gz: 89879a266475e2285e36a6a565a8449cb8159d229b45fc0be9ebd1b91a9504f27817529582317b1984603c19d57384b9926d826d111868772e4348a95bbba6c7
@@ -5,11 +5,10 @@ module Bouncer
5
5
 
6
6
  def self.from_json json
7
7
  activation = Activation.new
8
- activation.id = json['id']
9
- activation.created_at = json['created_at']
10
- activation.unit_id = json['links']['unit']
11
- activation.device_id = json['links']['device']
12
- activation.user_id = json['links']['user']
8
+ json.keys.map do |key|
9
+ activation.class.class_eval { attr_accessor key.to_sym }
10
+ activation.send("#{key}=", json[key])
11
+ end
13
12
  activation
14
13
  end
15
14
  end
@@ -1,3 +1,3 @@
1
1
  module Bouncer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bouncer::Activation do
4
+ it 'is created dynamically from a JSON payload' do
5
+ user = Bouncer::Activation.from_json({ foo: 'foo', links: { unit_id: SecureRandom.uuid }})
6
+ expect(user).to respond_to :foo
7
+ expect(user).to respond_to :links
8
+ expect(user.links[:unit_id]).not_to be_nil
9
+ end
10
+ end
@@ -10,13 +10,10 @@ describe Bouncer::User do
10
10
  end
11
11
 
12
12
  it 'is created dynamically from a JSON payload' do
13
- uuid = SecureRandom.uuid
14
- VCR.use_cassette 'bouncer/user' do
15
- user = Bouncer::User.from_json({ email: 'foo@example.com', super_admin: false, role: 'manager' })
16
- expect(user).to respond_to :email
17
- expect(user).to respond_to :super_admin
18
- expect(user).to respond_to :role
19
- expect(user).to_not respond_to :foo
20
- end
13
+ user = Bouncer::User.from_json({ email: 'foo@example.com', super_admin: false, role: 'manager' })
14
+ expect(user).to respond_to :email
15
+ expect(user).to respond_to :super_admin
16
+ expect(user).to respond_to :role
17
+ expect(user).to_not respond_to :foo
21
18
  end
22
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bouncer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurt Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -253,6 +253,7 @@ files:
253
253
  - spec/cassettes/bouncer/valid_admin.yml
254
254
  - spec/cassettes/bouncer/valid_user.yml
255
255
  - spec/mixins/controller_mixin_spec.rb
256
+ - spec/model/activation_spec.rb
256
257
  - spec/model/token_spec.rb
257
258
  - spec/model/user_spec.rb
258
259
  - spec/spec_helper.rb
@@ -287,6 +288,7 @@ test_files:
287
288
  - spec/cassettes/bouncer/valid_admin.yml
288
289
  - spec/cassettes/bouncer/valid_user.yml
289
290
  - spec/mixins/controller_mixin_spec.rb
291
+ - spec/model/activation_spec.rb
290
292
  - spec/model/token_spec.rb
291
293
  - spec/model/user_spec.rb
292
294
  - spec/spec_helper.rb