Sha256: 324f5fd44c30688c41ebdb7d3136d86ea26fc7dbc63f076a3b072b36e29502a1

Contents?: true

Size: 849 Bytes

Versions: 12

Compression:

Stored size: 849 Bytes

Contents

require 'spec_helper'

describe Apartment::Elevators::Domain do

  describe "#parse_database_name" do
    it "parses the host for a domain name" do
      request = ActionDispatch::Request.new('HTTP_HOST' => 'example.com')
      elevator = Apartment::Elevators::Domain.new(nil)
      elevator.parse_database_name(request).should == 'example'
    end

    it "ignores a www prefix and domain suffix" do
      request = ActionDispatch::Request.new('HTTP_HOST' => 'www.example.bc.ca')
      elevator = Apartment::Elevators::Domain.new(nil)
      elevator.parse_database_name(request).should == 'example'
    end

    it "returns nil if there is no host" do
      request = ActionDispatch::Request.new('HTTP_HOST' => '')
      elevator = Apartment::Elevators::Domain.new(nil)
      elevator.parse_database_name(request).should be_nil
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
apartment-0.22.1 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.22.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.21.1 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.21.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.20.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.19.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.18.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.17.3 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.17.2 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.17.1 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.17.0 spec/unit/middleware/domain_elevator_spec.rb
apartment-0.16.0 spec/unit/middleware/domain_elevator_spec.rb