Skip to content

Commit

Permalink
Share the factories from the gem into the main application, adding `F…
Browse files Browse the repository at this point in the history
…actoryBot.definition_file_paths` not in the initializer, but in the engine
  • Loading branch information
texpert committed Dec 17, 2022
1 parent 24eea99 commit c040062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/camaleon_cms/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'cancancan'
require 'meta-tags'
require 'mini_magick'
# require 'mobu'
require 'will_paginate'
require 'will_paginate-bootstrap'
require 'breadcrumbs_on_rails'
Expand All @@ -16,6 +15,12 @@
require 'cama_contact_form'
require 'cama_meta_tag'

begin
require 'factory_bot_rails'
rescue LoadError
# do nothing
end

$camaleon_engine_dir = File.expand_path("../../../", __FILE__)
require File.join($camaleon_engine_dir, "lib", "plugin_routes").to_s
Dir[File.join($camaleon_engine_dir, "lib", "ext", "**", "*.rb")].each{ |f| require f }
Expand Down Expand Up @@ -79,5 +84,8 @@ class Engine < ::Rails::Engine
end
end
end

config.factory_bot.definition_file_paths +=
[File.expand_path('../../../spec/factories', __FILE__)] if defined?(FactoryBotRails)
end
end
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

FactoryBot.definition_file_paths << Rails.root.join('../', 'factories')
# FactoryBot.definition_file_paths << Rails.root.join('../', 'factories')

0 comments on commit c040062

Please sign in to comment.