Class: Blacklight::TestSupport

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/blacklight/test_support_generator.rb

Instance Method Summary collapse

Instance Method Details

#alternate_controllerObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/blacklight/test_support_generator.rb', line 17

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

#configure_action_mailerObject



44
45
46
47
48
49
50
# File 'lib/generators/blacklight/test_support_generator.rb', line 44

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

#solr_document_configObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/blacklight/test_support_generator.rb', line 31

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