Sha256: 339d8666ba2ef18959bba0b209b90427f4baf5cabce42c0216f7e83fe3a15bf7

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

require "spec_helper"

#Setup test specific ApplicationController
class Account; end # this is so the spec will work in isolation

class ApplicationController < ActionController::Base
  include Rails.application.routes.url_helpers
  set_current_tenant_by_subdomain
end

# Start testing
describe ApplicationController, :type => :controller do
  controller do
    def index
      render :text => "custom called"
    end
  end

  it 'Finds the correct tenant with a subdomain.example.com' do
    @request.host = "account1.example.com"
    expect(Account).to receive(:where).with({subdomain: 'account1'}) {['account1']}
    get :index
    expect(ActsAsTenant.current_tenant).to eq 'account1'
  end

  it 'Finds the correct tenant with a www.subdomain.example.com' do
    @request.host = "www.account1.example.com"
    expect(Account).to receive(:where).with({subdomain: 'account1'}) {['account1']}
    get :index
    expect(ActsAsTenant.current_tenant).to eq 'account1'
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
acts_as_tenant-0.4.1 spec/acts_as_tenant/tenant_by_subdomain_spec.rb
acts_as_tenant-0.4.0 spec/acts_as_tenant/tenant_by_subdomain_spec.rb
acts_as_tenant-0.3.9 spec/acts_as_tenant/tenant_by_subdomain_spec.rb
acts_as_tenant-0.3.8 spec/acts_as_tenant/tenant_by_subdomain_spec.rb
acts_as_tenant-0.3.7 spec/acts_as_tenant/tenant_by_subdomain_spec.rb
acts_as_tenant-0.3.6 spec/acts_as_tenant/tenant_by_subdomain_spec.rb