- Fix DemoSeeerSpec race condition.

- Use patches.
- Overwrite default design variables.
- Move images to plugin.
pull/7115/head
Wieland Lindenthal 6 years ago
parent 7fccc2e198
commit 4dfe4d5dec
  1. 17
      lib/open_project/design.rb
  2. 0
      modules/bim_seeder/app/assets/images/bim/logo_openproject_bim_big.png
  3. 9
      modules/bim_seeder/app/seeders/bim_seeder/root_seeder.rb
  4. 4
      modules/bim_seeder/lib/open_project/bim_seeder.rb
  5. 1
      modules/bim_seeder/lib/open_project/bim_seeder/engine.rb
  6. 23
      modules/bim_seeder/lib/open_project/bim_seeder/patches/design_patch.rb
  7. 11
      modules/bim_seeder/lib/open_project/bim_seeder/patches/root_seeder_patch.rb
  8. 7
      modules/bim_seeder/spec/seeders/demo_data_seeder_spec.rb
  9. 6
      spec/seeders/demo_data_seeder_spec.rb

@ -200,22 +200,7 @@ module OpenProject
'table-timeline--row-height' => '40px',
'status-selector-bg-color' => '#F99601',
'status-selector-bg-hover-color' => '#E08600'
}.merge(
if OpenProject::Configuration['edition'] == 'bim'
{
'primary-color' => "#748EA8",
'primary-color-dark' => "#566484",
'header-bg-color' => "#566484",
'header-item-bg-hover-color' => "#748EA8",
'main-menu-bg-color' => "#333739",
'main-menu-bg-selected-background' => "#748EA8",
'main-menu-bg-hover-background' => "#566484",
'header-home-link-bg' => '#{image-url("editions/bim/logo_openproject_bim_big.png") no-repeat 20px 0}'
}
else
{}
end
).freeze
}.freeze
# Regular expression for references of other variables.
VARIABLE_NAME_RGX = /\$([\w-]+)/

@ -1,9 +0,0 @@
module BimSeeder
module RootSeeder
def seed_basic_data
::BimSeeder::BasicDataSeeder.new.seed!
end
end
end
RootSeeder.prepend BimSeeder::RootSeeder

@ -1,5 +1,9 @@
module OpenProject
module BimSeeder
require "open_project/bim_seeder/engine"
# The DesignPatch is not a typical method patch, as it replaces a constant and thus needs to be applied without the
# standard patch logic for plugins.
require "open_project/bim_seeder/patches/design_patch"
end
end

@ -12,5 +12,6 @@ module OpenProject::BimSeeder
:author_url => 'https://openproject.org',
:requires_openproject => '>= 9.0.0'
patches [:RootSeeder]
end
end

@ -0,0 +1,23 @@
require 'open_project/design'
module OpenProject::BimSeeder
module Patches
module DesignPatch
DEFAULTS = OpenProject::Design::DEFAULTS.merge(
{
'primary-color' => "#748EA8",
'primary-color-dark' => "#566484",
'header-bg-color' => "#566484",
'header-item-bg-hover-color' => "#748EA8",
'main-menu-bg-color' => "#333739",
'main-menu-bg-selected-background' => "#748EA8",
'main-menu-bg-hover-background' => "#566484",
'header-home-link-bg' => '#{image-url("bim/logo_openproject_bim_big.png") no-repeat 20px 0}'
}
).freeze
end
end
end
OpenProject::Design.send(:remove_const, 'DEFAULTS')
OpenProject::Design.const_set('DEFAULTS', OpenProject::BimSeeder::Patches::DesignPatch::DEFAULTS)

@ -0,0 +1,11 @@
module OpenProject::BimSeeder::Patches::RootSeederPatch
def self.included(base) # :nodoc:
base.prepend InstanceMethods
end
module InstanceMethods
def seed_basic_data
::BimSeeder::BasicDataSeeder.new.seed!
end
end
end

@ -36,9 +36,6 @@ def translate_with_base_url(string)
end
describe 'seeds' do
let(:edition) { 'bim' }
let(:perform_deliveries) { ActionMailer::Base.perform_deliveries }
before do
allow(OpenProject::Configuration).to receive(:[]).and_call_original
allow(OpenProject::Configuration).to receive(:[]).with('edition').and_return(edition)
@ -47,7 +44,11 @@ describe 'seeds' do
end
context 'BIM edition' do
let(:edition) { 'bim' }
it 'create the demo data' do
perform_deliveries = ActionMailer::Base.perform_deliveries
begin
# Avoid asynchronous DeliverWorkPackageCreatedJob
Delayed::Worker.delay_jobs = false

@ -36,9 +36,6 @@ def translate_with_base_url(string)
end
describe 'seeds' do
let(:edition) { 'standard' }
let(:perform_deliveries) { ActionMailer::Base.perform_deliveries }
before do
allow(OpenProject::Configuration).to receive(:[]).and_call_original
allow(OpenProject::Configuration).to receive(:[]).with('edition').and_return(edition)
@ -47,7 +44,10 @@ describe 'seeds' do
end
context 'standard edition' do
let(:edition) { 'standard' }
it 'create the demo data' do
perform_deliveries = ActionMailer::Base.perform_deliveries
begin
# Avoid asynchronous DeliverWorkPackageCreatedJob

Loading…
Cancel
Save