Skip to content

Commit 441a871

Browse files
committed
add mobile, location to hash. add client test coverage
1 parent 93c5a60 commit 441a871

File tree

7 files changed

+44
-3
lines changed

7 files changed

+44
-3
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--colour

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
require "bundler/gem_tasks"
2+
require "rspec/core/rake_task"
3+
4+
RSpec::Core::RakeTask.new(:spec)
5+
6+
task default: :spec

lib/omniauth/marvin/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Omniauth
22
module Marvin
3-
VERSION = "0.1.0"
3+
VERSION = "0.1.1"
44
end
55
end

lib/omniauth/strategies/marvin.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module OmniAuth
44
module Strategies
55
class Marvin < OmniAuth::Strategies::OAuth2
6-
option :name, :marvin
6+
option :name, "marvin"
77

88
option :client_options, {
99
site: "https://api.intrav2.42.fr",
@@ -18,12 +18,14 @@ class Marvin < OmniAuth::Strategies::OAuth2
1818
login: raw_info["login"],
1919
url: raw_info["url"],
2020
name: raw_info["displayname"],
21+
mobile: raw_info["mobile"],
2122
image: raw_info["image_url"],
2223
staff?: raw_info["staff?"],
2324
correction_point: raw_info["correction_point"],
2425
wallet: raw_info["wallet"],
2526
level: raw_info["cursus"]["level"],
26-
grade: raw_info["cursus"]["grade"]
27+
grade: raw_info["cursus"]["grade"],
28+
location: raw_info["location"]
2729
}
2830
end
2931

omniauth-marvin.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ Gem::Specification.new do |spec|
2828
spec.require_paths = ["lib"]
2929

3030
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
31+
spec.add_runtime_dependency 'multi_json', '~> 1.3'
3132

3233
spec.add_development_dependency "bundler", "~> 1.10"
3334
spec.add_development_dependency "rake", "~> 10.0"
35+
spec.add_development_dependency 'rspec'
3436
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "spec_helper"
2+
require "omniauth-marvin"
3+
4+
describe OmniAuth::Strategies::Marvin do
5+
let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
6+
7+
subject do
8+
args = ['appid', 'secret', @options || {}].compact
9+
OmniAuth::Strategies::Marvin.new(*args).tap do |strategy|
10+
allow(strategy).to receive(:request) {
11+
request
12+
}
13+
end
14+
end
15+
16+
describe "client options" do
17+
it 'has a correct name' do
18+
expect(subject.options.name).to eq("marvin")
19+
end
20+
21+
it 'has a correct site' do
22+
expect(subject.options.client_options.site).to eq("https://api.intrav2.42.fr")
23+
end
24+
25+
it "has a valid auth url" do
26+
expect(subject.options.client_options.authorize_path).to eq("v2/oauth/authorize")
27+
end
28+
end
29+
end

spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/setup"
2+
require "rspec"

0 commit comments

Comments
 (0)