Sha256: b44f8812c54fad2e7f4c49b90debf8651fe263b4053bbfb7724d7669feb4cd40

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

require "test_helper"

class PasswordsControllerTest < ActionDispatch::IntegrationTest
  setup do
    @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon))
  end

  test "should update password" do
    patch password_url, params: { current_password: "Secret1*3*5*", password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }, headers: { "Authorization" => "Bearer #{@token}" }
    assert_response :success
  end

  test "should not update password with wrong current password" do
    patch password_url, params: { current_password: "SecretWrong1*3", password: "Secret6*4*2*", password_confirmation: "Secret6*4*2*" }, headers: { "Authorization" => "Bearer #{@token}" }

    assert_response :bad_request
    assert_equal "The current password you entered is incorrect", response.parsed_body["error"]
  end

  def sign_in_as(<%= singular_table_name %>)
    post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }, headers: { "User-Agent" => "App iOS" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
authentication-zero-2.8.4 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.8.3 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.8.2 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.8.1 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.8.0 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.7.0 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.6.0 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.5.1 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt
authentication-zero-2.5.0 lib/generators/authentication/templates/test_unit/controllers/api/passwords_controller_test.rb.tt