Load BIM edition modules conditionally using the ENV variable "OPENPROJECT_EDITION"

pull/7115/head
Wieland Lindenthal 6 years ago
parent c14338a8c0
commit 7fccc2e198
  1. 13
      Gemfile.modules
  2. 7
      config/configuration.yml.example
  3. 6
      modules/bim_seeder/app/seeders/bim_seeder/root_seeder.rb
  4. 10
      modules/bim_seeder/spec/seeders/demo_data_seeder_spec.rb
  5. 7
      spec/seeders/demo_data_seeder_spec.rb

@ -39,8 +39,17 @@ group :opf_plugins do
gem 'openproject-github_integration', path: 'modules/github_integration'
gem 'openproject-ldap_groups', path: 'modules/ldap_groups'
gem 'grids', path: 'modules/grids'
gem 'grids', path: 'modules/grids'
gem 'openproject-boards', path: 'modules/boards'
gem 'openproject-bim_seeder', path: 'modules/bim_seeder'
#####################################
#
# Remove this before merging into dev!!
#
# We need this for now, to trick Travis as we do not set the ENV variable "OPENPROJECT_EDITION", yet.
ENV['OPENPROJECT_EDITION'] = 'bim'
#####################################
gem 'openproject-bim_seeder', path: 'modules/bim_seeder', require: !!(ENV['OPENPROJECT_EDITION'] == 'bim')
end

@ -165,13 +165,6 @@
# default configuration options for all environments
default:
# Edition
#
# Openproject comes in two editions, the 'standard' edition for generic project management
# and the 'bim' edition, that specializes on the construction business.
#
edition: standard
log_level: info
# Outgoing emails configuration (see examples above)

@ -1,11 +1,7 @@
module BimSeeder
module RootSeeder
def seed_basic_data
if OpenProject::Configuration['edition'] == 'bim'
return ::BimSeeder::BasicDataSeeder.new.seed!
end
super
::BimSeeder::BasicDataSeeder.new.seed!
end
end
end

@ -46,16 +46,16 @@ describe 'seeds' do
ActionMailer::Base.perform_deliveries = false
end
context 'bim edition' do
context 'BIM edition' do
it 'create the demo data' do
expect { BimSeeder::BasicDataSeeder.new.seed! }.not_to raise_error
expect { AdminUserSeeder.new.seed! }.not_to raise_error
expect { DemoDataSeeder.new.seed! }.not_to raise_error
begin
# Avoid asynchronous DeliverWorkPackageCreatedJob
Delayed::Worker.delay_jobs = false
expect { BimSeeder::BasicDataSeeder.new.seed! }.not_to raise_error
expect { AdminUserSeeder.new.seed! }.not_to raise_error
expect { DemoDataSeeder.new.seed! }.not_to raise_error
expect(User.where(admin: true).count).to eq 1
expect(Project.count).to eq 1
expect(WorkPackage.count).to eq 18

@ -48,14 +48,15 @@ describe 'seeds' do
context 'standard edition' do
it 'create the demo data' do
expect { StandardSeeder::BasicDataSeeder.new.seed! }.not_to raise_error
expect { AdminUserSeeder.new.seed! }.not_to raise_error
expect { DemoDataSeeder.new.seed! }.not_to raise_error
begin
# Avoid asynchronous DeliverWorkPackageCreatedJob
Delayed::Worker.delay_jobs = false
expect { StandardSeeder::BasicDataSeeder.new.seed! }.not_to raise_error
expect { AdminUserSeeder.new.seed! }.not_to raise_error
expect { DemoDataSeeder.new.seed! }.not_to raise_error
expect(User.where(admin: true).count).to eq 1
expect(Project.count).to eq 2
expect(WorkPackage.count).to eq 41

Loading…
Cancel
Save