Sha256: a7ed04d2500572eaee72043bde26577e9f3abb528b0df724864fc9eb7d4fd644

Contents?: true

Size: 905 Bytes

Versions: 16

Compression:

Stored size: 905 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This is a quick hack so all controller specs have their engine's routes
  # included as well as our Devise mapping.
  module ControllerRequests
    extend ActiveSupport::Concern

    included do
      begin
        engine = (ENV["ENGINE_NAME"].to_s.split("-").map(&:capitalize).join("::") + "::Engine").constantize

        load_routes engine if engine.respond_to?(:routes)
      rescue NameError => _exception
        puts "Failed to automatically inject routes for engine #{ENV["ENGINE_NAME"]}"
      end
    end

    class_methods do
      def load_routes(klass)
        routes do
          klass.routes
        end
      end
    end
  end
end

RSpec.configure do |config|
  config.include Decidim::ControllerRequests, type: :controller

  config.before :each, type: :controller do
    @request.env["devise.mapping"] = Devise.mappings[:user]
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
decidim-dev-0.4.1 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.4.3 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.4.3 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.4.2 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.4.2 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.4.1 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.4.0 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.4.0 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.3.2 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.3.2 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.3.1 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.3.1 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.3.0 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.3.0 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-dev-0.2.0 lib/decidim/dev/test/rspec_support/engine_routes.rb
decidim-0.2.0 decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb