Sha256: 7ef6818995e6eb34d8a30c966f06ce22e22ae1d257cae4f342526c88bf2ed0d7

Contents?: true

Size: 1.1 KB

Versions: 23

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

# generado con pg_rails

require 'rails_helper'

RSpec.describe User do
  let(:user) { create(:user) }

  it 'se persiste' do
    expect(user).to be_persisted
  end

  it do
    expect(user.default_account).to be_present
  end

  describe 'search ransacker' do
    it 'searchs' do
      results = described_class.ransack(search_cont: user.nombre).result.to_a
      expect(results).to eq [user]
    end
  end

  describe 'default scope' do
    before do
      ActsAsTenant.current_tenant = nil
      ActsAsTenant.test_tenant = nil
      Current.reset
    end

    it 'scopes according to tenant' do
      account = create(:account)
      other_account = create(:account)
      usr1 = usr2 = usr3 = usr4 = nil
      ActsAsTenant.with_tenant(other_account) do
        usr3 = create(:user)
        usr4 = create(:user)
      end
      ActsAsTenant.with_tenant(account) do
        usr1 = create(:user)
        usr2 = create(:user)
        expect(described_class.all).to contain_exactly(usr1, usr2)
      end
      expect(described_class.all).to contain_exactly(usr1, usr2, usr3, usr4)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pg_rails-7.6.20 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.19 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.18 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.17 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.16 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.15 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.14 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.13 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.12 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.11 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.10 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.9 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.8 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.7 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.6 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.5 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.4 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.3 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.2 pg_engine/spec/models/user_spec.rb
pg_rails-7.6.1 pg_engine/spec/models/user_spec.rb