Sha256: 5bd34ed4104819a3ba5333ed302f4b9d16ae535bcdb0d186d1a90a733995b9c6

Contents?: true

Size: 1.94 KB

Versions: 21

Compression:

Stored size: 1.94 KB

Contents

require 'rails_helper'

RSpec.describe ActiveAdmin::Application, type: :request do

  include Rails.application.routes.url_helpers

  let(:resource) { ActiveAdmin.register Category }

  [false, nil].each do |value|

    describe "with a #{value} default namespace" do

      around do |example|
        with_custom_default_namespace(value) { example.call }
      end

      it "should generate resource paths" do
        expect(resource.route_collection_path).to eq "/categories"
      end

      it "should generate a log out path" do
        expect(destroy_admin_user_session_path).to eq "/logout"
      end

      it "should generate a log in path" do
        expect(new_admin_user_session_path).to eq "/login"
      end

    end

  end

  describe "with a test default namespace" do

    around do |example|
      with_custom_default_namespace(:test) { example.call }
    end

    it "should generate resource paths" do
      expect(resource.route_collection_path).to eq "/test/categories"
    end

    it "should generate a log out path" do
      expect(destroy_admin_user_session_path).to eq "/test/logout"
    end

    it "should generate a log in path" do
      expect(new_admin_user_session_path).to eq "/test/login"
    end

  end

  describe "with a namespace with underscores in the name" do

    around do |example|
      with_custom_default_namespace(:abc_123) { example.call }
    end

    it "should generate resource paths" do
      expect(resource.route_collection_path).to eq "/abc_123/categories"
    end

    it "should generate a log out path" do
      expect(destroy_admin_user_session_path).to eq "/abc_123/logout"
    end

    it "should generate a log in path" do
      expect(new_admin_user_session_path).to eq "/abc_123/login"
    end

  end

  private

  def with_custom_default_namespace(namespace)
    application = ActiveAdmin::Application.new
    application.default_namespace = namespace

    with_temp_application(application) { yield }
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.2 spec/requests/default_namespace_spec.rb
activeadmin-rails-1.7.1 spec/requests/default_namespace_spec.rb
activeadmin-rails-1.7.0 spec/requests/default_namespace_spec.rb
activeadmin-rb-1.6.0 spec/requests/default_namespace_spec.rb
activeadmin-rb-1.5.2 spec/requests/default_namespace_spec.rb
activeadmin-rb-1.5.1 spec/requests/default_namespace_spec.rb
activeadmin-rb-1.5.0 spec/requests/default_namespace_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin-rb-1.4.0 spec/requests/default_namespace_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin-1.3.1 spec/requests/default_namespace_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin-1.3.0 spec/requests/default_namespace_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/requests/default_namespace_spec.rb
activeadmin-1.2.1 spec/requests/default_namespace_spec.rb
activeadmin-1.2.0 spec/requests/default_namespace_spec.rb
activeadmin-1.1.0 spec/requests/default_namespace_spec.rb