Skip to content

Commit

Permalink
Some rubocop style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johankok committed Aug 22, 2018
1 parent 8257c6e commit c46f6dd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
rvm:
- 1.9.3
- 2.1.5
- 2.2.0
script: rspec spec
- 2.3.7
- 2.4.4
- 2.5.1
script: rspec spec
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
require "bundler/gem_tasks"

require 'bundler/gem_tasks'
4 changes: 2 additions & 2 deletions lib/omniauth-timber-cantina.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require "omniauth/timber/cantina"
require "omniauth/strategies/timber_cantina"
require 'omniauth/timber/cantina'
require 'omniauth/strategies/timber_cantina'
21 changes: 10 additions & 11 deletions lib/omniauth/strategies/timber_cantina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,29 @@

module OmniAuth
module Strategies
# Basic authentication strategy for Timber Cantina
class TimberCantina < OmniAuth::Strategies::OAuth2
option :name, :timber_cantina

option :client_options, {
:site => "https://cantina.budh.nl",
:authorize_url => "/oauth/authorize"
}
option :client_options,
site: 'https://cantina.budh.nl',
authorize_url: '/oauth/authorize'

uid { raw_info["id"] }
uid { raw_info['id'] }

info do
{
:email => raw_info["email"],
:name => raw_info["name"],
:api_access_enabled => raw_info["api_access_enabled"],
:application_permissions => raw_info["application_permissions"]
email: raw_info['email'],
name: raw_info['name'],
api_access_enabled: raw_info['api_access_enabled'],
application_permissions: raw_info['application_permissions']
# and anything else you want to return to your API consumers
}
end

def raw_info
@raw_info ||= access_token.get('/api/v1/me.json').parsed
end

end
end
end
end
2 changes: 1 addition & 1 deletion lib/omniauth/timber/cantina.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "omniauth/timber/cantina/version"
require 'omniauth/timber/cantina/version'

module Omniauth
module Timber
Expand Down
4 changes: 2 additions & 2 deletions omniauth-timber-cantina.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
spec.name = 'omniauth-timber-cantina'
spec.version = Omniauth::Timber::Cantina::VERSION
spec.authors = ['Johan Kok']
spec.email = ['info@johankok.nl']
spec.email = ['webmaster@boomdenhaag.nl']
spec.summary = %q{OmniAuth strategy for Timber Cantina SSO application.}
spec.description = %q{OmniAuth strategy for Timber Cantina SSO application.}
spec.homepage = 'https://github.com/johankok/omniauth-timber-cantina'
spec.homepage = 'https://github.com/boom-den-haag/omniauth-timber-cantina'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0")
Expand Down
25 changes: 10 additions & 15 deletions spec/omniauth/strategies/omniauth_timber_cantina_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,33 @@
subject { OmniAuth::Strategies::TimberCantina.new({}) }


context "client options" do
context 'client options' do
it 'should have correct site' do
expect(subject.options.client_options.site).to eq "https://cantina.budh.nl"
expect(subject.options.client_options.site).to eq 'https://cantina.budh.nl'
end

it 'should have correct authorize url' do
expect(subject.options.client_options.authorize_url).to eq '/oauth/authorize'
end

describe "should be able to customize" do
describe 'should be able to customize' do
let(:custom_site) { 'http://localhost:3000' }
let(:custom_authorize_url) { '/admin_users/oauth/authorize' }
let(:custom) do
OmniAuth::Strategies::TimberCantina.new('KEY', 'SECRET',
{
client_options: {
site: custom_site,
authorize_url: custom_authorize_url
}
}
)
client_options: {
site: custom_site,
authorize_url: custom_authorize_url
})
end

it "for site" do
it 'for site' do
expect(custom.options.client_options.site).to eq custom_site
end

it "for authorize url" do
it 'for authorize url' do
expect(custom.options.client_options.authorize_url).to eq custom_authorize_url
end

end
end

end
end

0 comments on commit c46f6dd

Please sign in to comment.