Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Commit

Permalink
Added scaffolding for oauth endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilBetham committed Jul 9, 2014
1 parent 47debb3 commit a0997e0
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 53 deletions.
13 changes: 13 additions & 0 deletions Gemfile
Expand Up @@ -44,3 +44,16 @@ gem 'google-api-client', '~> 0.7.1'
# Send notifications via SMS
gem 'sms_fu', git: 'https://github.com/brendanlim/sms-fu.git'
gem 'pony', '~> 1.9'

# Background tasks handled by resque
gem 'resque', '~> 1.25.1', require: 'resque/server'
gem 'resque-scheduler', '~> 3.0.0'
gem 'resque_mailer'

# Premailer for email style inlining
gem 'premailer-rails', '~> 1.7.0'
gem 'nokogiri', '~> 1.6.2.1'

# Performance monitoring
gem 'rack-mini-profiler'
gem 'flamegraph', '~> 0.0.5'
55 changes: 55 additions & 0 deletions Gemfile.lock
Expand Up @@ -58,11 +58,18 @@ GEM
execjs
coffee-script-source (1.7.0)
colorize (0.7.3)
css_parser (1.3.5)
addressable
erubis (2.7.0)
execjs (2.2.1)
extlib (0.9.16)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
fast_stack (0.1.0)
rake
rake-compiler
flamegraph (0.0.5)
fast_stack
google-api-client (0.7.1)
addressable (>= 2.3.2)
autoparse (>= 0.3.3)
Expand All @@ -75,6 +82,7 @@ GEM
signet (>= 0.5.0)
uuidtools (>= 2.1.0)
hike (1.2.3)
htmlentities (4.3.2)
i18n (0.6.9)
jbuilder (2.1.2)
activesupport (>= 3.0.0, < 5)
Expand All @@ -90,16 +98,30 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.6.0)
minitest (5.4.0)
mono_logger (1.1.0)
multi_json (1.10.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
polyglot (0.3.5)
pony (1.9)
mail (>= 2.0)
premailer (1.8.2)
css_parser (>= 1.3.5)
htmlentities (>= 4.0.0)
premailer-rails (1.7.0)
actionmailer (>= 3, < 5)
premailer (~> 1.7, >= 1.7.9)
rack (1.5.2)
rack-mini-profiler (0.9.2)
rack (>= 1.1.3)
rack-protection (1.5.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (4.1.1)
Expand All @@ -118,9 +140,29 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
rake-compiler (0.9.2)
rake
rdoc (4.1.1)
json (~> 1.4)
redis (3.0.7)
redis-namespace (1.4.1)
redis (~> 3.0.4)
resque (1.25.2)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (3.0.0)
mono_logger (~> 1.0)
redis (~> 3.0)
resque (~> 1.25)
rufus-scheduler (~> 2.0)
resque_mailer (2.2.6)
actionmailer (>= 3.0)
retriable (1.4.1)
rufus-scheduler (2.0.24)
tzinfo (>= 0.3.22)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
Expand All @@ -135,6 +177,10 @@ GEM
faraday (>= 0.9.0.rc5)
jwt (>= 0.1.5)
multi_json (>= 1.0.0)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
spring (1.1.3)
sprockets (2.11.0)
hike (~> 1.2)
Expand Down Expand Up @@ -164,18 +210,27 @@ GEM
execjs (>= 0.3.0)
json (>= 1.8.0)
uuidtools (2.1.4)
vegas (0.1.11)
rack (>= 1.0.0)

PLATFORMS
ruby

DEPENDENCIES
capistrano-rails
coffee-rails (~> 4.0.0)
flamegraph (~> 0.0.5)
google-api-client (~> 0.7.1)
jbuilder (~> 2.0)
jquery-rails
nokogiri (~> 1.6.2.1)
pony (~> 1.9)
premailer-rails (~> 1.7.0)
rack-mini-profiler
rails (= 4.1.1)
resque (~> 1.25.1)
resque-scheduler (~> 3.0.0)
resque_mailer
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
sms_fu!
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/o_auth.js.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/o_auth.css.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the OAuth controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
9 changes: 9 additions & 0 deletions app/controllers/o_auth_controller.rb
@@ -0,0 +1,9 @@
class OAuthController < ApplicationController
def authorize
#TODO Redirect user to google o auth url
end

def callback
#TODO Store recevied token and authorize user to use app
end
end
2 changes: 2 additions & 0 deletions app/helpers/o_auth_helper.rb
@@ -0,0 +1,2 @@
module OAuthHelper
end
2 changes: 2 additions & 0 deletions app/views/o_auth/authorize.html.erb
@@ -0,0 +1,2 @@
<h1>OAuth#authorize</h1>
<p>Find me in app/views/o_auth/authorize.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/o_auth/callback.html.erb
@@ -0,0 +1,2 @@
<h1>OAuth#callback</h1>
<p>Find me in app/views/o_auth/callback.html.erb</p>
4 changes: 4 additions & 0 deletions config/initializers/resque.rb
@@ -0,0 +1,4 @@
require 'resque'
require 'resque/scheduler'
require 'resque/scheduler/server'
Resque.redis.namespace = "resque:diskjockey"
55 changes: 2 additions & 53 deletions config/routes.rb
@@ -1,56 +1,5 @@
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
get 'oauth/authorize', to: 'o_auth#authorize'
get 'oauth/callback', to: 'o_auth#callback'

# You can have the root of your site routed with "root"
# root 'welcome#index'

# Example of regular route:
# get 'products/:id' => 'catalog#view'

# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products

# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end

# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end

# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end

# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable

# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
26 changes: 26 additions & 0 deletions db/schema.rb
@@ -0,0 +1,26 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140709055905) do

create_table "users", force: true do |t|
t.string "username"
t.string "email"
t.string "phone"
t.string "phone_carrier"
t.text "google_api_token"
t.datetime "created_at"
t.datetime "updated_at"
end

end
12 changes: 12 additions & 0 deletions lib/tasks/resque.rake
@@ -0,0 +1,12 @@
# Resque tasks
require 'resque/tasks'
require 'resque/scheduler/tasks'

namespace :resque do
task :setup => :environment do
require 'resque'
require 'resque/scheduler'

Resque.schedule = YAML.load_file(Rails.root.join('config/resque_schedule.yml'))
end
end
14 changes: 14 additions & 0 deletions test/controllers/o_auth_controller_test.rb
@@ -0,0 +1,14 @@
require 'test_helper'

class OAuthControllerTest < ActionController::TestCase
test "should get authorize" do
get :authorize
assert_response :success
end

test "should get callback" do
get :callback
assert_response :success
end

end
4 changes: 4 additions & 0 deletions test/helpers/o_auth_helper_test.rb
@@ -0,0 +1,4 @@
require 'test_helper'

class OAuthHelperTest < ActionView::TestCase
end

0 comments on commit a0997e0

Please sign in to comment.