diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..b2423b3bd --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,6 @@ +class User < ActiveRecord::Base + devise :database_authenticatable, + :recoverable, :rememberable, :validatable + + attr_accessible :email, :password, :password_confirmation, :remember_me, :name +end diff --git a/config/routes.rb b/config/routes.rb index 525cbbd44..bb59c395c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rosa::Application.routes.draw do + devise_for :users + root :to => "platforms#index" end diff --git a/db/migrate/20110309144736_devise_create_users.rb b/db/migrate/20110309144736_devise_create_users.rb new file mode 100644 index 000000000..608013a61 --- /dev/null +++ b/db/migrate/20110309144736_devise_create_users.rb @@ -0,0 +1,18 @@ +class DeviseCreateUsers < ActiveRecord::Migration + def self.up + create_table(:users) do |t| + t.string :name + t.database_authenticatable :null => false + t.recoverable + t.rememberable + t.timestamps + end + + add_index :users, :email, :unique => true + add_index :users, :reset_password_token, :unique => true + end + + def self.down + drop_table :users + end +end diff --git a/db/schema.rb b/db/schema.rb index 671c0daef..34ae0c791 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,6 +10,21 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 0) do +ActiveRecord::Schema.define(:version => 20110309144736) do + + create_table "users", :force => true do |t| + t.string "name" + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "password_salt", :default => "", :null => false + t.string "reset_password_token" + t.string "remember_token" + t.datetime "remember_created_at" + t.datetime "created_at" + t.datetime "updated_at" + 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 diff --git a/db/seeds.rb b/db/seeds.rb index 664d8c74c..446698d82 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,17 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => cities.first) +require 'digest/md5' + +TEST_USERS = + [ + ['yaroslav@markin.net' , 'Yaroslav Markin'] , + ['timothy.tsvetkov@gmail.com' , 'Timothy Tsvetkov'] , + ['alexey.nayden@gmail.com' , 'Alexey Nayden'] + ] + +TEST_USERS.each do |tuser| + email = tuser[0] + next if User.find_by_email(email) + name = tuser[1] + pass = Digest::MD5.hexdigest(name)[0..6] + User.create! :name => name, :email => email, :password => pass, :password_confirmation => pass + puts "Created user #{name} (#{email}) and password #{pass}" +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 000000000..44032b484 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe User do + pending "add some examples to (or delete) #{__FILE__}" +end