aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb18
-rw-r--r--spec/controllers/user_controller_spec.rb6
-rw-r--r--spec/fixtures/users.yml15
-rw-r--r--spec/models/user_spec.rb12
4 files changed, 39 insertions, 12 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index aee701031..5dbd4b98e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -349,21 +349,23 @@ class User < ActiveRecord::Base
self.save!
end
+ def should_be_emailed?
+ return (self.email_confirmed && self.email_bounced_at.nil?)
+ end
+
+ ## Private instance methods
private
- def User.encrypted_password(password, salt)
- string_to_hash = password + salt # XXX need to add a secret here too?
- Digest::SHA1.hexdigest(string_to_hash)
- end
-
def create_new_salt
self.salt = self.object_id.to_s + rand.to_s
end
- def should_be_emailed?
- return (self.email_confirmed && self.email_bounced_at.nil?)
+ ## Class methods
+ def User.encrypted_password(password, salt)
+ string_to_hash = password + salt # XXX need to add a secret here too?
+ Digest::SHA1.hexdigest(string_to_hash)
end
-
+
def User.record_bounce_for_email(email, message)
user = User.find_user_by_email(email)
return false if user.nil?
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 438fb8c0c..a12d79e82 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -104,7 +104,7 @@ describe UserController, "when signing in" do
get :signin, :r => "/list"
response.should render_template('sign')
post_redirect = get_last_postredirect
- post :signin, { :user_signin => { :email => 'silly@localhost', :password => 'jonespassword' },
+ post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' },
:token => post_redirect.token
}
response.should render_template('confirm')
@@ -116,7 +116,7 @@ describe UserController, "when signing in" do
get :signin, :r => "/list"
post_redirect = get_last_postredirect
- post :signin, { :user_signin => { :email => 'silly@localhost', :password => 'jonespassword' },
+ post :signin, { :user_signin => { :email => 'unconfirmed@localhost', :password => 'jonespassword' },
:token => post_redirect.token
}
response.should send_email
@@ -136,7 +136,7 @@ describe UserController, "when signing in" do
# check confirmation URL works
session[:user_id].should be_nil
get :confirm, :email_token => post_redirect.email_token
- session[:user_id].should == users(:silly_name_user).id
+ session[:user_id].should == users(:unconfirmed_user).id
response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1)
end
diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml
index 2485c95a0..e80183c9f 100644
--- a/spec/fixtures/users.yml
+++ b/spec/fixtures/users.yml
@@ -20,7 +20,7 @@ silly_name_user:
hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 # jonespassword
updated_at: 2007-11-01 10:39:15.491593
created_at: 2007-11-01 10:39:15.491593
- email_confirmed: false
+ email_confirmed: true
admin_level: 'none'
ban_text: ''
about_me: ''
@@ -37,3 +37,16 @@ admin_user:
admin_level: 'super'
ban_text: ''
about_me: ''
+unconfirmed_user:
+ id: "4"
+ name: "Unconfirmed"
+ url_name: unconfirmed
+ email: unconfirmed@localhost
+ salt: "-6116981980.392287733335677"
+ hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 # jonespassword
+ updated_at: 2007-11-01 10:39:15.491593
+ created_at: 2007-11-01 10:39:15.491593
+ email_confirmed: false
+ admin_level: 'none'
+ ban_text: ''
+ about_me: ''
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index fc56d3365..751a61060 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -282,6 +282,18 @@ describe User, "when setting a profile photo" do
# end
end
+describe User, "when unconfirmed" do
+ fixtures :users
+
+ before do
+ @user = users(:unconfirmed_user)
+ end
+
+ it "should not be emailed" do
+ @user.should_be_emailed?.should be_false
+ end
+end
+
describe User, "when emails have bounced" do
fixtures :users