Sha256: 77fa6ec7855c902228cd6a4cb25c7272030a7b93f2045e41cd8671c99a64b756

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

require 'spec_helper'

describe Clearance::Configuration do
  after { restore_default_config }

  describe 'when no user_model_name is specified' do
    before do
      Clearance.configure do |config|
      end
    end

    it 'defaults to User' do
      Clearance.configuration.user_model.should == ::User
    end
  end

  describe 'when a custom user_model_name is specified' do
    before do
      MyUser = Class.new

      Clearance.configure do |config|
        config.user_model = MyUser
      end
    end

    after do
      Clearance.configure do |config|
        config.user_model = ::User
      end
    end

    it 'is used instead of User' do
      Clearance.configuration.user_model.should == ::MyUser
    end
  end

  describe 'when secure_cookie is set to true' do
    before do
      Clearance.configure do |config|
        config.secure_cookie = true
      end
    end

    after do
      Clearance.configure do |config|
        config.secure_cookie = false
      end
    end

    it 'returns true' do
      Clearance.configuration.secure_cookie.should be_true
    end
  end

  describe 'when secure_cookie is not specified' do
    before do
      Clearance.configure do |config|
      end
    end

    it 'defaults to false' do
      Clearance.configuration.secure_cookie.should be_false
    end
  end

  describe 'when no redirect URL specified' do
    it 'should return "/" as redirect URL' do
      Clearance::Configuration.new.redirect_url.should == '/'
    end
  end

  describe 'when redirect URL is specified' do
    let(:new_redirect_url) { '/admin' }

    before do
      Clearance.configure do |config|
        config.redirect_url = new_redirect_url
      end
    end

    after do
      Clearance.configure do |config|
        config.redirect_url = '/'
      end
    end

    it 'should return new redirect URL' do
      Clearance.configuration.redirect_url.should == new_redirect_url
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clearance-1.0.1 spec/configuration_spec.rb
clearance-1.0.0 spec/configuration_spec.rb
clearance-1.0.0.rc8 spec/configuration_spec.rb
clearance-1.0.0.rc7 spec/configuration_spec.rb