Sha256: 569fe59f75a74166ba103b902cd8b7aefd4d4cbcda7c77f766cdf7061306111e

Contents?: true

Size: 1.5 KB

Versions: 75

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true
# Copy Blacklight test support material in place

# Need the requires here so we can call the generator from environment.rb
# as suggested above.
require 'rails/generators'
require 'rails/generators/base'
module Blacklight
  class TestSupport < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    desc <<-EOS
      Generate blacklight testing configurations for blacklight's own tests, or for blacklight plugins to use for testing
    EOS

    def alternate_controller
      copy_file "alternate_controller.rb", "app/controllers/alternate_controller.rb"

      routing_code = <<-EOF
    resource :alternate, controller: 'alternate', only: [:index] do
      concerns :searchable
    end
      EOF

      sentinel = /concern :searchable[^\n]+\n/

      inject_into_file 'config/routes.rb', routing_code, { after: sentinel, force: true }
    end

    def solr_document_config
      insert_into_file 'app/models/solr_document.rb', after: "include Blacklight::Solr::Document" do
        <<-EOF

            field_semantics.merge!(
              title: "title_tsim",
              author: "author_tsim",
              language: "language_ssim",
              format: "format")
        EOF
      end
    end

    def configure_action_mailer
      insert_into_file "config/environments/test.rb", after: "config.action_mailer.delivery_method = :test\n" do <<-EOF
         config.action_mailer.default_options = {from: 'no-reply@example.org'}
      EOF
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
blacklight-7.26.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.25.3 lib/generators/blacklight/test_support_generator.rb
blacklight-7.25.2 lib/generators/blacklight/test_support_generator.rb
blacklight-7.25.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.25.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.24.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.23.0.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.23.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.22.2 lib/generators/blacklight/test_support_generator.rb
blacklight-7.22.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.22.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.21.2 lib/generators/blacklight/test_support_generator.rb
blacklight-7.21.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.21.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.20.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.20.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.19.2 lib/generators/blacklight/test_support_generator.rb
blacklight-7.19.1 lib/generators/blacklight/test_support_generator.rb
blacklight-7.19.0 lib/generators/blacklight/test_support_generator.rb
blacklight-7.18.1 lib/generators/blacklight/test_support_generator.rb