Sha256: 472834c73233e33e0368b76a7ed00809e240d90f6d7062f53907a72ca6fa9c56

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

RSpec.shared_examples_for "a provider" do
  let(:user) { User.create! }
  let(:other_user) { User.create! }

  it "can log a user in" do
    provider.login(user)

    expect(provider.current_user).to eq user
  end

  it "can log a user out" do
    provider.login(user)

    provider.logout

    expect(provider.current_user).to eq nil
  end

  it "responds to login_exclusive" do
    expect(provider).to respond_to(:login_exclusive)
  end

  it "responds to login_exclusive" do
    expect(provider).to respond_to(:login_inclusive)
  end

  it "knows if there are any users logged in" do
    provider.login(user)

    expect(provider.current_users_without_scope).to eq [user]
  end

  it "can lock the original user, allowing us to change current_user" do
    provider.login(user)
    provider.remember_current_user(true)
    provider.login_exclusive(other_user, scope: "user")

    expect(provider.original_user).to eq user
    expect(provider.current_user).to eq other_user
  end

  it "can forget the original_user" do
    provider.login(user)
    provider.remember_current_user(true)

    expect(provider.original_user).to eq user
    provider.remember_current_user(false)

    expect(provider.original_user).to eq nil
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
switch_user-1.4.0 spec/support/provider.rb
switch_user-1.3.1 spec/support/provider.rb
switch_user-1.3.0 spec/support/provider.rb
switch_user-1.2.1 spec/support/provider.rb
switch_user-1.2.0 spec/support/provider.rb
switch_user-1.1.0 spec/support/provider.rb
switch_user-1.0.2 spec/support/provider.rb
switch_user-1.0.1 spec/support/provider.rb
switch_user-1.0.0 spec/support/provider.rb