Files
danbooru/test/functional/maintenance/user/email_changes_controller_test.rb
evazion 258f4a8b95 users: move emails to separate table.
* Move emails from users table to email_addresses table.
* Validate that addresses are formatted correctly and are unique across
  users. Existing invalid emails are grandfathered in.
* Add is_verified flag (the address has been confirmed by the user).
* Add is_deliverable flag (an undeliverable address is an address that bounces).
* Normalize addresses to prevent registering multiple accounts with the
  same email address (using tricks like Gmail's plus addressing).
2020-03-12 21:18:53 -05:00

38 lines
1.3 KiB
Ruby

require "test_helper"
module Maintenance
module User
class EmailChangesControllerTest < ActionDispatch::IntegrationTest
context "in all cases" do
setup do
@user = create(:user, email_address: build(:email_address, { address: "bob@ogres.net" }))
end
context "#new" do
should "render" do
get_auth new_maintenance_user_email_change_path, @user
assert_response :success
end
end
context "#create" do
context "with the correct password" do
should "work" do
post_auth maintenance_user_email_change_path, @user, params: {:email_change => {:password => "password", :email => "abc@ogres.net"}}
assert_redirected_to(edit_user_path(@user))
assert_equal("abc@ogres.net", @user.reload.email_address.address)
end
end
context "with the incorrect password" do
should "not work" do
post_auth maintenance_user_email_change_path, @user, params: {:email_change => {:password => "passwordx", :email => "abc@ogres.net"}}
assert_equal("bob@ogres.net", @user.reload.email_address.address)
end
end
end
end
end
end
end