Sha256: aa13954d17af468ab130d6dadd3de8ec55ca87317f52c3885ff8e0b3d8056737

Contents?: true

Size: 723 Bytes

Versions: 6

Compression:

Stored size: 723 Bytes

Contents

# Create multiple orgs
# Create an item in each
# Make sure you can only see one org's item in one org

describe Item do

  let!(:item1) { Item.create! }

  let!(:org2) { Organization.create! }
  let!(:item2) { org2.as_current { Item.create! } }
  let!(:item3) { org2.as_current { Item.create! } }

  specify 'default org should have one item' do
    expect(Item.all).to eq [ item1 ]
  end

  it 'does not return item2' do
    expect(Item.where(id: item2.id)).to eq []
  end

  specify 'org2 should have two items' do
    org2.as_current do
      expect(Item.all).to eq [ item2, item3]
    end
  end

  it 'does not return item1' do
    org2.as_current do
      expect(Item.where(id: item1.id)).to eq []
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_multitenant-0.7.0 spec/item_spec.rb
rails_multitenant-0.6.0 spec/item_spec.rb
rails_multitenant-0.5.2 spec/item_spec.rb
rails_multitenant-0.5.1 spec/item_spec.rb
rails_multitenant-0.5.0 spec/item_spec.rb
rails_multitenant-0.4.0 spec/item_spec.rb