Skip to content

Refactor mock_step and deprecate subprocess kwarg#25

Open
yogeshjain999 wants to merge 1 commit intotrailblazer:masterfrom
yogeshjain999:refactor-mock-step
Open

Refactor mock_step and deprecate subprocess kwarg#25
yogeshjain999 wants to merge 1 commit intotrailblazer:masterfrom
yogeshjain999:refactor-mock-step

Conversation

@yogeshjain999
Copy link
Copy Markdown
Member

Refactor mock_step method to utilise new DSL::Patch call and deprecate subprocess kwarg. Instead, pass only subprocess_path with full nested path of subprocesses.

Old usage

override = mock_step(Album::Show, id: :fetch, subprocess: Publisher::Details, subprocess_path: [Spotify::Stats]) do |ctx|
  ctx[:publisher_stats] = { views: 100, downloads: 10 }
end

assert_pass({}, {}, operation: override)

New usage

override = mock_step(Album::Show, id: :fetch, subprocess_path: [Publisher::Details, Spotify::Stats]) do |ctx|
  ctx[:publisher_stats] = { views: 100, downloads: 10 }
end

assert_pass({}, {}, operation: override)

Passing subprocess kwarg will work for now, but it shows deprecation warning and will get removed in next major release.


#~method
assert_pass new_activity, default_params, {} do |(signal, (ctx, flow_options))|
assert_pass({}, {}, operation: new_activity) do |ctx|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the {}, {} arguments here, I wonder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I want to compare ctx[:user] object here in the 2nd {} of output here, but I guess it's not possible to compare it's not primitive type!

step Subprocess(subprocess, patch: patch), replace: subprocess, id: subprocess
end
subprocess_path = [subprocess, *subprocess_path]
Trailblazer::Activity::Deprecate.warn caller_locations[0], ":subprocess is deprecated and will be removed in 1.0.0. Pass `subprocess_path: #{subprocess_path}` instead."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we name it :path instead of :subprocess_path (feels clumsy)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah, but I thought path resonates more with Activity::Path and we allow Railway and FastTrack too 😄

Having subprocess in it makes intent clear, how about just subprocess or subprocesses ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants