Skip to content

Commit

Permalink
Load plugin under Rails 4, fix seeds incompatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Cleal committed Jan 7, 2016
1 parent 31b0857 commit 296dcfc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FakeConfigTemplate < ActiveRecord::Base
end

def self.up
kind = TemplateKind.find_or_create_by_name('Bootdisk')
kind = TemplateKind.where(:name => 'Bootdisk').first_or_create

tmpl_h = Setting.find_by_name('bootdisk_host_template').try(:value)
tmpl_g = Setting.find_by_name('bootdisk_generic_host_template').try(:value)
Expand Down
28 changes: 15 additions & 13 deletions db/seeds.d/50-bootdisk_templates.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
kind = TemplateKind.find_or_create_by_name('Bootdisk')
kind = TemplateKind.where(:name => 'Bootdisk').first_or_create

ProvisioningTemplate.without_auditing do
content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'host.erb'))
tmpl = ProvisioningTemplate.find_or_create_by_name(
:name => 'Boot disk iPXE - host',
:template_kind_id => kind.id,
:snippet => false,
:template => content
)
tmpl = ProvisioningTemplate.where(:name => 'Boot disk iPXE - host').first_or_create do |template|
template.attributes = {
:template_kind_id => kind.id,
:snippet => false,
:template => content
}
end
tmpl.attributes = {
:template => content,
:default => true,
Expand All @@ -17,12 +18,13 @@
tmpl.save!(:validate => false) if tmpl.changes.present?

content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'generic_host.erb'))
tmpl = ProvisioningTemplate.find_or_create_by_name(
:name => 'Boot disk iPXE - generic host',
:template_kind_id => kind.id,
:snippet => false,
:template => content
)
tmpl = ProvisioningTemplate.where(:name => 'Boot disk iPXE - generic host').first_or_create do |template|
template.attributes = {
:template_kind_id => kind.id,
:snippet => false,
:template => content
}
end
tmpl.attributes = {
:template => content,
:default => true,
Expand Down
3 changes: 1 addition & 2 deletions lib/foreman_bootdisk.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'foreman_bootdisk/version'
require 'foreman_bootdisk/engine'

module ForemanBootdisk
ENGINE_NAME = 'foreman_bootdisk'

require 'foreman_bootdisk/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
end
4 changes: 3 additions & 1 deletion lib/foreman_bootdisk/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class Engine < ::Rails::Engine
end

initializer "foreman_bootdisk.load_app_instance_data" do |app|
app.config.paths['db/migrate'] += ForemanBootdisk::Engine.paths['db/migrate'].existent
ForemanBootdisk::Engine.paths['db/migrate'].existent.each do |path|
app.config.paths['db/migrate'] << path
end
end

initializer "foreman_bootdisk.apipie" do
Expand Down

0 comments on commit 296dcfc

Please sign in to comment.