Skip to content

Commit

Permalink
Merge pull request #32 from yogeshjain999/wrap-wiring
Browse files Browse the repository at this point in the history
Upgrade activity-dsl and operation versions
  • Loading branch information
yogeshjain999 authored Nov 30, 2020
2 parents 5c4d5c9 + 1ebddbd commit 50a6846
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
24 changes: 0 additions & 24 deletions test/docs/guard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,6 @@ class Create < Trailblazer::Operation
}
end

#---
# dependency injection
class DocsGuardInjectionTest < Minitest::Spec
#:di-op
class Create < Trailblazer::Operation
extend Trailblazer::Operation::Container

step Policy::Guard( ->(options, current_user:, **) { current_user == Module } )
end
#:di-op end

it { Create.(:current_user => Module).inspect("").must_equal %{<Result:true [nil] >} }
it {
result =
#:di-call
Create.(
{},
:current_user => Module,
:"policy.default.eval" => Trailblazer::Operation::Policy::Guard.build(->(options, **) { false })
)
#:di-call end
result.inspect("").must_equal %{<Result:false [nil] >} }
end

#---
# missing current_user throws exception
class DocsGuardMissingKeywordTest < Minitest::Spec
Expand Down
25 changes: 25 additions & 0 deletions test/docs/rescue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,29 @@ def my_handler(exception, (ctx), *)
it { Memo::Create.( { seq: [], } ).inspect(:seq, :exception_class).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify], nil] >} }
it { Memo::Create.( { seq: [], rehash_raise: true } ).inspect(:seq, :exception_class).must_equal %{<Result:false [[:find_model, :update, :rehash, :log_error], RuntimeError] >} }
end

=begin
Rescue(), fast_track: true {}
=end
class RescueWithFastTrack < Minitest::Spec
Memo = Class.new

#:rescue-fasttrack
class Memo::Create < Trailblazer::Operation
rescue_block = ->(*) {
step :update, Output(:failure) => End(:fail_fast)
step :rehash
}

step :find_model
step Rescue(&rescue_block), fail_fast: true
step :notify
fail :log_error
#~methods
include T.def_steps(:find_model, :update, :notify, :log_error, :rehash)
end

it { Memo::Create.( { seq: [], } ).inspect(:seq).must_equal %{<Result:true [[:find_model, :update, :rehash, :notify]] >} }
it { Memo::Create.( { seq: [], update: false } ).inspect(:seq).must_equal %{<Result:false [[:find_model, :update]] >} }
end
end
6 changes: 3 additions & 3 deletions trailblazer-macro.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "roar"
spec.add_development_dependency "trailblazer-developer"

spec.add_dependency "trailblazer-activity", ">= 0.10.0", "< 1.0.0"
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.2.7", "< 1.0.0"
spec.add_dependency "trailblazer-operation", ">= 0.6.2" # TODO: this dependency will be removed.
spec.add_dependency "trailblazer-activity", ">= 0.11.2", "< 1.0.0"
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 0.3.3", "< 1.0.0"
spec.add_dependency "trailblazer-operation", ">= 0.6.5" # TODO: this dependency will be removed.

spec.required_ruby_version = ">= 2.2.0"
end

0 comments on commit 50a6846

Please sign in to comment.