Sha256: 3a5d4fea06606da327f052447b471cb7b831029569bb43f0273c84f5cd8da49a
Contents?: true
Size: 1.14 KB
Versions: 6
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 DatabaseNotFound exception if there is no host" do request = ActionDispatch::Request.new('HTTP_HOST' => '') expect { elevator.parse_tenant_name(request) }.to raise_error(Apartment::DatabaseNotFound) end it "raises DatabaseNotFound 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::DatabaseNotFound) end end describe "#call" do it "switches to the proper tenant" do Apartment::Database.should_receive(:switch).with('example_tenant') elevator.call('HTTP_HOST' => 'example.com') end end end
Version data entries
6 entries across 6 versions & 1 rubygems