Sha256: 66bde0d0ef20680e65d613b9dc946a3056660c5876e382351ffd6f6c6fa7ab42

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 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 ''

    page.should 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

3 entries across 3 versions & 1 rubygems

Version Path
clearance-1.4.0 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
clearance-1.3.0 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb
clearance-1.2.1 lib/generators/clearance/specs/templates/features/clearance/visitor_updates_password_spec.rb