* VRFS-72
This commit is contained in:
parent
770134c883
commit
33c2bbd68e
|
|
@ -2,11 +2,7 @@ module JamRuby
|
|||
class User < ActiveRecord::Base
|
||||
include Tire::Model::Search
|
||||
|
||||
<<<<<<< HEAD
|
||||
attr_accessible :name, :email, :password, :password_confirmation, :city, :state, :country
|
||||
=======
|
||||
attr_accessible :first_name, :last_name, :name, :email, :password, :password_confirmation
|
||||
>>>>>>> b2880dc65a3e361fbef0727657fa368336d712ba
|
||||
attr_accessible :first_name, :last_name, :name, :email, :password, :password_confirmation, :city, :state, :country
|
||||
attr_accessor :updating_password
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
|
|
|||
|
|
@ -50,15 +50,20 @@ module JamRuby
|
|||
return user
|
||||
end
|
||||
|
||||
# throws RecordNotFound if signup token is invalid
|
||||
# throws RecordNotFound if signup token is invalid; i.e., if it's nil, empty string, or not belonging to a user
|
||||
def signup_confirm(signup_token)
|
||||
UserManager.active_record_transaction do |user_manager|
|
||||
# throws ActiveRecord::RecordNotFound if invalid
|
||||
user = User.find_by_signup_token!(signup_token)
|
||||
user.signup_token = nil
|
||||
user.email_confirmed = true
|
||||
user.save
|
||||
return user
|
||||
if signup_token.nil? || signup_token.empty?
|
||||
# there are plenty of confirmed users with nil signup_tokens, so we can't look on it
|
||||
raise ActiveRecord::RecordNotFound
|
||||
else
|
||||
UserManager.active_record_transaction do |user_manager|
|
||||
# throws ActiveRecord::RecordNotFound if invalid
|
||||
user = User.find_by_signup_token!(signup_token)
|
||||
user.signup_token = nil
|
||||
user.email_confirmed = true
|
||||
user.save
|
||||
return user
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe Search do
|
|||
|
||||
def create_peachy_data
|
||||
@user = FactoryGirl.create(:user, first_name: "Peach", last_name: "Pit", name: "peachy", email: "user@example.com", musician: true)
|
||||
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Pit", name: "peachy", email: "fan@example.com", musician: false)
|
||||
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Pit", name: "peachy2", email: "fan@example.com", musician: false)
|
||||
@band = FactoryGirl.create(:band, name: "Peach pit", website: "www.bands.com", biography: "zomg we rock")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ describe User do
|
|||
end
|
||||
|
||||
it "should tokenize correctly" do
|
||||
@user2 = FactoryGirl.create(:user, first_name: "peaches", last_name: "test", name: "peachy", email: "peach@example.com",
|
||||
@user2 = FactoryGirl.create(:user, first_name: "peaches", last_name: "test", name: "peachy2", email: "peach@example.com",
|
||||
password: "foobar", password_confirmation: "foobar", musician: true, email_confirmed: true)
|
||||
User.search_index.refresh
|
||||
ws = User.search("pea")
|
||||
|
|
@ -71,7 +71,7 @@ describe User do
|
|||
|
||||
|
||||
it "users who have signed up, but not confirmed should not show up in search index" do
|
||||
@user3 = FactoryGirl.create(:user, name: "unconfirmed", email: "unconfirmed@example.com",
|
||||
@user3 = FactoryGirl.create(:user, first_name: "unconfirmed", last_name: "unconfirmed", name: "unconfirmed", email: "unconfirmed@example.com",
|
||||
password: "foobar", password_confirmation: "foobar", musician: true, email_confirmed: false)
|
||||
User.search_index.refresh
|
||||
ws = User.search("unconfirmed")
|
||||
|
|
|
|||
Loading…
Reference in New Issue