Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename the reset to change since there is no longer a confirmation. K…

…ill confirmation code.
  • Loading branch information...
commit 50e40b7da698e5248a8ddf57cb4eec15d8657e89 1 parent 2c2657b
@cmeiklejohn cmeiklejohn authored
View
14 app/controllers/sessions_controller.rb
@@ -8,18 +8,8 @@ def create
flash_failure_after_create
render :template => 'sessions/new', :status => :unauthorized
else
- if !@user.email_reset
- sign_in(@user)
- redirect_back_or(url_after_create)
- else
- if @user.email_reset
- Mailer.email_reset(@user).deliver
- else
- ClearanceMailer.confirmation(@user).deliver
- end
- flash_notice_after_create
- redirect_to(new_session_url)
- end
+ sign_in(@user)
+ redirect_back_or(url_after_create)
end
end
View
6 app/models/user.rb
@@ -17,7 +17,6 @@ class User < ActiveRecord::Base
before_validation :regenerate_token, :if => :email_changed?, :on => :update
before_create :generate_api_key
- after_update :deliver_email_reset, :if => :email_reset
validates_uniqueness_of :handle, :allow_nil => true
validates_format_of :handle, :with => /\A[A-Za-z][A-Za-z_\-0-9]*\z/, :allow_nil => true
@@ -73,14 +72,9 @@ def to_yaml(*args)
end
def regenerate_token
- self.email_reset = true
generate_confirmation_token
end
- def deliver_email_reset
- Mailer.email_reset(self).deliver
- end
-
def generate_api_key
self.api_key = ActiveSupport::SecureRandom.hex(16)
end
View
19 features/email_change.feature
@@ -0,0 +1,19 @@
+Feature: Email change
+ In order to still use my account after I've changed my email address
+ A user
+ Should be able to change the email address associated with my account
+
+ Background:
+ Given I have signed in with "email@person.com"
+
+ Scenario: User changes their email to a new address
+ When I have changed my email address to "email@newperson.com"
+ And I sign out
+ When I sign in as "email@newperson.com"
+ Then I should not see "sign in"
+
+ Scenario: User tries to change their email to an invalid email address
+ When I am on my edit profile page
+ And I fill in "Email address" with "this is an invalid email address"
+ And I press "Update"
+ Then I should see an error message
View
39 features/email_reset.feature
@@ -1,39 +0,0 @@
-Feature: Email reset
- In order to still use my account after I've changed my email address
- A user
- Should be able to reset the email address associated with my account
-
- Background:
- Given I have signed in with "email@person.com"
-
- Scenario: User resets email address
- Given I am on my edit profile page
- When I fill in "Email address" with "email@newperson.com"
- And I press "Update"
- Then an email entitled "Email address confirmation" should be sent to "email@newperson.com"
- And I should see "You will receive an email within the next few minutes."
- And I should be signed out
-
- Scenario: User tries to reset email with an invalid email address
- When I am on my edit profile page
- And I fill in "Email address" with "this is an invalid email address"
- And I press "Update"
- Then I should see an error message
-
- Scenario: User confirms new email address
- When I have reset my email address to "email@newperson.com"
- And I follow the confirmation link sent to "email@newperson.com"
- Then I should see "Confirmed email and signed in"
- And I should be signed in
-
- Scenario: User tries to sign in in after resetting email address without confirmation
- When I have reset my email address to "email@newperson.com"
- And I sign in as "email@newperson.com"
- Then I should see "Confirmation email will be resent."
- And an email entitled "Email address confirmation" should be sent to "email@newperson.com"
-
- Scenario: User signs in after resetting and confirming email address
- When I have reset my email address to "email@newperson.com"
- And I follow the confirmation link sent to "email@newperson.com"
- And I sign in as "email@newperson.com"
- Then I should not see "sign in"
View
5 features/step_definitions/email_change_steps.rb
@@ -0,0 +1,5 @@
+Given /^I have changed my email address to "([^\"]*)"$/ do |email|
+ Given %{I am on my edit profile page}
+ When %{I fill in "Email address" with "#{email}"}
+ And %{I press "Update"}
+end
View
11 features/step_definitions/email_reset_steps.rb
@@ -1,11 +0,0 @@
-Then /^an email entitled "([^\"]*)" should be sent to "([^\"]*)"$/ do |subject, email|
- sent = ActionMailer::Base.deliveries.last
- assert_equal [email], sent.to
- assert_match subject, sent.subject
-end
-
-Given /^I have reset my email address to "([^\"]*)"$/ do |email|
- Given %{I am on my edit profile page}
- When %{I fill in "Email address" with "#{email}"}
- And %{I press "Update"}
-end
Please sign in to comment.
Something went wrong with that request. Please try again.