Sha256: 246365b281b500f2c6293cb6149145aa34798db754ce1c374769978005061210

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

organizations = Organization.unscoped.all
locations = Location.unscoped.all
User.as_anonymous_admin do
  RemoteExecutionFeature.without_auditing do
    if Rails.env.test? || Foreman.in_rake?
      # If this file tries to import a template with a REX feature in a SeedsTest,
      # it will fail - the REX feature isn't registered on SeedsTest because
      # DatabaseCleaner truncates the db before every test.
      # During db:seed, we also want to know the feature is registered before
      # seeding the template
      ForemanLeapp::Engine.register_rex_features
    end
    JobTemplate.without_auditing do
      Dir[File.join("#{ForemanLeapp::Engine.root}/app/views/foreman_leapp/"\
                    'job_templates/**/*.erb')].sort.each do |template|
        template = JobTemplate.import_raw!(File.read(template),
                                           :default => true,
                                           :lock => true,
                                           :update => true)
        template.organizations = organizations if template.present?
        template.locations = locations if template.present?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_leapp-2.0.3 db/seeds.d/10_leapp_preupgrade.rb
foreman_leapp-2.0.2 db/seeds.d/10_leapp_preupgrade.rb
foreman_leapp-1.2.2 db/seeds.d/10_leapp_preupgrade.rb
foreman_leapp-2.0.1 db/seeds.d/10_leapp_preupgrade.rb