emails: move edit email flow to emails controller.

This commit is contained in:
evazion
2020-03-14 17:42:47 -05:00
parent 3dbdce3ae3
commit 167fe51a8a
9 changed files with 89 additions and 98 deletions

View File

@@ -0,0 +1,36 @@
require "test_helper"
class EmailsControllerTest < ActionDispatch::IntegrationTest
context "in all cases" do
setup do
@user = create(:user, email_address: build(:email_address, { address: "bob@ogres.net" }))
end
context "#edit" do
should "render" do
get_auth edit_user_email_path(@user), @user
assert_response :success
end
end
context "#create" do
context "with the correct password" do
should "work" do
put_auth user_email_path(@user), @user, params: { user: { password: "password", email: "abc@ogres.net" }}
assert_redirected_to(settings_path)
assert_equal("abc@ogres.net", @user.reload.email_address.address)
end
end
context "with the incorrect password" do
should "not work" do
put_auth user_email_path(@user), @user, params: { user: { password: "passwordx", email: "abc@ogres.net" }}
assert_response :success
assert_equal("bob@ogres.net", @user.reload.email_address.address)
end
end
end
end
end