Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/sinatra/auth/github.rb
	sinatra_auth_github.gemspec
	spec/spec_helper.rb
  • Loading branch information
atmos committed May 25, 2012
2 parents 3ee8203 + 4ae54b5 commit f171cde
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 6 deletions.
2 changes: 0 additions & 2 deletions lib/sinatra/auth/github.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module Sinatra module Sinatra
module Auth module Auth
module Github module Github
VERSION = "0.4.2"

# Simple way to serve an image early in the stack and not get blocked by # Simple way to serve an image early in the stack and not get blocked by
# application level before filters # application level before filters
class AccessDenied < Sinatra::Base class AccessDenied < Sinatra::Base
Expand Down
31 changes: 31 additions & 0 deletions lib/sinatra/auth/github/test/test_helper.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'warden/test/helpers'
require 'warden-github/user'

module Sinatra
module Auth
module Github
module Test
module Helper
include(Warden::Test::Helpers)
def make_user(attrs = {})
User.make(attrs)
end

class User < Warden::Github::Oauth::User
def self.make(attrs = {})
default_attrs = {
'login' => "test_user",
'name' => "Test User",
'email' => "test@example.com",
'company' => "GitHub",
'gravatar_id' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png'
}
default_attrs.merge! attrs
User.new(default_attrs)
end
end
end
end
end
end
end
7 changes: 7 additions & 0 deletions lib/sinatra/auth/github/version.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
module Sinatra
module Auth
module Github
VERSION = "0.5.0"
end
end
end
3 changes: 2 additions & 1 deletion sinatra_auth_github.gemspec
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__) $:.push File.expand_path("../lib", __FILE__)
require "sinatra/auth/github/version"


Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "sinatra_auth_github" s.name = "sinatra_auth_github"
s.version = "0.4.2" s.version = Sinatra::Auth::Github::VERSION
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.authors = ["Corey Donohoe"] s.authors = ["Corey Donohoe"]
s.email = ["atmos@atmos.org"] s.email = ["atmos@atmos.org"]
Expand Down
2 changes: 1 addition & 1 deletion spec/app.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def repos


get '/' do get '/' do
authenticate! authenticate!
"Hello There, #{github_user.name}!#{github_user.token}\n#{repos.inspect}" "Hello there, #{github_user.login}!"
end end


get '/orgs/:id' do get '/orgs/:id' do
Expand Down
25 changes: 25 additions & 0 deletions spec/login_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,25 @@
require "spec_helper"

describe "Logged in users" do
before do
@user = make_user('login' => 'defunkt')
login_as @user
end

it "greets the user" do
get "/"
last_response.body.should eql("Hello there, defunkt!")
end

it "logs the user out" do
get "/"

get "/logout"
last_response.status.should eql(302)
last_response.headers['Location'].should eql("https://github.com")

get "/"
last_response.status.should eql(302)
last_response.headers['Location'].should =~ %r{^https://github\.com/login/oauth/authorize}
end
end
12 changes: 10 additions & 2 deletions spec/spec_helper.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,23 @@
require "bundler/setup" require "bundler/setup"


require File.join(File.dirname(__FILE__), '..', 'lib', 'sinatra', 'auth', 'github') $:.push File.join(File.dirname(__FILE__), '..', 'lib')


require 'pp' require 'pp'
require 'rack/test'
require 'ruby-debug'


require 'rack/test' require 'rack/test'


require 'sinatra/auth/github'
require 'sinatra/auth/github/test/test_helper'

require 'app'

RSpec.configure do |config| RSpec.configure do |config|
config.include(Rack::Test::Methods) config.include(Rack::Test::Methods)
config.include(Sinatra::Auth::Github::Test::Helper)


def app def app
Example.app Example::App
end end
end end

0 comments on commit f171cde

Please sign in to comment.