Sha256: 01f09699bb47e66c87fbbd5a9456121f246a94fbec0ddaef11075c6867d7c51c

Contents?: true

Size: 1.5 KB

Versions: 29

Compression:

Stored size: 1.5 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    module Users
      class PasswordsIntegrationTest < Workarea::IntegrationTest
        setup :set_user

        def set_user
          @user = create_user(email: 'passwords@workarea.com', password: 'Workar3a!')
        end

        def test_creates_a_password_reset
          post storefront.forgot_password_path,
            params: { email: 'passwords@workarea.com' }

          assert_equal(1, User::PasswordReset.count)
          result = User::PasswordReset.first
          assert_equal(@user.id, result.user_id)
        end

        def test_sends_an_email
          post storefront.forgot_password_path,
            params: { email: 'passwords@workarea.com' }

          delivery = ActionMailer::Base.deliveries.last
          assert_includes(delivery.subject, 'Password')
          assert_includes(delivery.to, 'passwords@workarea.com')
          assert_includes(delivery.html_part.body, User::PasswordReset.first.token)
        end

        def test_handles_a_missing_password_reset
          get storefront.reset_password_path(token: 'foo')
          assert_redirected_to(storefront.forgot_password_path)
        end

        def test_handles_an_unsuccessful_reset
          reset = User::PasswordReset.setup!('passwords@workarea.com')
          patch storefront.reset_password_path(token: reset.token),
            params: { password: '' }

          assert(flash[:error].present?)
          assert(response.redirect?)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
workarea-storefront-3.5.8 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.30 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.7 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.29 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.6 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.28 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.5 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.27 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.4 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.26 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.3 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.25 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.2 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.24 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.1 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.23 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.22 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.0 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.4.21 test/integration/workarea/storefront/users/passwords_integration_test.rb
workarea-storefront-3.5.0.beta.1 test/integration/workarea/storefront/users/passwords_integration_test.rb