Sha256: 601655bfd43533499a8c89d4e1a0fc69dd822cc786286f750bb48c872df1e9ad
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require 'spec_helper' require 'apartment/elevators/host_hash' describe Apartment::Elevators::HostHash do subject(:elevator){ Apartment::Elevators::HostHash.new(Proc.new{}, 'example.com' => 'example_tenant') } describe "#parse_tenant_name" do it "parses the host for a domain name" do request = ActionDispatch::Request.new('HTTP_HOST' => 'example.com') elevator.parse_tenant_name(request).should == 'example_tenant' end it "raises TenantNotFound exception if there is no host" do request = ActionDispatch::Request.new('HTTP_HOST' => '') expect { elevator.parse_tenant_name(request) }.to raise_error(Apartment::TenantNotFound) end it "raises TenantNotFound exception if there is no database associated to current host" do request = ActionDispatch::Request.new('HTTP_HOST' => 'example2.com') expect { elevator.parse_tenant_name(request) }.to raise_error(Apartment::TenantNotFound) end end describe "#call" do it "switches to the proper tenant" do Apartment::Tenant.should_receive(:switch!).with('example_tenant') elevator.call('HTTP_HOST' => 'example.com') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
apartment-1.0.2 | spec/unit/elevators/host_hash_spec.rb |
apartment-1.0.1 | spec/unit/elevators/host_hash_spec.rb |
apartment-1.0.0 | spec/unit/elevators/host_hash_spec.rb |