omniauth-edmodo 0.0.8 → 0.0.9

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: a1e632b24585480c84d4199d2da90a250c45f63a
4
- data.tar.gz: c1bfc0573b9f3e19eedd83911815e8767c79a37a
3
+ metadata.gz: c3b043fa2a5a2713712ef61ca74612a6d7ff5713
4
+ data.tar.gz: 71ff7005637d164f711958b763f5d43ad5c379a4
5
5
  SHA512:
6
- metadata.gz: d3a932be2d1d00298c5440664ff37bff5db3d0e362bb71d2434bdaf8d881a71762ab1403b13738e76473ad228cfd366721bfb26a7977abbbe82459e05d4bc211
7
- data.tar.gz: b72e2e97efd938e4c705763f6a70bab4b343e4d6ad22faa782d775bdb6bfa32a25f5739957917e2b3b3a7ded01511052cdb335660779269b1cf2a6b882aad79f
6
+ metadata.gz: fa1c529367b5ccb66a5ab6ccc340b5951b135cad7aa46129290044c074c6656d9623ccab02ffce86e64e2fc0599769ff5dd70d2bb4097971ccda532d44e315df
7
+ data.tar.gz: de7e273ae1316787faf4d823534bda2194937ba789c886c79bd1d75ad5bd93e90909f4eea8df6d50d839bac8e5ff3c7b8c6631e58c59a972108aac802f1fe0ed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Omniauth Edmodo
2
2
 
3
- This is the OmniAuth strategy for authenticating to Edmodo. TO use it, you'll need to obtain an OAuth2 application key and secret from Edmodo.
3
+ This is the OmniAuth strategy for authenticating to Edmodo. To use it, you'll need to obtain an OAuth2 application key and secret from Edmodo.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,10 +18,14 @@ Or install it yourself as:
18
18
 
19
19
  ## Basic Usage
20
20
 
21
- use OmniAuth::Builder do
21
+ There is no difference between the following code and using each strategy indivually as middleware. This is an example that you might put into a Rails initializer at config/initializers/omniauth.rb
22
+
23
+ Rails.application.config.use OmniAuth::Builder do
22
24
  provider :edmodo, ENV['EDMODO_KEY'], ENV['EDMODO_SECRET'], scope: "basic,read_user_email"
23
25
  end
24
26
 
27
+ See more at https://github.com/intridea/omniauth
28
+
25
29
  ## Contributing
26
30
 
27
31
  1. Fork it ( https://github.com/[my-github-username]/omniauth-edmodo/fork )
@@ -31,7 +31,7 @@ module OmniAuth
31
31
  'email' => raw_info['email'],
32
32
  'first_name' => raw_info['first_name'],
33
33
  'last_name' => raw_info['last_name'],
34
- 'image' => raw_info['avatars']['large']
34
+ 'image' => raw_info.fetch('avatars', {})['large']
35
35
  }
36
36
  end
37
37
 
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Edmodo
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -60,4 +60,69 @@ describe OmniAuth::Strategies::Edmodo do
60
60
  expect(subject.raw_info).to eq(parsed_response)
61
61
  end
62
62
  end
63
+
64
+ context '#info' do
65
+ before do
66
+ allow(access_token).to receive(:get).with('users/me').and_return(response)
67
+ end
68
+
69
+ context 'when user signing in is a student' do
70
+ let(:parsed_response) do
71
+ { 'url' => 'https://api.edmodo.com/users/123', 'id' => 123, 'type' => 'student' }
72
+ end
73
+
74
+ it 'should return empty profile' do
75
+ expect(subject.info).to eq({
76
+ 'nickname' => nil,
77
+ 'email' => nil,
78
+ 'first_name' => nil,
79
+ 'last_name' => nil,
80
+ 'image' => nil
81
+ })
82
+ end
83
+ end
84
+
85
+ context 'when user signing in is a teacher' do
86
+ let(:parsed_response) do
87
+ {
88
+ 'url' => 'https://api.edmodo.com/users/123',
89
+ 'id' => 123,
90
+ 'type' => 'teacher',
91
+ 'username' => 'jeff',
92
+ 'email' => 'jeff@example.org',
93
+ 'first_name' => 'Jeff',
94
+ 'last_name' => 'Jefferson',
95
+ 'avatars' => { 'large' => 'https://u.ph.edim.co/123/123.png' }
96
+ }
97
+ end
98
+
99
+ it 'should return profile with nickname, email, first_name, last_name and image' do
100
+ expect(subject.info).to eq({
101
+ 'nickname' => 'jeff',
102
+ 'email' => 'jeff@example.org',
103
+ 'first_name' => 'Jeff',
104
+ 'last_name' => 'Jefferson',
105
+ 'image' => 'https://u.ph.edim.co/123/123.png'
106
+ })
107
+ end
108
+
109
+ context 'without an avatar' do
110
+ let(:parsed_response) do
111
+ {
112
+ 'url' => 'https://api.edmodo.com/users/123',
113
+ 'id' => 123,
114
+ 'type' => 'teacher',
115
+ 'username' => 'jeff',
116
+ 'email' => 'jeff@example.org',
117
+ 'first_name' => 'Jeff',
118
+ 'last_name' => 'Jefferson'
119
+ }
120
+ end
121
+
122
+ it 'should include empty "image" property' do
123
+ expect(subject.info).to include({ 'image' => nil })
124
+ end
125
+ end
126
+ end
127
+ end
63
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-edmodo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry Luk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.2.2
150
+ rubygems_version: 2.4.6
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: OmniAuth strategy for Edmodo