Permalink
Browse files

login by github

  • Loading branch information...
1 parent 245e45a commit 97016b5b7f5323bda4159e3d3ceda78eb98d5e1e @flyerhzm flyerhzm committed Nov 23, 2011
Showing with 1,051 additions and 275 deletions.
  1. +2 −0 .gitignore
  2. +1 −0 .rspec
  3. +19 −3 Gemfile
  4. +144 −6 Gemfile.lock
  5. +1 −1 Rakefile
  6. +3 −0 app/assets/javascripts/users/sessions.js.coffee
  7. +3 −0 app/assets/stylesheets/users/sessions.css.scss
  8. +4 −0 app/controllers/home_controller.rb
  9. +14 −0 app/controllers/users/omniauth_callbacks_controller.rb
  10. +2 −0 app/controllers/users/sessions_controller.rb
  11. +2 −0 app/helpers/users/sessions_helper.rb
  12. +31 −0 app/models/user.rb
  13. +5 −0 app/views/devise/mailer/confirmation_instructions.html.erb
  14. +8 −0 app/views/devise/mailer/reset_password_instructions.html.erb
  15. +7 −0 app/views/devise/mailer/unlock_instructions.html.erb
  16. +25 −0 app/views/devise/shared/_links.erb
  17. 0 app/views/home/index.html.haml
  18. +0 −14 app/views/layouts/application.html.erb
  19. +16 −0 app/views/layouts/application.html.haml
  20. +5 −0 app/views/users/mailer/confirmation_instructions.html.erb
  21. +8 −0 app/views/users/mailer/reset_password_instructions.html.erb
  22. +7 −0 app/views/users/mailer/unlock_instructions.html.erb
  23. +25 −0 app/views/users/shared/_links.erb
  24. +1 −1 config.ru
  25. +7 −1 config/application.rb
  26. +8 −0 config/cucumber.yml
  27. +1 −1 config/environment.rb
  28. +3 −1 config/environments/development.rb
  29. +1 −1 config/environments/production.rb
  30. +1 −1 config/environments/test.rb
  31. +211 −0 config/initializers/devise.rb
  32. +1 −1 config/initializers/secret_token.rb
  33. +2 −2 config/initializers/session_store.rb
  34. +58 −0 config/locales/devise.en.yml
  35. +7 −1 config/routes.rb
  36. +28 −0 db/migrate/20111105031755_devise_create_users.rb
  37. +7 −0 db/migrate/20111122133254_add_github_uid_and_name_and_nickname_to_users.rb
  38. +37 −0 db/schema.rb
  39. +10 −0 features/account/sign_in_with_github.feature
  40. +100 −0 features/step_definitions/pickle_steps.rb
  41. +11 −0 features/step_definitions/web_steps.rb
  42. +66 −0 features/support/env.rb
  43. +26 −0 features/support/pickle.rb
  44. +65 −0 lib/tasks/cucumber.rake
  45. +0 −241 public/index.html
  46. +10 −0 script/cucumber
  47. +5 −0 spec/controllers/users/sessions_controller_spec.rb
  48. +15 −0 spec/helpers/users/sessions_helper_spec.rb
  49. +5 −0 spec/models/user_spec.rb
  50. +33 −0 spec/spec_helper.rb
View
2 .gitignore
@@ -3,4 +3,6 @@ db/*.sqlite3
log/*.log
tmp/
.sass-cache/
+.rvmrc
config/database.yml
+config/github.yml
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
22 Gemfile
@@ -8,7 +8,11 @@ gem 'rails', '3.1.1'
gem 'mysql2'
gem 'rails_best_practices'
gem 'haml'
-
+gem 'simple_form'
+gem 'omniauth'
+gem 'omniauth-github'
+gem 'devise'
+gem 'oa-core'
# Gems used only for assets and not required
# in production environments by default.
@@ -32,9 +36,21 @@ gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
+group :develop do
+ gem 'thin'
+end
+
group :test do
- # Pretty printed test output
- gem 'turn', :require => false
gem 'rspec'
gem 'rspec-rails'
+ gem 'factory_girl'
+ gem 'factory_girl_rails'
+ gem 'cucumber'
+ gem 'cucumber-rails'
+ gem 'capybara'
+ gem 'database_cleaner'
+ gem 'launchy'
+ gem 'pickle'
+
+ gem 'rails3-generators'
end
View
150 Gemfile.lock
@@ -29,32 +29,113 @@ GEM
activesupport (= 3.1.1)
activesupport (3.1.1)
multi_json (~> 1.0)
- ansi (1.3.0)
+ addressable (2.2.6)
arel (2.2.1)
+ bcrypt-ruby (3.0.1)
builder (3.0.0)
+ capistrano (2.9.0)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.1.0)
+ capybara (1.1.1)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.2.2)
+ ffi (~> 1.0.6)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.1.2)
+ colored (1.2)
+ cucumber (1.1.0)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.2)
+ gherkin (~> 2.5.0)
+ json (>= 1.4.6)
+ term-ansicolor (>= 1.0.6)
+ cucumber-rails (1.1.1)
+ capybara (>= 1.1.1)
+ cucumber (>= 1.1.0)
+ nokogiri (>= 1.5.0)
+ daemons (1.1.4)
+ database_cleaner (0.6.7)
+ devise (1.4.9)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.0.3)
+ warden (~> 1.0.3)
+ diff-lcs (1.1.3)
erubis (2.7.0)
+ eventmachine (0.12.10)
execjs (1.2.9)
multi_json (~> 1.0)
+ factory_girl (2.2.0)
+ activesupport
+ factory_girl_rails (1.3.0)
+ factory_girl (~> 2.2.0)
+ railties (>= 3.0.0)
+ faraday (0.7.5)
+ addressable (~> 2.2.6)
+ multipart-post (~> 1.1.3)
+ rack (>= 1.1.0, < 2)
+ ffi (1.0.9)
+ gherkin (2.5.2)
+ json (>= 1.4.6)
+ haml (3.1.3)
+ hashie (1.2.0)
+ highline (1.6.2)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.16)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.1)
+ json_pure (1.6.1)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.3)
+ multipart-post (1.1.3)
+ mysql2 (0.3.7)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-sftp (2.0.5)
+ net-ssh (>= 2.0.9)
+ net-ssh (2.2.1)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ nokogiri (1.5.0)
+ oa-core (0.3.0)
+ oauth2 (0.5.1)
+ faraday (~> 0.7.4)
+ multi_json (~> 1.0.3)
+ omniauth (1.0.0)
+ hashie (~> 1.2)
+ rack
+ omniauth-github (1.0.0)
+ omniauth (~> 1.0)
+ omniauth-oauth2 (~> 1.0)
+ omniauth-oauth2 (1.0.0)
+ oauth2 (~> 0.5.0)
+ omniauth (~> 1.0)
+ orm_adapter (0.0.5)
+ pickle (0.4.10)
+ cucumber (>= 0.8)
+ rake
polyglot (0.3.3)
+ progressbar (0.9.1)
rack (1.3.5)
rack-cache (1.1)
rack (>= 0.4)
@@ -72,6 +153,15 @@ GEM
activesupport (= 3.1.1)
bundler (~> 1.0)
railties (= 3.1.1)
+ rails3-generators (0.17.4)
+ railties (>= 3.0.0)
+ rails_best_practices (1.2.0)
+ activesupport
+ colored
+ erubis
+ i18n
+ progressbar
+ sexp_processor
railties (3.1.1)
actionpack (= 3.1.1)
activesupport (= 3.1.1)
@@ -82,38 +172,86 @@ GEM
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.7.0)
+ rspec-rails (2.7.0)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.7.0)
+ rubyzip (0.9.4)
sass (3.1.10)
sass-rails (3.1.4)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (>= 3.1.4)
sprockets (~> 2.0.0)
tilt (~> 1.3.2)
+ selenium-webdriver (2.8.0)
+ childprocess (>= 0.2.1)
+ ffi (>= 1.0.7)
+ json_pure
+ rubyzip
+ sexp_processor (3.0.7)
+ simple_form (1.5.2)
+ actionpack (~> 3.0)
+ activemodel (~> 3.0)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.4)
+ term-ansicolor (1.0.7)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- turn (0.8.3)
- ansi
tzinfo (0.3.30)
uglifier (1.0.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ warden (1.0.6)
+ rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ capistrano
+ capybara
coffee-rails (~> 3.1.1)
+ cucumber
+ cucumber-rails
+ database_cleaner
+ devise
+ factory_girl
+ factory_girl_rails
+ haml
jquery-rails
+ launchy
+ mysql2
+ oa-core
+ omniauth
+ omniauth-github
+ pickle
rails (= 3.1.1)
+ rails3-generators
+ rails_best_practices
+ rspec
+ rspec-rails
sass-rails (~> 3.1.4)
- sqlite3
- turn
+ simple_form
+ thin
uglifier (>= 1.0.3)
View
2 Rakefile
@@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
-ServiceRailsBestpracticesCom::Application.load_tasks
+RailsbpCom::Application.load_tasks
View
3 app/assets/javascripts/users/sessions.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://jashkenas.github.com/coffee-script/
View
3 app/assets/stylesheets/users/sessions.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the users/sessions controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
4 app/controllers/home_controller.rb
@@ -0,0 +1,4 @@
+class HomeController < ApplicationController
+ def index
+ end
+end
View
14 app/controllers/users/omniauth_callbacks_controller.rb
@@ -0,0 +1,14 @@
+class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
+ def github
+ # You need to implement the method below in your model
+ @user = User.find_for_github_oauth(env["omniauth.auth"])
+
+ if @user.persisted?
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Github"
+ sign_in_and_redirect @user, :event => :authentication
+ else
+ session["devise.github_data"] = env["omniauth.auth"]
+ redirect_to root_path
+ end
+ end
+end
View
2 app/controllers/users/sessions_controller.rb
@@ -0,0 +1,2 @@
+class Users::SessionsController < Devise::SessionsController
+end
View
2 app/helpers/users/sessions_helper.rb
@@ -0,0 +1,2 @@
+module Users::SessionsHelper
+end
View
31 app/models/user.rb
@@ -0,0 +1,31 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable,
+ :omniauthable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+
+ def self.find_for_github_oauth(data)
+ if user = User.find_by_github_uid(data.uid)
+ user
+ else # Create a user with a stub password.
+ user = User.new(:email => data.info.email, :password => Devise.friendly_token[0, 20])
+ user.github_uid = data.uid
+ user.name = data.info.name
+ user.nickname = data.info.nickname
+ user.save
+ user
+ end
+ end
+
+ def self.new_with_session(params, session)
+ super.tap do |user|
+ if data = session["devise.github_data"] && session["devise.github_data"]["user_info"]
+ user.email = data["email"]
+ end
+ end
+ end
+end
View
5 app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+<p>Welcome <%= @resource.email %>!</p>
+
+<p>You can confirm your account through the link below:</p>
+
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
View
8 app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
+
+<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
+
+<p>If you didn't request this, please ignore this email.</p>
+<p>Your password won't change until you access the link above and create a new one.</p>
View
7 app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
+
+<p>Click the link below to unlock your account:</p>
+
+<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
View
25 app/views/devise/shared/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
+ <% end -%>
+<% end -%>
View
0 app/views/home/index.html.haml
No changes.
View
14 app/views/layouts/application.html.erb
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>ServiceRailsBestpracticesCom</title>
- <%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-
-<%= yield %>
-
-</body>
-</html>
View
16 app/views/layouts/application.html.haml
@@ -0,0 +1,16 @@
+!!!
+%html
+ %head
+ %title Rails Best Practices Service
+ = stylesheet_link_tag "application"
+ = csrf_meta_tags
+ %body
+ .notice= notice
+ .alert= alert
+
+ - if user_signed_in?
+ = current_user.nickname
+ - else
+ = link_to "Sign in with Github", user_omniauth_authorize_path(:github)
+ = yield
+ = javascript_include_tag "application"
View
5 app/views/users/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+<p>Welcome <%= @resource.email %>!</p>
+
+<p>You can confirm your account through the link below:</p>
+
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
View
8 app/views/users/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
+
+<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
+
+<p>If you didn't request this, please ignore this email.</p>
+<p>Your password won't change until you access the link above and create a new one.</p>
View
7 app/views/users/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
+
+<p>Click the link below to unlock your account:</p>
+
+<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
View
25 app/views/users/shared/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
+ <% end -%>
+<% end -%>
View
2 config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run ServiceRailsBestpracticesCom::Application
+run RailsbpCom::Application
View
8 config/application.rb
@@ -9,8 +9,14 @@
# Bundler.require(:default, :assets, Rails.env)
end
-module ServiceRailsBestpracticesCom
+module RailsbpCom
class Application < Rails::Application
+ config.generators do |g|
+ g.test_framework :rspec, :views => false, :fixture => true
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
+ g.form_builder :simple_form
+ g.template_engine :haml
+ end
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
View
8 config/cucumber.yml
@@ -0,0 +1,8 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
+%>
+default: <%= std_opts %> features
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
2 config/environment.rb
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the rails application
-ServiceRailsBestpracticesCom::Application.initialize!
+RailsbpCom::Application.initialize!
View
4 config/environments/development.rb
@@ -1,4 +1,4 @@
-ServiceRailsBestpracticesCom::Application.configure do
+RailsbpCom::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
@@ -27,4 +27,6 @@
# Expands the lines which load the assets
config.assets.debug = true
+
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
end
View
2 config/environments/production.rb
@@ -1,4 +1,4 @@
-ServiceRailsBestpracticesCom::Application.configure do
+RailsbpCom::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
View
2 config/environments/test.rb
@@ -1,4 +1,4 @@
-ServiceRailsBestpracticesCom::Application.configure do
+RailsbpCom::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
View
211 config/initializers/devise.rb
@@ -0,0 +1,211 @@
+# Use this hook to configure devise mailer, warden hooks and so forth. The first
+# four configuration values can also be set straight in your models.
+Devise.setup do |config|
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = "Devise::Mailer"
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [ :email ]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [ :email ]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [ :email ]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
+ # config.http_authenticatable = false
+
+ # If http headers should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. "Application" by default.
+ # config.http_authentication_realm = "Application"
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+ # using other encryptors, it sets how many times you want the password re-encrypted.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments.
+ config.stretches = Rails.env.test? ? 1 : 10
+
+ # Setup a pepper to generate the encrypted password.
+ # config.pepper = "2f6e716eb1f7a34ff5b7d8ed678ea330b5f5496b28882b665ba0976a0df471dc90d744d61fcfbcb03626b774e550c1e5ee5abe3afc7776ade61e0971ce6a21e0"
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming his account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming his account,
+ # access will be blocked just in the third day. Default is 0.days, meaning
+ # the user cannot access the website without confirming his account.
+ # config.confirm_within = 2.days
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [ :email ]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # If true, a valid remember token can be re-used between multiple browsers.
+ # config.remember_across_browsers = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # If true, uses the password salt as remember token. This should be turned
+ # to false if you are not using database authenticatable.
+ config.use_salt_as_remember_token = true
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # :secure => true in order to force SSL only cookies.
+ # config.cookie_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length. Default is 6..128.
+ # config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # an one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [ :email ]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [ :email ]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 2.hours
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
+ # REST_AUTH_SITE_KEY to pepper)
+ # config.encryptor = :sha512
+
+ # ==> Configuration for :token_authenticatable
+ # Defines name of the authentication token params key
+ # config.token_authentication_key = :auth_token
+
+ # If true, authentication through token does not store user in session and needs
+ # to be supplied on each request. Useful if you are using the token as API token.
+ # config.stateless_token = false
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Configure sign_out behavior.
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
+ # The default is true, which means any logout action will sign out all active scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The :"*/*" and "*/*" formats below is required to match Internet
+ # Explorer requests.
+ # config.navigational_formats = [:"*/*", "*/*", :html]
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ GITHUB_CONFIG = YAML.load_file(Rails.root.join('config', 'github.yml'))[Rails.env]
+ config.omniauth :github, GITHUB_CONFIG['key'], GITHUB_CONFIG['secret'], :scope => 'repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.failure_app = AnotherApp
+ # manager.intercept_401 = false
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
+ # end
+end
View
2 config/initializers/secret_token.rb
@@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
-ServiceRailsBestpracticesCom::Application.config.secret_token = '3ec409d02c71a93e08603efc0293be610f7e74cc70e3bf8631e1104f2226a831841a64d52ba8998d59e14d856e7f094de1bc74b3ab7bdd30f18b2e5f9750c661'
+RailsbpCom::Application.config.secret_token = '3ec409d02c71a93e08603efc0293be610f7e74cc70e3bf8631e1104f2226a831841a64d52ba8998d59e14d856e7f094de1bc74b3ab7bdd30f18b2e5f9750c661'
View
4 config/initializers/session_store.rb
@@ -1,8 +1,8 @@
# Be sure to restart your server when you modify this file.
-ServiceRailsBestpracticesCom::Application.config.session_store :cookie_store, key: '_service.rails-bestpractices.com_session'
+RailsbpCom::Application.config.session_store :cookie_store, key: '_railsbp.com_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
-# ServiceRailsBestpracticesCom::Application.config.session_store :active_record_store
+# RailsbpCom::Application.config.session_store :active_record_store
View
58 config/locales/devise.en.yml
@@ -0,0 +1,58 @@
+# Additional translations at http://github.com/plataformatec/devise/wiki/I18n
+
+en:
+ errors:
+ messages:
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ already_confirmed: "was already confirmed, please try signing in"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
+
+ devise:
+ failure:
+ already_authenticated: 'You are already signed in.'
+ unauthenticated: 'You need to sign in or sign up before continuing.'
+ unconfirmed: 'You have to confirm your account before continuing.'
+ locked: 'Your account is locked.'
+ invalid: 'Invalid email or password.'
+ invalid_token: 'Invalid authentication token.'
+ timeout: 'Your session expired, please sign in again to continue.'
+ inactive: 'Your account was not activated yet.'
+ sessions:
+ signed_in: 'Signed in successfully.'
+ signed_out: 'Signed out successfully.'
+ passwords:
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
+ updated: 'Your password was changed successfully. You are now signed in.'
+ updated_not_active: 'Your password was changed successfully.'
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
+ confirmations:
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
+ registrations:
+ signed_up: 'Welcome! You have signed up successfully.'
+ inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
+ updated: 'You updated your account successfully.'
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
+ reasons:
+ inactive: 'inactive'
+ unconfirmed: 'unconfirmed'
+ locked: 'locked'
+ unlocks:
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
+ omniauth_callbacks:
+ success: 'Successfully authorized from %{kind} account.'
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
+ mailer:
+ confirmation_instructions:
+ subject: 'Confirmation instructions'
+ reset_password_instructions:
+ subject: 'Reset password instructions'
+ unlock_instructions:
+ subject: 'Unlock Instructions'
View
8 config/routes.rb
@@ -1,4 +1,10 @@
-ServiceRailsBestpracticesCom::Application.routes.draw do
+RailsbpCom::Application.routes.draw do
+ root :to => "home#index"
+ devise_for :users, :controllers => { :sessions => "users/sessions", :omniauth_callbacks => "users/omniauth_callbacks" } do
+ get 'sign_in', :to => 'users/sessions#new', :as => :new_user_session
+ get 'sign_out', :to => 'users/sessions#destroy', :as => :destroy_user_session
+ end
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
28 db/migrate/20111105031755_devise_create_users.rb
@@ -0,0 +1,28 @@
+class DeviseCreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table(:users) do |t|
+ t.database_authenticatable :null => false
+ t.recoverable
+ t.rememberable
+ t.trackable
+
+ # t.encryptable
+ # t.confirmable
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
+ # t.token_authenticatable
+
+
+ t.timestamps
+ end
+
+ add_index :users, :email, :unique => true
+ add_index :users, :reset_password_token, :unique => true
+ # add_index :users, :confirmation_token, :unique => true
+ # add_index :users, :unlock_token, :unique => true
+ # add_index :users, :authentication_token, :unique => true
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
View
7 db/migrate/20111122133254_add_github_uid_and_name_and_nickname_to_users.rb
@@ -0,0 +1,7 @@
+class AddGithubUidAndNameAndNicknameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :github_uid, :integer
+ add_column :users, :nickname, :string
+ add_column :users, :name, :string
+ end
+end
View
37 db/schema.rb
@@ -0,0 +1,37 @@
+# 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 to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20111122133254) do
+
+ create_table "users", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "github_uid"
+ t.string "nickname"
+ t.string "name"
+ end
+
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
+
+end
View
10 features/account/sign_in_with_github.feature
@@ -0,0 +1,10 @@
+Feature: Sign in with github
+ In order to sign in with github
+ As a github user
+ I want to click an icon and be signed in
+
+ Scenario: Successful sign in with github
+ Given I am on the homepage
+ When I click "Sign in with Github"
+ Then I should see "Successfully authorized from Github account."
+ And I should see "flyerhzm"
View
100 features/step_definitions/pickle_steps.rb
@@ -0,0 +1,100 @@
+# this file generated by script/generate pickle
+
+# create a model
+Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
+ create_model(name, fields)
+end
+
+# create n models
+Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
+ count.to_i.times { create_model(plural_factory.singularize, fields) }
+end
+
+# create models from a table
+Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
+ create_models_from_table(plural_factory, table)
+end
+
+# find a model
+Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
+ find_model!(name, fields)
+end
+
+# not find a model
+Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
+ find_model(name, fields).should be_nil
+end
+
+# find models with a table
+Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
+ find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
+end
+
+# find exactly n models
+Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
+ find_models(plural_factory.singularize, fields).size.should == count.to_i
+end
+
+# assert equality of models
+Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
+ model!(a).should == model!(b)
+end
+
+# assert model is in another model's has_many assoc
+Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
+ model!(owner).send(association).should include(model!(target))
+end
+
+# assert model is not in another model's has_many assoc
+Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
+ model!(owner).send(association).should_not include(model!(target))
+end
+
+# assert model is another model's has_one/belongs_to assoc
+Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
+ model!(owner).send(association).should == model!(target)
+end
+
+# assert model is not another model's has_one/belongs_to assoc
+Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
+ model!(owner).send(association).should_not == model!(target)
+end
+
+# assert model.predicate?
+Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
+ model!(name).should send("have_#{predicate.gsub(' ', '_')}")
+ else
+ model!(name).should send("be_#{predicate.gsub(' ', '_')}")
+ end
+end
+
+# assert not model.predicate?
+Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
+ if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
+ model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
+ else
+ model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
+ end
+end
+
+# model.attribute.should eql(value)
+# model.attribute.should_not eql(value)
+Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
+ actual_value = model(name).send(attribute)
+ expectation = expectation.gsub(' ', '_')
+
+ case expected
+ when 'nil', 'true', 'false'
+ actual_value.send(expectation, send("be_#{expected}"))
+ when /^[+-]?[0-9_]+(\.\d+)?$/
+ actual_value.send(expectation, eql(expected.to_f))
+ else
+ actual_value.to_s.send(expectation, eql(eval(expected)))
+ end
+end
+
+# assert size of association
+Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
+ model!(name).send(association).size.should == size.to_i
+end
View
11 features/step_definitions/web_steps.rb
@@ -0,0 +1,11 @@
+Given /^I am on the homepage$/ do
+ visit '/'
+end
+
+When /^I click "([^"]*)"/ do |text|
+ click_on text
+end
+
+Then /^I should see "([^"]*)"/ do |text|
+ page.html.should match text
+end
View
66 features/support/env.rb
@@ -0,0 +1,66 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+require 'cucumber/rails'
+
+# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
+# order to ease the transition to Capybara we set the default here. If you'd
+# prefer to use XPath just remove this line and adjust any selectors in your
+# steps to use the XPath syntax.
+Capybara.default_selector = :css
+
+# By default, any exception happening in your Rails application will bubble up
+# to Cucumber so that your scenario will fail. This is a different from how
+# your application behaves in the production environment, where an error page will
+# be rendered instead.
+#
+# Sometimes we want to override this default behaviour and allow Rails to rescue
+# exceptions and display an error page (just like when the app is running in production).
+# Typical scenarios where you want to do this is when you test your error pages.
+# There are two ways to allow Rails to rescue exceptions:
+#
+# 1) Tag your scenario (or feature) with @allow-rescue
+#
+# 2) Set the value below to true. Beware that doing this globally is not
+# recommended as it will mask a lot of errors for you!
+#
+ActionController::Base.allow_rescue = false
+
+# Remove/comment out the lines below if your app doesn't have a database.
+# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
+begin
+ DatabaseCleaner.strategy = :transaction
+rescue NameError
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
+end
+
+OmniAuth.config.test_mode = true
+OmniAuth.config.mock_auth[:github] = Hashie::Mash.new({
+ provider: 'github',
+ uid: '123456',
+ info: {
+ nickname: 'flyerhzm',
+ email: 'flyerhzm@gmail.com',
+ name: 'Richard Huang',
+ },
+ credentials: {
+ token: 'abcdefg',
+ secret: 'abcdefg'
+ }
+})
+
+
+# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
+# See the DatabaseCleaner documentation for details. Example:
+#
+# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
+# DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
+# end
+#
+# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
+# DatabaseCleaner.strategy = :transaction
+# end
+#
View
26 features/support/pickle.rb
@@ -0,0 +1,26 @@
+# this file generated by script/generate pickle [paths] [email]
+#
+# Make sure that you are loading your factory of choice in your cucumber environment
+#
+# For machinist add: features/support/machinist.rb
+#
+# require 'machinist/active_record' # or your chosen adaptor
+# require File.dirname(__FILE__) + '/../../spec/blueprints' # or wherever your blueprints are
+# Before { Sham.reset } # to reset Sham's seed between scenarios so each run has same random sequences
+#
+# For FactoryGirl add: features/support/factory_girl.rb
+#
+# require 'factory_girl'
+# require File.dirname(__FILE__) + '/../../spec/factories' # or wherever your factories are
+#
+# For Fabrication, just include it in the adapter list when configuring pickle as explained below.
+#
+# You may also need to add gem dependencies on your factory of choice in <tt>config/environments/cucumber.rb</tt>
+
+require 'pickle/world'
+# Example of configuring pickle:
+#
+# Pickle.configure do |config|
+# config.adapters = [:machinist]
+# config.map 'I', 'myself', 'me', 'my', :to => 'user: "me"'
+# end
View
65 lib/tasks/cucumber.rake
@@ -0,0 +1,65 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+
+unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
+
+vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
+
+begin
+ require 'cucumber/rake/task'
+
+ namespace :cucumber do
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'default'
+ end
+
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'wip'
+ end
+
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'rerun'
+ end
+
+ desc 'Run all features'
+ task :all => [:ok, :wip]
+
+ task :statsetup do
+ require 'rails/code_statistics'
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
+ end
+ end
+ desc 'Alias for cucumber:ok'
+ task :cucumber => 'cucumber:ok'
+
+ task :default => :cucumber
+
+ task :features => :cucumber do
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
+ end
+
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
+ task 'db:test:prepare' do
+ end
+
+ task :stats => 'cucumber:statsetup'
+rescue LoadError
+ desc 'cucumber rake task not available (cucumber not installed)'
+ task :cucumber do
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ end
+end
+
+end
View
241 public/index.html
@@ -1,241 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Ruby on Rails: Welcome aboard</title>
- <style type="text/css" media="screen">
- body {
- margin: 0;
- margin-bottom: 25px;
- padding: 0;
- background-color: #f0f0f0;
- font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
- font-size: 13px;
- color: #333;
- }
-
- h1 {
- font-size: 28px;
- color: #000;
- }
-
- a {color: #03c}
- a:hover {
- background-color: #03c;
- color: white;
- text-decoration: none;
- }
-
-
- #page {
- background-color: #f0f0f0;
- width: 750px;
- margin: 0;
- margin-left: auto;
- margin-right: auto;
- }
-
- #content {
- float: left;
- background-color: white;
- border: 3px solid #aaa;
- border-top: none;
- padding: 25px;
- width: 500px;
- }
-
- #sidebar {
- float: right;
- width: 175px;
- }
-
- #footer {
- clear: both;
- }
-
- #header, #about, #getting-started {
- padding-left: 75px;
- padding-right: 30px;
- }
-
-
- #header {
- background-image: url("/assets/rails.png");
- background-repeat: no-repeat;
- background-position: top left;
- height: 64px;
- }
- #header h1, #header h2 {margin: 0}
- #header h2 {
- color: #888;
- font-weight: normal;
- font-size: 16px;
- }
-
-
- #about h3 {
- margin: 0;
- margin-bottom: 10px;
- font-size: 14px;
- }
-
- #about-content {
- background-color: #ffd;
- border: 1px solid #fc0;
- margin-left: -55px;
- margin-right: -10px;
- }
- #about-content table {
- margin-top: 10px;
- margin-bottom: 10px;
- font-size: 11px;
- border-collapse: collapse;
- }
- #about-content td {
- padding: 10px;
- padding-top: 3px;
- padding-bottom: 3px;
- }
- #about-content td.name {color: #555}
- #about-content td.value {color: #000}
-
- #about-content ul {
- padding: 0;
- list-style-type: none;
- }
-
- #about-content.failure {
- background-color: #fcc;
- border: 1px solid #f00;
- }
- #about-content.failure p {
- margin: 0;
- padding: 10px;
- }
-
-
- #getting-started {
- border-top: 1px solid #ccc;
- margin-top: 25px;
- padding-top: 15px;
- }
- #getting-started h1 {
- margin: 0;
- font-size: 20px;
- }
- #getting-started h2 {
- margin: 0;
- font-size: 14px;
- font-weight: normal;
- color: #333;
- margin-bottom: 25px;
- }
- #getting-started ol {
- margin-left: 0;
- padding-left: 0;
- }
- #getting-started li {
- font-size: 18px;
- color: #888;
- margin-bottom: 25px;
- }
- #getting-started li h2 {
- margin: 0;
- font-weight: normal;
- font-size: 18px;
- color: #333;
- }
- #getting-started li p {
- color: #555;
- font-size: 13px;
- }
-
-
- #sidebar ul {
- margin-left: 0;
- padding-left: 0;
- }
- #sidebar ul h3 {
- margin-top: 25px;
- font-size: 16px;
- padding-bottom: 10px;
- border-bottom: 1px solid #ccc;
- }
- #sidebar li {
- list-style-type: none;
- }
- #sidebar ul.links li {
- margin-bottom: 5px;
- }
-
- .filename {
- font-style: italic;
- }
- </style>
- <script type="text/javascript">
- function about() {
- info = document.getElementById('about-content');
- if (window.XMLHttpRequest)
- { xhr = new XMLHttpRequest(); }
- else
- { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
- xhr.open("GET","rails/info/properties",false);
- xhr.send("");
- info.innerHTML = xhr.responseText;
- info.style.display = 'block'
- }
- </script>
- </head>
- <body>
- <div id="page">
- <div id="sidebar">
- <ul id="sidebar-items">
- <li>
- <h3>Browse the documentation</h3>
- <ul class="links">
- <li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
- <li><a href="http://api.rubyonrails.org/">Rails API</a></li>
- <li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
- <li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
- </ul>
- </li>
- </ul>
- </div>
-
- <div id="content">
- <div id="header">
- <h1>Welcome aboard</h1>
- <h2>You&rsquo;re riding Ruby on Rails!</h2>
- </div>
-
- <div id="about">
- <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
- <div id="about-content" style="display: none"></div>
- </div>
-
- <div id="getting-started">
- <h1>Getting started</h1>
- <h2>Here&rsquo;s how to get rolling:</h2>
-
- <ol>
- <li>
- <h2>Use <code>rails generate</code> to create your models and controllers</h2>
- <p>To see all available options, run it without parameters.</p>
- </li>
-
- <li>
- <h2>Set up a default route and remove <span class="filename">public/index.html</span></h2>
- <p>Routes are set up in <span class="filename">config/routes.rb</span>.</p>
- </li>
-
- <li>
- <h2>Create your database</h2>
- <p>Run <code>rake db:create</code> to create your database. If you're not using SQLite (the default), edit <span class="filename">config/database.yml</span> with your username and password.</p>
- </li>
- </ol>
- </div>
- </div>
-
- <div id="footer">&nbsp;</div>
- </div>
- </body>
-</html>
View
10 script/cucumber
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+if vendored_cucumber_bin
+ load File.expand_path(vendored_cucumber_bin)
+else
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
+ require 'cucumber'
+ load Cucumber::BINARY
+end
View
5 spec/controllers/users/sessions_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Users::SessionsController do
+
+end
View
15 spec/helpers/users/sessions_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the Users::SessionsHelper. For example:
+#
+# describe Users::SessionsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe Users::SessionsHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/models/user_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe User do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
33 spec/spec_helper.rb
@@ -0,0 +1,33 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV["RAILS_ENV"] ||= 'test'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+require 'rspec/autorun'
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+end

0 comments on commit 97016b5

Please sign in to comment.