omniauth-draugiem 1.1.0 → 1.2.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: 9d02ed02020c52e2ea3b3c72d4da019fb376e80c
4
- data.tar.gz: e1cd42b6b53304e7f1bef69868e36271d16ef85f
3
+ metadata.gz: b3522a225714401cb6d46a60a90cb3d80d1144cc
4
+ data.tar.gz: d65d9883674c351bca10a0be45d1b04e66d528ac
5
5
  SHA512:
6
- metadata.gz: cd4dece0b7d1639a749038b7ee97268483ceba61ce7bfce56c6270d23c027e571fc11c35cc98c3b9a5b43415089a4e395a43d67efc3f8004bd222c8b35ae2d8f
7
- data.tar.gz: 7a3a07f2e66543e63df8c7af00ea0cf9bae66a55d33066208b6d67d3925be9c54c5dfb05c2ce07ccb596586fcb1236fff28c7337fca3c96c4a39f02d8efeb08f
6
+ metadata.gz: 910ee5d048cd445c3f70bee5ef6a16b77a62d155befe6687d0940df6753f2a78fe020fa3140a3ae26ca75b2dd4732bd0f7801875ccb823383a801eb265bb1ad9
7
+ data.tar.gz: de66d56525721d824558d2c8811901cd98fc3e62e48484087c234b4406f0443bbaf45d27326cd1cda319105f17a732aaa5c3741332202c2c1eb196d71970df6f
@@ -6,6 +6,8 @@ rvm:
6
6
  - 2.1.0
7
7
  - 2.2.4
8
8
  - 2.3.3
9
+ - 2.4.1
10
+ - 2.5.0
9
11
  - ruby-head
10
12
 
11
- before_install: gem install bundler -v 1.14.6
13
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec
3
+ gem 'pry-rails'
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Draugiem
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -55,23 +55,24 @@ module OmniAuth
55
55
  fail!(:invalid_response, e)
56
56
  end
57
57
 
58
- uid { @auth_data['uid'] }
58
+ uid { @auth_data['uid'].to_s }
59
59
 
60
60
  credentials do
61
61
  { 'apikey' => @auth_data['apikey'] }
62
62
  end
63
63
 
64
64
  info do
65
- if @auth_data['users'] && @auth_data['users'][@auth_data['uid']]
66
- user = @auth_data['users'][@auth_data['uid']]
65
+ if @auth_data['users'] && @auth_data['users'][@auth_data['uid'].to_s]
66
+ user = @auth_data['users'][@auth_data['uid'].to_s]
67
67
  {
68
68
  'name' => "#{user['name']} #{user['surname']}",
69
69
  'nickname' => user['nick'],
70
+ 'email' => user['email'],
70
71
  'first_name' => user['name'],
71
72
  'last_name' => user['surname'],
72
73
  'location' => user['place'],
73
- 'age' => user['age'] =~ /^0-9$/ ? user['age'] : nil,
74
- 'adult' => user['adult'] == '1' ? true : false,
74
+ 'age' => user['age'] ? user['age'] : nil,
75
+ 'adult' => (user['adult'] == 1),
75
76
  'image' => user['img'],
76
77
  'sex' => user['sex']
77
78
  }
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency "omniauth", "~> 1.0"
22
- s.add_runtime_dependency "rest-client", "~> 1.6"
22
+ s.add_runtime_dependency "rest-client", "~> 2.0.1"
23
23
  s.add_runtime_dependency "multi_json", "~> 1.0"
24
24
 
25
25
  s.add_development_dependency "bundler", "~> 1.5"
@@ -24,28 +24,52 @@ describe 'OmniAuth::Strategies::Draugiem', :type => :strategy do
24
24
  stub_request(:get, "https://api.draugiem.lv/json/?action=authorize&app=abc&code=123456").
25
25
  to_return(:body => MultiJson.encode({
26
26
  'apikey'=>"123456789",
27
- 'uid'=>"100",
27
+ 'uid'=>100,
28
28
  'language'=>"lv",
29
29
  'users'=>{
30
30
  '100'=>{
31
- 'uid'=>"100",
31
+ 'uid'=>100,
32
32
  'name'=>"John",
33
33
  'surname'=>"Lenon",
34
34
  'nick'=>"johnybravo",
35
35
  'place'=>"Durbe",
36
- 'age'=>"false",
37
- 'adult'=>"1",
36
+ 'age'=>false,
37
+ 'adult'=> 1,
38
38
  'img'=>"https://4.bp.blogspot.com/_ZmXOoYjxXog/Sg2jby1RFSI/AAAAAAAAE_Q/1LpfjimAz50/s400/JohnnyBravo3.gif",
39
39
  'sex'=>"M"
40
40
  }
41
41
  }
42
42
  }))
43
43
  get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456'
44
-
45
44
  expect(last_request.env['omniauth.auth']['credentials']['apikey']).to eq "123456789"
46
45
  expect(last_request.env['omniauth.auth']['info']['location']).to eq "Durbe"
47
46
  expect(last_request.env['omniauth.auth']['info']['age']).to be nil
48
47
  expect(last_request.env['omniauth.auth']['info']['adult']).to be true
49
48
  end
49
+
50
+ it 'should gather user data after success authorization when age is 8 and not adult' do
51
+ stub_request(:get, "https://api.draugiem.lv/json/?action=authorize&app=abc&code=123456").
52
+ to_return(:body => MultiJson.encode({
53
+ 'apikey'=>"123456789",
54
+ 'uid'=>100,
55
+ 'language'=>"lv",
56
+ 'users'=>{
57
+ '100'=>{
58
+ 'uid'=>100,
59
+ 'name'=>"John",
60
+ 'surname'=>"Lenon",
61
+ 'nick'=>"johnybravo",
62
+ 'place'=>"Durbe",
63
+ 'age'=>8,
64
+ 'adult'=> 0,
65
+ 'img'=>"https://4.bp.blogspot.com/_ZmXOoYjxXog/Sg2jby1RFSI/AAAAAAAAE_Q/1LpfjimAz50/s400/JohnnyBravo3.gif",
66
+ 'sex'=>"M"
67
+ }
68
+ }
69
+ }))
70
+ get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456'
71
+ expect(last_request.env['omniauth.auth']['info']['age']).to be 8
72
+ expect(last_request.env['omniauth.auth']['info']['adult']).to be false
73
+ end
50
74
  end
51
- end
75
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-draugiem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-15 00:00:00.000000000 Z
12
+ date: 2018-02-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.6'
34
+ version: 2.0.1
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.6'
41
+ version: 2.0.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: multi_json
44
44
  requirement: !ruby/object:Gem::Requirement