-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddSaltToUsers < ActiveRecord::Migration | ||
def self.up | ||
add_column :users, :salt, :string | ||
end | ||
|
||
def self.down | ||
remove_column :users, :salt | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,5 +109,47 @@ | |
it "should have an encrypted password attribute" do | ||
@user.should respond_to(:encrypted_password) | ||
end | ||
|
||
it "should set the encrypted password attribute" do | ||
@user.encrypted_password.should_not be_blank | ||
end | ||
|
||
it "should have a salt" do | ||
@user.should respond_to(:salt) | ||
end | ||
|
||
describe "has_password? method" do | ||
|
||
it "should exist" do | ||
@user.should respond_to(:has_password?) | ||
end | ||
|
||
it "should return true if the passwords match" do | ||
@user.has_password?(@attr[:password]).should be_true | ||
end | ||
|
||
it "should return false if the passwords don't match" do | ||
@user.has_password?("invalid").should be_false | ||
end | ||
end | ||
|
||
describe "authenticate method" do | ||
|
||
it "should exist" do | ||
User.should respond_to(:authenticate) | ||
end | ||
|
||
it "should return nil on email/password mismatch" do | ||
User.authenticate(@attr[:email], "wrongpass").should be_nil | ||
end | ||
|
||
it "should return nil for an email address with no user" do | ||
User.authenticate("[email protected]", @attr[:password]).should be_nil | ||
end | ||
|
||
it "should return the user on email/password match" do | ||
User.authenticate(@attr[:email], @attr[:password]).should == @user | ||
end | ||
end | ||
end | ||
end |