This commit is contained in:
r888888888
2013-05-21 17:52:03 -07:00
parent d1f2f1c09a
commit eab2eb1d82
6 changed files with 112 additions and 2 deletions

View File

@@ -0,0 +1,42 @@
require "test_helper"
module Maintenance
module User
class EmailChangesControllerTest < ActionController::TestCase
context "in all cases" do
setup do
@user = FactoryGirl.create(:user, :email => "bob@ogres.net")
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
end
context "#new" do
should "render" do
get :new, {}, {:user_id => @user.id}
assert_response :success
end
end
context "#create" do
context "with the correct password" do
should "work" do
post :create, {:email_change => {:password => "password", :email => "abc@ogres.net"}}, {:user_id => @user.id}
assert_redirected_to(edit_user_path(@user))
@user.reload
assert_equal("abc@ogres.net", @user.email)
end
end
context "with the incorrect password" do
should "not work" do
post :create, {:email_change => {:password => "passwordx", :email => "abc@ogres.net"}}, {:user_id => @user.id}
assert_response :success
@user.reload
assert_equal("bob@ogres.net", @user.email)
end
end
end
end
end
end
end