Sha256: 9d1f0c315a1b1f2f21affea02c8d78e7cde5e20fe3bd93e137c826cad7e3dba8

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

require "test_helper"

class Admin::PasswordResetsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @admin_user = admin_users(:lazaro_nixon)
    @sid = @admin_user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
    @sid_exp = @admin_user.signed_id(purpose: :password_reset, expires_in: 0.minutes)
  end

  test "should get new" do
    get new_admin_password_reset_url
    assert_response :success
  end

  test "should get edit" do
    get edit_admin_password_reset_url(token: @sid)
    assert_response :success
  end

  test "should send a password reset email" do
    assert_enqueued_email_with Admin::UserMailer, :password_reset_provision, args: { admin_user: @admin_user } do
      post admin_password_reset_url, params: { email: @admin_user.email }
    end

    assert_redirected_to admin_sign_in_url
  end

  test "should not send a password reset email to a nonexistent email" do
    assert_no_enqueued_emails do
      post admin_password_reset_url, params: { email: "invalid_email@hey.com" }
    end

    assert_redirected_to new_admin_password_reset_url
    assert_equal "Sorry, we didn't recognize that email address", flash[:alert]
  end

  test "should update password" do
    patch admin_password_reset_url, params: { token: @sid, password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }
    assert_redirected_to admin_sign_in_url
  end

  test "should not update password with expired token" do
    patch admin_password_reset_url, params: { token: @sid_exp, password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }

    assert_redirected_to new_admin_password_reset_url
    assert_equal "That password reset link is invalid", flash[:alert]
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
administration-zero-0.0.10 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.9 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.8 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.7 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.6 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.5 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.4 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.3 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.2 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb
administration-zero-0.0.1 lib/generators/admin/install/templates/test_unit/controllers/admin/password_resets_controller_test.rb