Sha256: fb5aeb720636c7cd1ba9f6f09e16d494d82eb6028768df67640570270c809f54

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

require 'rails_helper'

module MnoEnterprise
  RSpec.describe Devise::RegistrationsController, type: :routing do
    routes { MnoEnterprise::Engine.routes }

    context 'it is enabled by default' do
      before(:all) do
        Settings.devise = {}
        Rails.application.reload_routes!
      end

      it 'routes to #new' do
        expect(get('/auth/users/sign_up')).to route_to("mno_enterprise/auth/registrations#new")
      end

      it 'routes to #create' do
        expect(post('/auth/users')).to route_to("mno_enterprise/auth/registrations#create")
      end
    end

    context 'when registration is enabled' do
      before(:all) do
        Settings.merge!(devise: {registration: {disabled: false}})
        Rails.application.reload_routes!
      end

      it 'routes to #new' do
        expect(get('/auth/users/sign_up')).to route_to("mno_enterprise/auth/registrations#new")
      end

      it 'routes to #create' do
        expect(post('/auth/users')).to route_to("mno_enterprise/auth/registrations#create")
      end
    end

    context 'when registration is disabled' do
      before(:all) do
        Settings.merge!(devise: {registration: {disabled: true}})
        Rails.application.reload_routes!
      end

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mno-enterprise-api-3.4.0 spec/routing/devise/registrations_routing_spec.rb
mno-enterprise-api-3.3.3 spec/routing/devise/registrations_routing_spec.rb
mno-enterprise-api-3.3.2 spec/routing/devise/registrations_routing_spec.rb
mno-enterprise-api-3.3.1 spec/routing/devise/registrations_routing_spec.rb
mno-enterprise-api-3.3.0 spec/routing/devise/registrations_routing_spec.rb