mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 11:10:12 +01:00
a bit more around user authentication. this checkin is nto in a good state, but i want to transfer work to my laptop to head to the beach. Use [557] for a stable build.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@560 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
ae9ecb398f
commit
855f6e0beb
4 changed files with 124 additions and 25 deletions
13
tracks/db/migrate/033_add_remember_me_to_user.rb
Normal file
13
tracks/db/migrate/033_add_remember_me_to_user.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class AddRememberMeToUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
rename_column :users, :password, :crypted_password
|
||||
add_column :users, :remember_token, :string
|
||||
add_column :users, :remember_token_expires_at, :datetime
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :users, :remember_token
|
||||
remove_column :users, :remember_token_expires_at
|
||||
rename_column :users, :password, :crypted_password
|
||||
end
|
||||
end
|
||||
|
|
@ -2,13 +2,26 @@
|
|||
# migrations feature of ActiveRecord to incrementally modify your database, and
|
||||
# then regenerate this schema definition.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 32) do
|
||||
ActiveRecord::Schema.define(:version => 33) do
|
||||
|
||||
create_table "bow_wows", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "cats", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "cat_type", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "contexts", :force => true do |t|
|
||||
t.column "name", :string, :default => "", :null => false
|
||||
t.column "position", :integer, :null => false
|
||||
t.column "hide", :boolean, :default => false
|
||||
t.column "user_id", :integer, :default => 1
|
||||
t.column "name", :string, :default => "", :null => false
|
||||
t.column "hide", :integer, :limit => 4, :default => 0, :null => false
|
||||
t.column "position", :integer, :default => 0, :null => false
|
||||
t.column "user_id", :integer, :default => 0, :null => false
|
||||
t.column "created_at", :datetime
|
||||
t.column "updated_at", :datetime
|
||||
end
|
||||
|
|
@ -16,9 +29,48 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
add_index "contexts", ["user_id"], :name => "index_contexts_on_user_id"
|
||||
add_index "contexts", ["user_id", "name"], :name => "index_contexts_on_user_id_and_name"
|
||||
|
||||
create_table "eaters_foodstuffs", :force => true do |t|
|
||||
t.column "foodstuff_id", :integer
|
||||
t.column "eater_id", :integer
|
||||
t.column "some_attribute", :integer, :default => 0
|
||||
t.column "eater_type", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "fish", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "speed", :integer
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "frogs", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "keep_your_enemies_close", :force => true do |t|
|
||||
t.column "enemy_id", :integer
|
||||
t.column "enemy_type", :string
|
||||
t.column "protector_id", :integer
|
||||
t.column "protector_type", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "little_whale_pupils", :force => true do |t|
|
||||
t.column "whale_id", :integer
|
||||
t.column "aquatic_pupil_id", :integer
|
||||
t.column "aquatic_pupil_type", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "notes", :force => true do |t|
|
||||
t.column "user_id", :integer, :null => false
|
||||
t.column "project_id", :integer, :null => false
|
||||
t.column "user_id", :integer, :default => 0, :null => false
|
||||
t.column "project_id", :integer, :default => 0, :null => false
|
||||
t.column "body", :text
|
||||
t.column "created_at", :datetime
|
||||
t.column "updated_at", :datetime
|
||||
|
|
@ -43,8 +95,15 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
t.column "value", :binary
|
||||
end
|
||||
|
||||
create_table "petfoods", :id => false, :force => true do |t|
|
||||
t.column "the_petfood_primary_key", :integer, :null => false
|
||||
t.column "name", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "preferences", :force => true do |t|
|
||||
t.column "user_id", :integer, :null => false
|
||||
t.column "user_id", :integer, :default => 0, :null => false
|
||||
t.column "date_format", :string, :limit => 40, :default => "%d/%m/%Y", :null => false
|
||||
t.column "week_starts", :integer, :default => 0, :null => false
|
||||
t.column "show_number_completed", :integer, :default => 5, :null => false
|
||||
|
|
@ -66,8 +125,8 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
|
||||
create_table "projects", :force => true do |t|
|
||||
t.column "name", :string, :default => "", :null => false
|
||||
t.column "position", :integer, :null => false
|
||||
t.column "user_id", :integer, :default => 1
|
||||
t.column "position", :integer, :default => 0, :null => false
|
||||
t.column "user_id", :integer, :default => 0, :null => false
|
||||
t.column "description", :text
|
||||
t.column "state", :string, :limit => 20, :default => "active", :null => false
|
||||
t.column "created_at", :datetime
|
||||
|
|
@ -84,7 +143,7 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
t.column "updated_at", :datetime
|
||||
end
|
||||
|
||||
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
|
||||
add_index "sessions", ["session_id"], :name => "sessions_session_id_index"
|
||||
|
||||
create_table "taggings", :force => true do |t|
|
||||
t.column "taggable_id", :integer
|
||||
|
|
@ -104,16 +163,16 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
add_index "tags", ["name"], :name => "index_tags_on_name"
|
||||
|
||||
create_table "todos", :force => true do |t|
|
||||
t.column "context_id", :integer, :null => false
|
||||
t.column "project_id", :integer
|
||||
t.column "description", :string, :default => "", :null => false
|
||||
t.column "context_id", :integer, :default => 0, :null => false
|
||||
t.column "description", :string, :limit => 100, :default => "", :null => false
|
||||
t.column "notes", :text
|
||||
t.column "created_at", :datetime
|
||||
t.column "due", :date
|
||||
t.column "completed_at", :datetime
|
||||
t.column "user_id", :integer, :default => 1
|
||||
t.column "project_id", :integer
|
||||
t.column "user_id", :integer, :default => 0, :null => false
|
||||
t.column "show_from", :date
|
||||
t.column "state", :string, :limit => 20, :default => "immediate", :null => false
|
||||
t.column "state", :string, :limit => 20, :default => "immediate", :null => false
|
||||
end
|
||||
|
||||
add_index "todos", ["user_id", "state"], :name => "index_todos_on_user_id_and_state"
|
||||
|
|
@ -123,16 +182,30 @@ ActiveRecord::Schema.define(:version => 32) do
|
|||
add_index "todos", ["user_id", "context_id"], :name => "index_todos_on_user_id_and_context_id"
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.column "login", :string, :limit => 80, :default => "", :null => false
|
||||
t.column "password", :string, :limit => 40, :default => "", :null => false
|
||||
t.column "word", :string
|
||||
t.column "is_admin", :boolean, :default => false, :null => false
|
||||
t.column "first_name", :string
|
||||
t.column "last_name", :string
|
||||
t.column "auth_type", :string, :default => "database", :null => false
|
||||
t.column "open_id_url", :string
|
||||
t.column "login", :string, :limit => 80
|
||||
t.column "crypted_password", :string, :limit => 40
|
||||
t.column "word", :string
|
||||
t.column "is_admin", :integer, :limit => 4, :default => 0, :null => false
|
||||
t.column "first_name", :string
|
||||
t.column "last_name", :string
|
||||
t.column "auth_type", :string, :default => "database", :null => false
|
||||
t.column "open_id_url", :string
|
||||
t.column "remember_token", :string
|
||||
t.column "remember_token_expires_at", :datetime
|
||||
end
|
||||
|
||||
add_index "users", ["login"], :name => "index_users_on_login"
|
||||
|
||||
create_table "whales", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
create_table "wild_boars", :force => true do |t|
|
||||
t.column "name", :string
|
||||
t.column "created_at", :datetime, :null => false
|
||||
t.column "updated_at", :datetime, :null => false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class PreferencesControllerTest < Test::Rails::TestCase
|
|||
end
|
||||
|
||||
def test_update_preferences
|
||||
@request.session['user_id'] = users(:admin_user).id # log in the admin user
|
||||
login_as :admin_user
|
||||
post :update, {:user => { :first_name => 'Jane', :last_name => 'Doe'}, :prefs => { :date_format => "%m-%d-%Y", :week_starts => "0", :show_number_completed => "10", :show_completed_projects_in_sidebar => "false", :show_hidden_contexts_in_sidebar => "false", :staleness_starts => "14", :due_style => "1", :admin_email => "my.email@domain.com" }}
|
||||
updated_admin_user = User.find(users(:admin_user).id)
|
||||
assert_not_nil updated_admin_user.preference
|
||||
|
|
|
|||
|
|
@ -313,6 +313,19 @@ class UserTest < Test::Rails::TestCase
|
|||
assert_equal users(:other_user), User.authenticate('jane', 'sesame')
|
||||
end
|
||||
|
||||
def test_should_set_remember_token
|
||||
users(:other_user).remember_me
|
||||
assert_not_nil users(:other_user).remember_token
|
||||
assert_not_nil users(:other_user).remember_token_expires_at
|
||||
end
|
||||
|
||||
def test_should_unset_remember_token
|
||||
users(:other_user).remember_me
|
||||
assert_not_nil users(:other_user).remember_token
|
||||
users(:other_user).forget_me
|
||||
assert_nil users(:other_user).remember_token
|
||||
end
|
||||
|
||||
protected
|
||||
def create_user(options = {})
|
||||
options[:password_confirmation] = options[:password] unless options.has_key?(:password_confirmation) || !options.has_key?(:password)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue