mirror of
https://github.com/wahyd4/Libr.git
synced 2026-08-20 18:26:21 +10:00
Start integration with Devise
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
source 'https://rubygems.org'
|
||||
#source 'https://rubygems.org'
|
||||
|
||||
#source 'http://ruby.taobao.org'
|
||||
source 'http://ruby.taobao.org'
|
||||
|
||||
ruby '2.0.0'
|
||||
|
||||
@@ -15,6 +15,7 @@ gem 'thin'
|
||||
gem 'will_paginate'
|
||||
gem 'nokogiri'
|
||||
gem 'unicorn'
|
||||
gem 'devise'
|
||||
|
||||
|
||||
gem 'activesupport','4.0.0'
|
||||
|
||||
+12
-1
@@ -1,5 +1,5 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: http://ruby.taobao.org/
|
||||
specs:
|
||||
actionmailer (4.0.0)
|
||||
actionpack (= 4.0.0)
|
||||
@@ -29,6 +29,7 @@ GEM
|
||||
arel (4.0.1)
|
||||
atomic (1.1.14)
|
||||
awesome_print (1.2.0)
|
||||
bcrypt-ruby (3.1.2)
|
||||
builder (3.1.4)
|
||||
capybara (2.2.1)
|
||||
mime-types (>= 1.16)
|
||||
@@ -55,6 +56,12 @@ GEM
|
||||
daemons (1.1.9)
|
||||
dalli (2.6.4)
|
||||
database_cleaner (1.2.0)
|
||||
devise (3.2.2)
|
||||
bcrypt-ruby (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 3.2.6, < 5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (~> 1.2.3)
|
||||
diff-lcs (1.2.5)
|
||||
docile (1.1.2)
|
||||
erubis (2.7.0)
|
||||
@@ -89,6 +96,7 @@ GEM
|
||||
multi_test (0.0.3)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
orm_adapter (0.5.0)
|
||||
pg (0.17.1)
|
||||
polyglot (0.3.3)
|
||||
protected_attributes (1.0.3)
|
||||
@@ -189,6 +197,8 @@ GEM
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
warden (1.2.3)
|
||||
rack (>= 1.0)
|
||||
websocket (1.0.7)
|
||||
will_paginate (3.0.5)
|
||||
xpath (2.0.0)
|
||||
@@ -203,6 +213,7 @@ DEPENDENCIES
|
||||
cucumber-rails
|
||||
dalli
|
||||
database_cleaner
|
||||
devise
|
||||
flay
|
||||
jquery-rails
|
||||
kgio
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
require 'utils'
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
#devise :database_authenticatable, :registerable,
|
||||
# :recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
devise :database_authenticatable, :recoverable, :stretches => 20
|
||||
|
||||
include Utils
|
||||
attr_accessible :email, :name, :avatar, :id, :location, :preferred_name
|
||||
@@ -16,6 +22,7 @@ class User < ActiveRecord::Base
|
||||
|
||||
def self.create_user(name, avatar)
|
||||
User.create name: name, avatar: avatar
|
||||
|
||||
end
|
||||
|
||||
def borrow(instance)
|
||||
|
||||
@@ -70,5 +70,7 @@ module Libr
|
||||
|
||||
config.assets.precompile += [ Proc.new {|path| File.basename(path) =~ /^[^_].*\.\w+$/} ]
|
||||
|
||||
config.i18n.enforce_available_locales = true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,3 +5,5 @@
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
Libr::Application.config.secret_token = 'ceb13c7522932aa2b100468c03f32b5eb3360df00a8d4abf9f4d770dbbcd2094ee403c5865834c9b963ecf7ad2aafdd0aad7fc0406cba260cc93f830bd322cbe'
|
||||
|
||||
#Libr::Application.config.secret_key_base = 'wef323b4jh3brjhsdf98usefbhwefh'
|
||||
@@ -1,5 +1,6 @@
|
||||
Libr::Application.routes.draw do
|
||||
|
||||
devise_for :users
|
||||
root to: 'home#index'
|
||||
get 'books/new' => 'book#new'
|
||||
get 'books/:id' => 'book#view'
|
||||
|
||||
+14
-2
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20130417050322) do
|
||||
ActiveRecord::Schema.define(version: 20140117135051) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -71,13 +71,25 @@ ActiveRecord::Schema.define(version: 20130417050322) do
|
||||
end
|
||||
|
||||
create_table "users", force: true do |t|
|
||||
t.string "email"
|
||||
t.string "email", default: "", null: false
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "avatar"
|
||||
t.string "location"
|
||||
t.string "preferred_name"
|
||||
t.string "encrypted_password", 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, null: false
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
end
|
||||
|
||||
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ describe :Book do
|
||||
|
||||
it 'ensure total_borrowers will count the user who returned the book' do
|
||||
instance_1 = BookInstance.create book_id: @book.id, user_id: @user.id
|
||||
user_1 = User.create name: 'Tom'
|
||||
user_1 = User.create name: 'Tom', email: 'a@a.com'
|
||||
@user.borrow @instance
|
||||
user_1.borrow instance_1
|
||||
@user.should_not == nil
|
||||
@@ -57,7 +57,6 @@ describe :Book do
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe :total_available_instances do
|
||||
it 'ensure total available instance should be 1 after borrowed' do
|
||||
instance_1 = BookInstance.create book_id: @book.id, user_id: @user.id
|
||||
@@ -76,7 +75,7 @@ describe :Book do
|
||||
end
|
||||
|
||||
it 'ensure total available instance will not include the private book' do
|
||||
user_1 = User.create name: 'Nick'
|
||||
user_1 = User.create name: 'Nick', email: 'a@a.com'
|
||||
book_1 = Book.create name: 'Big data', image: 'none', isbn: '1234567890123'
|
||||
instance = BookInstance.create book_id: book_1.id, user_id: user_1.id
|
||||
instance_2 = BookInstance.create book_id: book_1.id, user_id: user_1.id
|
||||
|
||||
@@ -15,7 +15,7 @@ describe :User do
|
||||
@user.borrowed_and_not_returned_books.count.should == 1
|
||||
end
|
||||
it 'ensure when there are two books,users can borrow these two books.' do
|
||||
user_1 = User.create name: 'Nick'
|
||||
user_1 = User.create name: 'Nick',email: 'a@a.com'
|
||||
book_1 = Book.create name: 'Big data',image:'none', isbn:'1234567890123'
|
||||
instance = BookInstance.create book_id: book_1.id, user_id: user_1.id
|
||||
instance_2 = BookInstance.create book_id: book_1.id, user_id: user_1.id
|
||||
|
||||
Reference in New Issue
Block a user