more work

This commit is contained in:
Mike Slemmer 2012-12-13 09:15:47 -08:00
parent c068f2ca16
commit 7ff103a430
3 changed files with 23 additions and 0 deletions

View File

@ -19,4 +19,7 @@ module ValidationMessages
INSTRUMENT_LIMIT_EXCEEDED = "No more than 5 instruments are allowed."
INSTRUMENT_MINIMUM_NOT_MET = "At least 1 instrument is required."
# user
OLD_PASSWORD_DOESNT_MATCH = "Your old password is incorrect."
end

View File

@ -164,6 +164,15 @@ module JamRuby
return id
end
def set_password(old_password, new_password)
raise JamRuby::JamArgumentError, ValidationMessages::OLD_PASSWORD_DOESNT_MATCH unless authenticate old_password
# FIXME: Should verify that the new password meets certain quality criteria
# FIXME: Need to run the new password through the validations here. Not sure if this does that.
password = new_password
save
end
# helper method for creating / updating a User
def self.save(id, updater_id, first_name, last_name, email, password, password_confirmation, musician, gender,
birth_date, internet_service_provider, city, state, country, instruments, photo_url)

View File

@ -125,6 +125,17 @@ describe User do
it { should be_invalid }
end
describe "setting a new password should work" do
end
describe "setting a new password should fail if old one doesnt match" do
end
describe "setting a new password should fail if new one doesnt validate" do
end
describe "return value of authenticate method" do
before { @user.save }
let(:found_user) { User.find_by_email(@user.email) }