Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'origin/master'

Conflicts:
	lib/sinatra/auth/github.rb
	sinatra_auth_github.gemspec
	spec/spec_helper.rb
  • Loading branch information...
commit f171cde040e98ff644ca0b644632028d43acf4b0 2 parents 3ee8203 + 4ae54b5
Corey Donohoe atmos authored
2  lib/sinatra/auth/github.rb
@@ -6,8 +6,6 @@
6 6 module Sinatra
7 7 module Auth
8 8 module Github
9   - VERSION = "0.4.2"
10   -
11 9 # Simple way to serve an image early in the stack and not get blocked by
12 10 # application level before filters
13 11 class AccessDenied < Sinatra::Base
31 lib/sinatra/auth/github/test/test_helper.rb
... ... @@ -0,0 +1,31 @@
  1 +require 'warden/test/helpers'
  2 +require 'warden-github/user'
  3 +
  4 +module Sinatra
  5 + module Auth
  6 + module Github
  7 + module Test
  8 + module Helper
  9 + include(Warden::Test::Helpers)
  10 + def make_user(attrs = {})
  11 + User.make(attrs)
  12 + end
  13 +
  14 + class User < Warden::Github::Oauth::User
  15 + def self.make(attrs = {})
  16 + default_attrs = {
  17 + 'login' => "test_user",
  18 + 'name' => "Test User",
  19 + 'email' => "test@example.com",
  20 + 'company' => "GitHub",
  21 + 'gravatar_id' => 'https://a249.e.akamai.net/assets.github.com/images/gravatars/gravatar-140.png'
  22 + }
  23 + default_attrs.merge! attrs
  24 + User.new(default_attrs)
  25 + end
  26 + end
  27 + end
  28 + end
  29 + end
  30 + end
  31 +end
7 lib/sinatra/auth/github/version.rb
... ... @@ -0,0 +1,7 @@
  1 +module Sinatra
  2 + module Auth
  3 + module Github
  4 + VERSION = "0.5.0"
  5 + end
  6 + end
  7 +end
3  sinatra_auth_github.gemspec
... ... @@ -1,9 +1,10 @@
1 1 # -*- encoding: utf-8 -*-
2 2 $:.push File.expand_path("../lib", __FILE__)
  3 +require "sinatra/auth/github/version"
3 4
4 5 Gem::Specification.new do |s|
5 6 s.name = "sinatra_auth_github"
6   - s.version = "0.4.2"
  7 + s.version = Sinatra::Auth::Github::VERSION
7 8 s.platform = Gem::Platform::RUBY
8 9 s.authors = ["Corey Donohoe"]
9 10 s.email = ["atmos@atmos.org"]
2  spec/app.rb
@@ -20,7 +20,7 @@ def repos
20 20
21 21 get '/' do
22 22 authenticate!
23   - "Hello There, #{github_user.name}!#{github_user.token}\n#{repos.inspect}"
  23 + "Hello there, #{github_user.login}!"
24 24 end
25 25
26 26 get '/orgs/:id' do
25 spec/login_spec.rb
... ... @@ -0,0 +1,25 @@
  1 +require "spec_helper"
  2 +
  3 +describe "Logged in users" do
  4 + before do
  5 + @user = make_user('login' => 'defunkt')
  6 + login_as @user
  7 + end
  8 +
  9 + it "greets the user" do
  10 + get "/"
  11 + last_response.body.should eql("Hello there, defunkt!")
  12 + end
  13 +
  14 + it "logs the user out" do
  15 + get "/"
  16 +
  17 + get "/logout"
  18 + last_response.status.should eql(302)
  19 + last_response.headers['Location'].should eql("https://github.com")
  20 +
  21 + get "/"
  22 + last_response.status.should eql(302)
  23 + last_response.headers['Location'].should =~ %r{^https://github\.com/login/oauth/authorize}
  24 + end
  25 +end
12 spec/spec_helper.rb
... ... @@ -1,15 +1,23 @@
1 1 require "bundler/setup"
2 2
3   -require File.join(File.dirname(__FILE__), '..', 'lib', 'sinatra', 'auth', 'github')
  3 +$:.push File.join(File.dirname(__FILE__), '..', 'lib')
4 4
5 5 require 'pp'
  6 +require 'rack/test'
  7 +require 'ruby-debug'
6 8
7 9 require 'rack/test'
8 10
  11 +require 'sinatra/auth/github'
  12 +require 'sinatra/auth/github/test/test_helper'
  13 +
  14 +require 'app'
  15 +
9 16 RSpec.configure do |config|
10 17 config.include(Rack::Test::Methods)
  18 + config.include(Sinatra::Auth::Github::Test::Helper)
11 19
12 20 def app
13   - Example.app
  21 + Example::App
14 22 end
15 23 end

0 comments on commit f171cde

Please sign in to comment.
Something went wrong with that request. Please try again.