Sha256: 6f4356d6c325707441aa64430e0bc585ae73744e7cd679b2464b43c543cd44e9

Contents?: true

Size: 762 Bytes

Versions: 2

Compression:

Stored size: 762 Bytes

Contents

require "spec_helper"

class ApplicationController2 < ActionController::Base
  include Rails.application.routes.url_helpers
  set_current_tenant_through_filter
  before_action :your_method_that_finds_the_current_tenant

  def your_method_that_finds_the_current_tenant
    current_account = Account.new(name: "account1")
    set_current_tenant(current_account)
  end
end

# Start testing
describe ApplicationController2, type: :controller do
  controller do
    def index
      # Exercise current_tenant helper method
      render plain: current_tenant.name
    end
  end

  it "Finds the correct tenant using the filter command" do
    get :index
    expect(ActsAsTenant.current_tenant.name).to eq "account1"
    expect(response.body).to eq "account1"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_tenant-0.5.1 spec/controllers/filter_spec.rb
acts_as_tenant-0.5.0 spec/controllers/filter_spec.rb