Sha256: 072f9c0025ebdf1a38685ae9c2c6fe2ae409319fb2a2a4c02d7ceedf1a1c456f

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require "rails_helper"

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

    context "Impersonation is enabled" do
      before(:all) do
        Settings.merge!(admin_panel: {impersonation: {disabled: false}})
        Rails.application.reload_routes!
      end

      it "routes to #create" do
        expect(get("/impersonate/user/1")).to route_to("mno_enterprise/impersonate#create", user_id: '1')
      end

      it "routes to #destroy" do
        expect(get("/impersonate/revert")).to route_to("mno_enterprise/impersonate#destroy")
      end
    end

    context "Impersonation is disabled" do
      before(:all) do
        Settings.merge!(admin_panel: {impersonation: {disabled: true}})
        Rails.application.reload_routes!
      end

      it 'loads regular routes' do
        expect(get('/ping')).to route_to('mno_enterprise/status#ping')
      end

      it "does not route to #create" do
        expect(get("/impersonate/user/1")).not_to be_routable
      end

      it "does not route to #destroy" do
        expect(get("/impersonate/revert")).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/mno_enterprise/impersonate_controller_routing_spec.rb
mno-enterprise-api-3.3.3 spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
mno-enterprise-api-3.3.2 spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
mno-enterprise-api-3.3.1 spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb
mno-enterprise-api-3.3.0 spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb