Sha256: 3bdfa4c20aca7724d96f269e1b7ecd50e863629c1278c7a718927236bf50d126

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe CurrentDomain::Controllers::Helpers do
  describe '#current_domain' do
    context 'default method for finding current domain is used' do
      class A < ActionController::Base
        include CurrentDomain::Controllers::Helpers
      end

      let(:controller) { A.new }

      before do
        allow(controller).to receive_message_chain(:request, :host)
          .and_return('host.name')
      end

      it 'returns request host name' do
        expect(controller.current_domain).to eq('host.name')
      end
    end

    context 'custom method for finding current domain is used' do
      class B < ActionController::Base
        include CurrentDomain::Controllers::Helpers

        def find_domain(_host)
          'domain'
        end
      end

      let(:controller) { B.new }

      before do
        allow(controller).to receive_message_chain(:request, :host)
          .and_return('host.name')
      end

      it 'returns custom domain object' do
        expect(controller.current_domain).to eq(controller.find_domain(''))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
current_domain-1.0 spec/current_domain/controllers/helpers_spec.rb
current_domain-0.1 spec/current_domain/controllers/helpers_spec.rb