Sha256: 4513f545e0238944964fab5e785d2ce2c0c0dadd241458f9f3875ffcb3f000e8

Contents?: true

Size: 1.8 KB

Versions: 37

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe 'routes for Clearance' do
  context 'routes enabled' do
    it 'draws the default routes' do
      expect(get: 'sign_up').to be_routable
      expect(get: 'sign_in').to be_routable
      expect(get: 'passwords/new').to be_routable
      expect(post: 'session').to be_routable
      expect(post: 'passwords').to be_routable
      expect(post: 'users').to be_routable
    end
  end

  context 'routes disabled' do
    around do |example|
      Clearance.configure { |config| config.routes = false }
      Rails.application.reload_routes!
      example.run
      Clearance.configuration = Clearance::Configuration.new
      Rails.application.reload_routes!
    end

    it 'does not draw any routes' do
      expect(get: 'sign_up').not_to be_routable
      expect(get: 'sign_in').not_to be_routable
      expect(get: 'passwords/new').not_to be_routable
      expect(post: 'session').not_to be_routable
      expect(post: 'passwords').not_to be_routable
      expect(post: 'users').not_to be_routable
    end
  end

  context 'signup disabled' do
    around do |example|
      Clearance.configure { |config| config.allow_sign_up = false }
      Rails.application.reload_routes!
      example.run
      Clearance.configuration = Clearance::Configuration.new
      Rails.application.reload_routes!
    end

    it 'does not route sign_up' do
      expect(get: 'sign_up').not_to be_routable
    end

    it 'does not route to users#create' do
      expect(post: 'users').not_to be_routable
    end

    it 'does not route to users#new' do
      expect(get: 'users/new').not_to be_routable
    end
  end

  context 'signup enabled' do
    it 'does route sign_up' do
      expect(get: 'sign_up').to be_routable
    end

    it 'does route to users#create' do
      expect(post: 'users').to be_routable
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
clearance-2.7.2 spec/routing/clearance_routes_spec.rb
clearance-2.7.0 spec/routing/clearance_routes_spec.rb
clearance-2.6.2 spec/routing/clearance_routes_spec.rb
clearance-2.6.1 spec/routing/clearance_routes_spec.rb
clearance-2.6.0 spec/routing/clearance_routes_spec.rb
clearance-2.5.0 spec/routing/clearance_routes_spec.rb
clearance-2.4.0 spec/routing/clearance_routes_spec.rb
clearance-2.3.1 spec/routing/clearance_routes_spec.rb
clearance-2.3.0 spec/routing/clearance_routes_spec.rb
clearance-2.2.1 spec/routing/clearance_routes_spec.rb
clearance-2.2.0 spec/routing/clearance_routes_spec.rb
clearance-2.1.0 spec/routing/clearance_routes_spec.rb
clearance-2.0.0 spec/routing/clearance_routes_spec.rb
clearance-2.0.0.beta2 spec/routing/clearance_routes_spec.rb
clearance-2.0.0.beta1 spec/routing/clearance_routes_spec.rb
clearance-1.17.0 spec/routing/clearance_routes_spec.rb
clearance-1.16.2 spec/routing/clearance_routes_spec.rb
clearance-1.16.1 spec/routing/clearance_routes_spec.rb
clearance-1.16.0 spec/routing/clearance_routes_spec.rb
clearance-1.15.1 spec/routing/clearance_routes_spec.rb