mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-04-26 05:55:17 +08:00
26 lines
856 B
Ruby
26 lines
856 B
Ruby
require 'test_helper'
|
|
|
|
class Settings::PasswordsControllerTest < ActionController::TestCase
|
|
def setup
|
|
login_as create(:user, password: '123456')
|
|
end
|
|
|
|
test "should get settings password page" do
|
|
get :show
|
|
assert_response :success, @response.body
|
|
end
|
|
|
|
test "should update passowrd" do
|
|
patch :update, current_password: '123456', user: { password: '654321', password_confirmation: '654321' }
|
|
assert current_user.reload.authenticate '654321'
|
|
end
|
|
|
|
test "should not update password without current_password" do
|
|
patch :update, user: { password: '654321', password_confirmation: '654321' }
|
|
assert !current_user.reload.authenticate('654321')
|
|
|
|
patch :update, current_password: 'wrongpassword', user: { password: '654321', password_confirmation: '654321' }
|
|
assert !current_user.reload.authenticate('654321')
|
|
end
|
|
end
|