Created
November 24, 2021 14:24
-
-
Save amitpatelx/b04f2035c8b458e3b339d536a0a08363 to your computer and use it in GitHub Desktop.
Error while using custom precondition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ba/skill_name/clone.rb | |
... | |
# precondition if: -> { in_merge_flow? } do | |
# decline_with(precondition_error('broken_merge')) if broken_merge? | |
# end | |
precondition MergeCapabilityCheck, if: -> { in_merge_flow? } | |
... | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) BA::SkillName::Clone preconditions when in merge flow when merge is broken is expected not to satisfy preconditions | |
Failure/Error: | |
expect(action).not_to satisfy_preconditions | |
.with_message( | |
'At the moment, a skill can be merged if, for any vertical it belongs to, ' \ | |
'it is not a skill identifier. Please submit an assistance ticket to handle merging ' \ | |
'outside these conditions.' | |
) | |
NoMethodError: | |
undefined method `broken_merge?' for #<BA::SkillName::Clone:0x0000560cc81881b8> | |
# ./apq/actions/ba/skill_name/clone.rb:64:in `block in <class:Clone>' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions/base_precondition.rb:18:in `instance_exec' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions/base_precondition.rb:18:in `_execute' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions/base_precondition.rb:12:in `execute!' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions.rb:30:in `block in execute!' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions.rb:30:in `each' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions.rb:30:in `execute!' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions.rb:109:in `run_preconditions!' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/action/preconditions.rb:97:in `satisfy_preconditions?' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/granite-0.11.1/lib/granite/rspec/satisfy_preconditions.rb:53:in `block (2 levels) in <main>' | |
# ./spec/apq/actions/ba/skill_name/clone_spec.rb:31:in `block (5 levels) in <main>' | |
# ./spec/rails_helper.rb:773:in `block (3 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:771:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:690:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:479:in `block (3 levels) in <top (required)>' | |
# ./app/processes/concerns/granite_integration.rb:184:in `disable_business_actions_matching' | |
# ./spec/rails_helper.rb:479:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:473:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:465:in `block (3 levels) in <top (required)>' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/rails-observers-0.1.5/lib/rails/observers/active_model/observer_array.rb:128:in `block in set_enablement' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/rails-observers-0.1.5/lib/rails/observers/active_model/observer_array.rb:112:in `transaction' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/rails-observers-0.1.5/lib/rails/observers/active_model/observer_array.rb:126:in `set_enablement' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/rails-observers-0.1.5/lib/rails/observers/active_model/observer_array.rb:41:in `disable' | |
# ./spec/rails_helper.rb:465:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:457:in `block (3 levels) in <top (required)>' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/database_cleaner-1.6.2/lib/database_cleaner/generic/base.rb:16:in `cleaning' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/database_cleaner-1.6.2/lib/database_cleaner/base.rb:98:in `cleaning' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/database_cleaner-1.6.2/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/database_cleaner-1.6.2/lib/database_cleaner/configuration.rb:87:in `cleaning' | |
# ./spec/rails_helper.rb:457:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:453:in `block (2 levels) in <top (required)>' | |
# ./spec/rails_helper.rb:448:in `block (3 levels) in <top (required)>' | |
# ./app/models/concerns/verticals/caching.rb:145:in `run_within' | |
# ./spec/rails_helper.rb:448:in `block (2 levels) in <top (required)>' | |
# ./engines/starfleet/spec/support/stub_redis.rb:13:in `block (3 levels) in <main>' | |
# /home/amit/.rvm/gems/ruby-2.6.5/gems/dry-container-0.7.2/lib/dry/container/stub.rb:20:in `stub' | |
# ./engines/starfleet/spec/support/stub_redis.rb:12:in `block (2 levels) in <main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BA | |
module SkillName | |
class MergeCapabilityCheck < Granite::Action::Precondition | |
# include ::GraniteTranslationsHelper | |
description 'Must not be broken for merge' | |
def call(**) | |
decline_with(precondition_error('merge_into_unchecked_skill')) unless existing_skill_name.checked? | |
decline_with(precondition_error('broken_merge')) if broken_merge? #skills.any? {|skill| BA::Skill::ImmutableMerge.new(skill, new_skill_name: existing_skill_name).invalid?} | |
end | |
private | |
def broken_merge? | |
skills.any? {|skill| BA::Skill::ImmutableMerge.new(skill, new_skill_name: existing_skill_name).invalid?} | |
end | |
def precondition_error(key) | |
t(".granite_action.errors.models.ba/skill/merge_business_action.#{key}") | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment