Sha256: 82e628e0a641798a6b320a16866b5f5ff95ffcbcaed2f683c11ef7281d102443

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require "spec_helper"

feature "Visitor updates password" do
  scenario "with valid password" do
    user = user_with_reset_password
    update_password user, "newpassword"

    user_should_be_signed_in
  end

  scenario "signs in with new password" do
    user = user_with_reset_password
    update_password user, "newpassword"
    sign_out
    sign_in_with user.email, "newpassword"

    user_should_be_signed_in
  end

  scenario "tries with a blank password" do
    user = user_with_reset_password
    visit_password_reset_page_for user
    change_password_to ""

    expect(page).to have_content I18n.t("flashes.failure_after_update")
    user_should_be_signed_out
  end

  private

  def update_password(user, password)
    visit_password_reset_page_for user
    change_password_to password
  end

  def visit_password_reset_page_for(user)
    visit edit_user_password_path(
      user_id: user,
      token: user.confirmation_token
    )
  end

  def change_password_to(password)
    fill_in "password_reset_password", with: password
    click_button I18n.t("helpers.submit.password_reset.submit")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clearance-1.5.0 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
clearance-1.4.3 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
clearance-1.4.2 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
clearance-1.4.1 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb