Browse files

Organize user tests-- put email and perishable token tests together

  • Loading branch information...
1 parent 5d529dc commit 61dd80bfecd882650ea540bb54edc7ba6f665545 @carols10cents carols10cents committed Nov 20, 2012
Showing with 17 additions and 26 deletions.
  1. +17 −26 test/models/user_test.rb
View
43 test/models/user_test.rb
@@ -100,22 +100,7 @@ def stub_superfeedr_request_for_user(user)
end
end
- describe "email" do
- it "changes email" do
- u = Fabricate(:user)
-
- stub_superfeedr_request_for_user u
-
- u.edit_user_profile(:email => 'team@jackhq.com')
- u.save
- refute u.email_confirmed
- end
-
- it "does not change email" do
- u = Fabricate(:user)
- assert_nil u.email_confirmed
- end
-
+ describe "perishable token" do
it "sets the token" do
u = Fabricate(:user)
assert_nil u.perishable_token
@@ -134,16 +119,7 @@ def stub_superfeedr_request_for_user(user)
end
end
- describe "reset password" do
- it "sets the token" do
- u = Fabricate(:user)
- assert_nil u.perishable_token
- assert_nil u.perishable_token_set
- u.create_token
- refute_nil u.perishable_token
- refute_nil u.perishable_token_set
- end
-
+ describe "#reset_password" do
it "changes the password" do
u = Fabricate(:user)
u.password = "test_password"
@@ -155,6 +131,21 @@ def stub_superfeedr_request_for_user(user)
end
describe "email confirmation" do
+ it "has an unconfirmed email initially" do
+ u = Fabricate(:user)
+ assert_nil u.email_confirmed
+ end
+
+ it "changes email and requires reconfirmation" do
+ u = Fabricate(:user)
+
+ stub_superfeedr_request_for_user u
+
+ u.edit_user_profile(:email => 'team@jackhq.com')
+ u.save
+ refute u.email_confirmed
+ end
+
it "allows unconfirmed emails to be entered more than once" do
u = Fabricate(:user)

0 comments on commit 61dd80b

Please sign in to comment.