Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Load FactoryBot for lookbook so we can generate preview data

Oliver Günther42f36f0c4482
diff --git a/Gemfile b/Gemfile
index 69948a4cbc2..b29d655a1f3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -210,6 +210,11 @@ gem 'view_component'
# Lookbook
gem 'lookbook', '~> 2.0.5'
+# Require factory_bot for usage with openproject plugins testing
+gem 'factory_bot', '~> 6.2.0', require: false
+# require factory_bot_rails for convenience in core development
+gem 'factory_bot_rails', '~> 6.2.0', require: false
+
gem 'turbo-rails', "~> 1.1"
group :test do
@@ -288,10 +293,6 @@ end
group :development, :test do
gem 'dotenv-rails'
- # Require factory_bot for usage with openproject plugins testing
- gem 'factory_bot', '~> 6.2.0'
- # require factory_bot_rails for convenience in core development
- gem 'factory_bot_rails', '~> 6.2.0'
# Tracing and profiling gems
gem 'flamegraph', require: false
diff --git a/config/initializers/lookbook.rb b/config/initializers/lookbook.rb
index 1a69ce4f8a4..ce028cc203a 100644
--- a/config/initializers/lookbook.rb
+++ b/config/initializers/lookbook.rb
@@ -1,6 +1,9 @@
OpenProject::Application.configure do
next unless OpenProject::Configuration.lookbook_enabled?
+ require 'factory_bot'
+ require 'factory_bot_rails'
+
# Re-define snapshot to avoid warnings
YARD::Tags::Library.define_tag("Snapshot preview (unused)", :snapshot)
config.lookbook.project_name = "OpenProject Lookbook"
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 448cb256919..959ae5fefa0 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -27,6 +27,7 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
+require 'factory_bot'
require 'factory_bot_rails'
require 'rspec/rails'
require 'shoulda/matchers'