Sha256: 831c71ae29ee941cd352994ce37f9edb47fc8e67b886886f84cd052ef7b45153

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

RSpec.describe Macros::Auth::SignOutAllScopes do
  include Warden::Test::Mock

  subject(:step) { described_class.new(params) }
  let(:params) { {} }

  let(:user) { mock_model('User') }
  let(:foo_user) { mock_model('FooUser') }
  let(:admin) { mock_model('Admin') }

  let(:ctx) { { warden: warden } }

  before do
    devise = class_double('Devise').as_stubbed_const
    allow(devise).to receive_message_chain(:mappings, :keys).and_return([:user, :foo_user, :admin])

    warden.set_user(foo_user, scope: :foo_user)
    warden.set_user(admin, scope: :admin)
  end

  it 'expects to sign out all users' do
    step.call(ctx)

    expect(warden.authenticated?(:user)).to be false
    expect(warden.authenticated?(:foo_user)).to be false
    expect(warden.authenticated?(:admin)).to be false
  end

  context 'except param passed' do
    let(:params) { { except: :admin } }

    it 'expects to sign out all users except admin' do
      step.call(ctx)

      expect(warden.authenticated?(:user)).to be false
      expect(warden.authenticated?(:foo_user)).to be false
      expect(warden.authenticated?(:admin)).to be true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 spec/lib/auth/sign_out_all_scopes_spec.rb