dailycred 0.1.461 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -2
- data/README.md +43 -15
- data/Rakefile +2 -2
- data/app/controllers/sessions_controller.rb +1 -1
- data/app/views/sessions/info.html.erb +2 -2
- data/config/routes.rb +4 -4
- data/dailycred.gemspec +1 -1
- data/dummy-preauth/.gitignore +16 -0
- data/dummy-preauth/Gemfile +42 -0
- data/dummy-preauth/README.rdoc +28 -0
- data/dummy-preauth/Rakefile +6 -0
- data/dummy-preauth/app/assets/images/rails.png +0 -0
- data/dummy-preauth/app/assets/javascripts/application.js +16 -0
- data/{dummy/app/assets/javascripts/posts.js.coffee → dummy-preauth/app/assets/javascripts/welcome.js.coffee} +1 -1
- data/dummy-preauth/app/assets/stylesheets/application.css +13 -0
- data/{dummy/app/assets/stylesheets/posts.css.scss → dummy-preauth/app/assets/stylesheets/welcome.css.scss} +1 -1
- data/dummy-preauth/app/controllers/application_controller.rb +6 -0
- data/{dummy/app/mailers/.gitkeep → dummy-preauth/app/controllers/concerns/.keep} +0 -0
- data/dummy-preauth/app/controllers/sessions_controller.rb +34 -0
- data/dummy-preauth/app/controllers/users_controller.rb +30 -0
- data/dummy-preauth/app/controllers/welcome_controller.rb +9 -0
- data/dummy-preauth/app/helpers/application_helper.rb +2 -0
- data/dummy-preauth/app/helpers/sessions_helper.rb +2 -0
- data/dummy-preauth/app/helpers/users_helper.rb +2 -0
- data/dummy-preauth/app/helpers/welcome_helper.rb +2 -0
- data/{dummy/app/models/.gitkeep → dummy-preauth/app/mailers/.keep} +0 -0
- data/{dummy/lib/assets/.gitkeep → dummy-preauth/app/models/.keep} +0 -0
- data/{dummy/lib/tasks/.gitkeep → dummy-preauth/app/models/concerns/.keep} +0 -0
- data/dummy-preauth/app/models/user.rb +34 -0
- data/dummy-preauth/app/views/layouts/application.html.erb +14 -0
- data/dummy-preauth/app/views/sessions/new.html.erb +15 -0
- data/dummy-preauth/app/views/users/_form.html.erb +20 -0
- data/dummy-preauth/app/views/users/edit.html.erb +3 -0
- data/dummy-preauth/app/views/users/new.html.erb +5 -0
- data/dummy-preauth/app/views/welcome/index.html.erb +2 -0
- data/dummy-preauth/bin/bundle +3 -0
- data/dummy-preauth/bin/rails +4 -0
- data/dummy-preauth/bin/rake +4 -0
- data/dummy-preauth/config.ru +4 -0
- data/dummy-preauth/config/application.rb +22 -0
- data/dummy-preauth/config/boot.rb +4 -0
- data/dummy-preauth/config/database.yml +25 -0
- data/dummy-preauth/config/environment.rb +5 -0
- data/dummy-preauth/config/environments/development.rb +27 -0
- data/dummy-preauth/config/environments/production.rb +80 -0
- data/dummy-preauth/config/environments/test.rb +36 -0
- data/dummy-preauth/config/initializers/backtrace_silencers.rb +7 -0
- data/dummy-preauth/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy-preauth/config/initializers/inflections.rb +16 -0
- data/dummy-preauth/config/initializers/mime_types.rb +5 -0
- data/dummy-preauth/config/initializers/omniauth.rb +9 -0
- data/dummy-preauth/config/initializers/secret_token.rb +12 -0
- data/dummy-preauth/config/initializers/session_store.rb +3 -0
- data/dummy-preauth/config/initializers/wrap_parameters.rb +14 -0
- data/dummy-preauth/config/locales/en.yml +23 -0
- data/dummy-preauth/config/routes.rb +57 -0
- data/dummy-preauth/db/migrate/20130423011519_create_users.rb +15 -0
- data/dummy-preauth/db/migrate/20130423011738_add_uuid_to_users.rb +5 -0
- data/dummy-preauth/db/schema.rb +26 -0
- data/dummy-preauth/db/seeds.rb +7 -0
- data/{dummy/log/.gitkeep → dummy-preauth/lib/assets/.keep} +0 -0
- data/dummy-preauth/lib/controller_authentication.rb +48 -0
- data/{dummy/test/fixtures/.gitkeep → dummy-preauth/lib/tasks/.keep} +0 -0
- data/{dummy/test/functional/.gitkeep → dummy-preauth/log/.keep} +0 -0
- data/dummy-preauth/public/404.html +27 -0
- data/dummy-preauth/public/422.html +26 -0
- data/dummy-preauth/public/500.html +26 -0
- data/{dummy/test/integration/.gitkeep → dummy-preauth/public/favicon.ico} +0 -0
- data/dummy-preauth/public/robots.txt +5 -0
- data/{dummy/test/unit/.gitkeep → dummy-preauth/test/controllers/.keep} +0 -0
- data/dummy-preauth/test/controllers/welcome_controller_test.rb +9 -0
- data/{dummy/vendor/assets/javascripts/.gitkeep → dummy-preauth/test/fixtures/.keep} +0 -0
- data/dummy-preauth/test/fixtures/users.yml +12 -0
- data/dummy-preauth/test/functional/sessions_controller_test.rb +22 -0
- data/dummy-preauth/test/functional/users_controller_test.rb +51 -0
- data/{dummy/vendor/assets/stylesheets/.gitkeep → dummy-preauth/test/helpers/.keep} +0 -0
- data/dummy-preauth/test/helpers/welcome_helper_test.rb +4 -0
- data/{dummy/vendor/plugins/.gitkeep → dummy-preauth/test/integration/.keep} +0 -0
- data/dummy-preauth/test/mailers/.keep +0 -0
- data/dummy-preauth/test/models/.keep +0 -0
- data/dummy-preauth/test/test_helper.rb +15 -0
- data/dummy-preauth/test/unit/user_test.rb +86 -0
- data/dummy-preauth/vendor/assets/javascripts/.keep +0 -0
- data/dummy-preauth/vendor/assets/stylesheets/.keep +0 -0
- data/dummy/.gitignore +3 -2
- data/dummy/Gemfile +14 -28
- data/dummy/README.rdoc +15 -248
- data/dummy/Rakefile +0 -1
- data/dummy/app/assets/javascripts/application.js +2 -1
- data/dummy/app/controllers/application_controller.rb +5 -4
- data/dummy/app/controllers/concerns/.keep +0 -0
- data/dummy/app/mailers/.keep +0 -0
- data/dummy/app/models/.keep +0 -0
- data/dummy/app/models/concerns/.keep +0 -0
- data/dummy/app/views/layouts/application.html.erb +2 -6
- data/dummy/bin/bundle +3 -0
- data/dummy/bin/rails +4 -0
- data/dummy/bin/rake +4 -0
- data/dummy/config/application.rb +2 -42
- data/dummy/config/boot.rb +0 -2
- data/dummy/config/environment.rb +2 -2
- data/dummy/config/environments/development.rb +9 -19
- data/dummy/config/environments/production.rb +40 -27
- data/dummy/config/environments/test.rb +12 -13
- data/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy/config/initializers/inflections.rb +6 -5
- data/dummy/config/initializers/omniauth.rb +9 -2
- data/dummy/config/initializers/secret_token.rb +6 -1
- data/dummy/config/initializers/session_store.rb +1 -6
- data/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/dummy/config/locales/en.yml +20 -2
- data/dummy/config/routes.rb +15 -26
- data/dummy/db/migrate/{20120925172903_create_users.rb → 20130417131939_create_users.rb} +7 -11
- data/dummy/db/schema.rb +9 -19
- data/dummy/lib/assets/.keep +0 -0
- data/dummy/lib/tasks/.keep +0 -0
- data/dummy/log/.keep +0 -0
- data/dummy/public/404.html +2 -1
- data/dummy/public/422.html +1 -1
- data/dummy/public/500.html +2 -1
- data/dummy/public/robots.txt +1 -1
- data/dummy/test/controllers/.keep +0 -0
- data/dummy/test/fixtures/.keep +0 -0
- data/dummy/test/helpers/.keep +0 -0
- data/dummy/test/integration/.keep +0 -0
- data/dummy/test/mailers/.keep +0 -0
- data/dummy/test/models/.keep +0 -0
- data/dummy/test/test_helper.rb +11 -58
- data/dummy/vendor/assets/javascripts/.keep +0 -0
- data/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/lib/dailycred.rb +2 -2
- data/lib/dailycred/acts_as_dailycred.rb +4 -17
- data/lib/dailycred/client.rb +1 -0
- data/lib/dailycred/engine.rb +3 -2
- data/lib/dailycred/helper.rb +4 -4
- data/lib/dailycred/middleware.rb +5 -2
- data/lib/dailycred/version.rb +1 -1
- data/lib/generators/dailycred_generator.rb +17 -8
- data/lib/generators/templates/migration_create_user.rb +3 -9
- data/lib/omniauth/strategies/dailycred.rb +2 -0
- data/spec/helper_spec.rb +1 -3
- data/test/generator_test.rb +4 -3
- metadata +103 -52
- data/dummy/Guardfile +0 -31
- data/dummy/app/assets/stylesheets/scaffolds.css.scss +0 -69
- data/dummy/app/controllers/posts_controller.rb +0 -86
- data/dummy/app/helpers/posts_helper.rb +0 -2
- data/dummy/app/models/post.rb +0 -3
- data/dummy/app/views/posts/_form.html.erb +0 -21
- data/dummy/app/views/posts/edit.html.erb +0 -6
- data/dummy/app/views/posts/index.html.erb +0 -23
- data/dummy/app/views/posts/new.html.erb +0 -5
- data/dummy/app/views/posts/show.html.erb +0 -10
- data/dummy/db/migrate/20120926012555_create_posts.rb +0 -9
- data/dummy/db/migrate/20121002192037_update_users_2.rb +0 -70
- data/dummy/db/migrate/20121108192739_add_column_to_posts.rb +0 -5
- data/dummy/public/index.html +0 -241
- data/dummy/script/rails +0 -6
- data/dummy/test/fixtures/posts.yml +0 -7
- data/dummy/test/fixtures/users.yml +0 -3
- data/dummy/test/functional/posts_controller_test.rb +0 -51
- data/dummy/test/performance/browsing_test.rb +0 -12
- data/dummy/test/unit/helpers/posts_helper_test.rb +0 -4
- data/dummy/test/unit/post_test.rb +0 -7
- data/dummy/test/unit/user_test.rb +0 -77
- data/spec/omniauth/strategies/dailycred_spec.rb +0 -64
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
hello: "Hello world"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
DummyPreauth::Application.routes.draw do
|
2
|
+
get "welcome/index"
|
3
|
+
get 'user/edit' => 'users#edit', :as => :edit_current_user
|
4
|
+
get 'signup' => 'users#new', :as => :signup
|
5
|
+
get 'logout' => 'sessions#destroy', :as => :logout
|
6
|
+
get 'login' => 'sessions#new', :as => :login
|
7
|
+
get 'auth/:provider/callback' => 'sessions#callback'
|
8
|
+
resources :sessions
|
9
|
+
resources :users
|
10
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
11
|
+
# See how all your routes lay out with "rake routes".
|
12
|
+
|
13
|
+
# You can have the root of your site routed with "root"
|
14
|
+
root to: 'welcome#index'
|
15
|
+
|
16
|
+
# Example of regular route:
|
17
|
+
# get 'products/:id' => 'catalog#view'
|
18
|
+
|
19
|
+
# Example of named route that can be invoked with purchase_url(id: product.id)
|
20
|
+
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
21
|
+
|
22
|
+
# Example resource route (maps HTTP verbs to controller actions automatically):
|
23
|
+
# resources :products
|
24
|
+
|
25
|
+
# Example resource route with options:
|
26
|
+
# resources :products do
|
27
|
+
# member do
|
28
|
+
# get 'short'
|
29
|
+
# post 'toggle'
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# collection do
|
33
|
+
# get 'sold'
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Example resource route with sub-resources:
|
38
|
+
# resources :products do
|
39
|
+
# resources :comments, :sales
|
40
|
+
# resource :seller
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Example resource route with more complex sub-resources:
|
44
|
+
# resources :products do
|
45
|
+
# resources :comments
|
46
|
+
# resources :sales do
|
47
|
+
# get 'recent', on: :collection
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
|
51
|
+
# Example resource route within a namespace:
|
52
|
+
# namespace :admin do
|
53
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
54
|
+
# # (app/controllers/admin/products_controller.rb)
|
55
|
+
# resources :products
|
56
|
+
# end
|
57
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :username
|
5
|
+
t.string :email
|
6
|
+
t.string :password_hash
|
7
|
+
t.string :password_salt
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :users
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20130423011738) do
|
15
|
+
|
16
|
+
create_table "users", force: true do |t|
|
17
|
+
t.string "username"
|
18
|
+
t.string "email"
|
19
|
+
t.string "password_hash"
|
20
|
+
t.string "password_salt"
|
21
|
+
t.datetime "created_at"
|
22
|
+
t.datetime "updated_at"
|
23
|
+
t.string "uuid"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This module is included in your application controller which makes
|
2
|
+
# several methods available to all controllers and views. Here's a
|
3
|
+
# common example you might add to your application layout file.
|
4
|
+
#
|
5
|
+
# <% if logged_in? %>
|
6
|
+
# Welcome <%= current_user.username %>.
|
7
|
+
# <%= link_to "Edit profile", edit_current_user_path %> or
|
8
|
+
# <%= link_to "Log out", logout_path %>
|
9
|
+
# <% else %>
|
10
|
+
# <%= link_to "Sign up", signup_path %> or
|
11
|
+
# <%= link_to "log in", login_path %>.
|
12
|
+
# <% end %>
|
13
|
+
#
|
14
|
+
# You can also restrict unregistered users from accessing a controller using
|
15
|
+
# a before filter. For example.
|
16
|
+
#
|
17
|
+
# before_filter :login_required, :except => [:index, :show]
|
18
|
+
module ControllerAuthentication
|
19
|
+
def self.included(controller)
|
20
|
+
controller.send :helper_method, :current_user, :logged_in?, :redirect_to_target_or_default
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_user
|
24
|
+
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
25
|
+
end
|
26
|
+
|
27
|
+
def logged_in?
|
28
|
+
current_user
|
29
|
+
end
|
30
|
+
|
31
|
+
def login_required
|
32
|
+
unless logged_in?
|
33
|
+
store_target_location
|
34
|
+
redirect_to login_url, :alert => "You must first log in or sign up before accessing this page."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def redirect_to_target_or_default(default, *args)
|
39
|
+
redirect_to(session[:return_to] || default, *args)
|
40
|
+
session[:return_to] = nil
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def store_target_location
|
46
|
+
session[:return_to] = request.url
|
47
|
+
end
|
48
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
<p>If you are the application owner check the logs for more information.</p>
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
<p>If you are the application owner check the logs for more information.</p>
|
25
|
+
</body>
|
26
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# password: "secret"
|
2
|
+
foo:
|
3
|
+
username: foo
|
4
|
+
email: foo@example.com
|
5
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
6
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
7
|
+
|
8
|
+
bar:
|
9
|
+
username: bar
|
10
|
+
email: bar@example.com
|
11
|
+
password_hash: 3488f5f7efecab14b91eb96169e5e1ee518a569f
|
12
|
+
password_salt: bef65e058905c379436d80d1a32e7374b139e7b0
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SessionsControllerTest < ActionController::TestCase
|
4
|
+
def test_new
|
5
|
+
get :new
|
6
|
+
assert_template 'new'
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_create_invalid
|
10
|
+
User.stubs(:authenticate).returns(nil)
|
11
|
+
post :create
|
12
|
+
assert_template 'new'
|
13
|
+
assert_nil session['user_id']
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_create_valid
|
17
|
+
User.stubs(:authenticate).returns(User.first)
|
18
|
+
post :create
|
19
|
+
assert_redirected_to root_url
|
20
|
+
assert_equal User.first.id, session['user_id']
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UsersControllerTest < ActionController::TestCase
|
4
|
+
def test_new
|
5
|
+
get :new
|
6
|
+
assert_template 'new'
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_create_invalid
|
10
|
+
User.any_instance.stubs(:valid?).returns(false)
|
11
|
+
post :create
|
12
|
+
assert_template 'new'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_create_valid
|
16
|
+
User.any_instance.stubs(:valid?).returns(true)
|
17
|
+
post :create
|
18
|
+
assert_redirected_to root_url
|
19
|
+
assert_equal assigns['user'].id, session['user_id']
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_edit_without_user
|
23
|
+
get :edit, :id => "ignored"
|
24
|
+
assert_redirected_to login_url
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_edit
|
28
|
+
@controller.stubs(:current_user).returns(User.first)
|
29
|
+
get :edit, :id => "ignored"
|
30
|
+
assert_template 'edit'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_update_without_user
|
34
|
+
put :update, :id => "ignored"
|
35
|
+
assert_redirected_to login_url
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_update_invalid
|
39
|
+
@controller.stubs(:current_user).returns(User.first)
|
40
|
+
User.any_instance.stubs(:valid?).returns(false)
|
41
|
+
put :update, :id => "ignored"
|
42
|
+
assert_template 'edit'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_update_valid
|
46
|
+
@controller.stubs(:current_user).returns(User.first)
|
47
|
+
User.any_instance.stubs(:valid?).returns(true)
|
48
|
+
put :update, :id => "ignored"
|
49
|
+
assert_redirected_to root_url
|
50
|
+
end
|
51
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rails/test_help'
|
4
|
+
|
5
|
+
class ActiveSupport::TestCase
|
6
|
+
ActiveRecord::Migration.check_pending!
|
7
|
+
|
8
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
9
|
+
#
|
10
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
11
|
+
# -- they do not yet inherit this setting
|
12
|
+
fixtures :all
|
13
|
+
|
14
|
+
# Add more helper methods to be used by all tests here...
|
15
|
+
end
|