Merge pull request #10138 from opf/fix/zeitwerk-check

Add zeitwerk:check action runner
pull/10141/head
Oliver Günther 3 years ago committed by GitHub
commit 6bdfb2e381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/workflows/test-core.yml
  2. 1
      docker/ci/entrypoint.sh
  3. 82
      modules/budgets/lib/budgets/hooks/work_package_hook.rb
  4. 40
      modules/reporting/lib/open_project/reporting/patches/big_decimal_patch.rb

@ -80,6 +80,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-node@v2
with:
node-version: '14'

@ -57,6 +57,7 @@ fi
if [ "$1" == "run-units" ]; then
shift
execute "time bundle exec rake zeitwerk:check"
execute "cd frontend && npm install && npm run test"
execute "time bundle exec rspec -I spec_legacy spec_legacy"
if ! execute "time bundle exec rake parallel:units" ; then

@ -26,48 +26,52 @@
# See COPYRIGHT and LICENSE files for more details.
#++
class Budgets::Hooks::WorkPackageHook < OpenProject::Hook::ViewListener
# Updates the cost object after a move
#
# Context:
# * params => Request parameters
# * work_package => WorkPackage to move
# * target_project => Target of the move
# * copy => true, if the work_packages are copied rather than moved
def controller_work_packages_move_before_save(context = {})
# FIXME: In case of copy==true, this will break stuff if the original work_package is saved
module Budgets
module Hooks
class WorkPackageHook < ::OpenProject::Hook::ViewListener
# Updates the cost object after a move
#
# Context:
# * params => Request parameters
# * work_package => WorkPackage to move
# * target_project => Target of the move
# * copy => true, if the work_packages are copied rather than moved
def controller_work_packages_move_before_save(context = {})
# FIXME: In case of copy==true, this will break stuff if the original work_package is saved
budget_id = context[:params] && context[:params][:budget_id]
case budget_id
when '' # a.k.a "(No change)"
# cost objects HAVE to be changed if move is performed across project boundaries
# as the are project specific
context[:work_package].budget_id = nil unless context[:work_package].project == context[:target_project]
when 'none'
context[:work_package].budget_id = nil
else
context[:work_package].budget_id = budget_id
end
end
budget_id = context[:params] && context[:params][:budget_id]
case budget_id
when '' # a.k.a "(No change)"
# cost objects HAVE to be changed if move is performed across project boundaries
# as the are project specific
context[:work_package].budget_id = nil unless context[:work_package].project == context[:target_project]
when 'none'
context[:work_package].budget_id = nil
else
context[:work_package].budget_id = budget_id
end
end
# Saves the Cost Object assignment to the work_package
#
# Context:
# * :work_package => WorkPackage being saved
# * :params => HTML parameters
#
def controller_work_packages_bulk_edit_before_save(context = {})
case true
# Saves the Cost Object assignment to the work_package
#
# Context:
# * :work_package => WorkPackage being saved
# * :params => HTML parameters
#
def controller_work_packages_bulk_edit_before_save(context = {})
case true
when context[:params][:budget_id].blank?
# Do nothing
when context[:params][:budget_id] == 'none'
# Unassign budget
context[:work_package].budget = nil
else
context[:work_package].budget = Budget.find(context[:params][:budget_id])
end
when context[:params][:budget_id].blank?
# Do nothing
when context[:params][:budget_id] == 'none'
# Unassign budget
context[:work_package].budget = nil
else
context[:work_package].budget = Budget.find(context[:params][:budget_id])
end
''
''
end
end
end
end

@ -26,22 +26,34 @@
# See COPYRIGHT and LICENSE files for more details.
#++
module OpenProject::Reporting::Patches::BigDecimalPatch
class BigDecimal
def to_d; self end
end
module OpenProject
module Reporting
module Patches
module BigDecimalPatch
class BigDecimal
def to_d
self
end
end
class Integer
def to_d; to_f.to_d end
end
class Integer
def to_d
to_f.to_d
end
end
class String
def to_d
BigDecimal self
end
end
class String
def to_d
BigDecimal self
end
end
class NilClass
def to_d; 0 end
class NilClass
def to_d
0
end
end
end
end
end
end

Loading…
Cancel
Save