Skip to content

Commit

Permalink
feat(has_negated_result): use HasNegatedResult plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Jan 21, 2024
1 parent 11f8f0c commit 6cb4e48
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/convenient_service/service/configs/standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Standard
use ConvenientService::Plugins::Common::HasAroundCallbacks::Concern

use ConvenientService::Plugins::Service::HasNegatedResult::Concern
use ConvenientService::Plugins::Service::HasNegatedJSendResult::Concern
use ConvenientService::Plugins::Service::CanHaveFallbacks::Concern
use ConvenientService::Plugins::Service::HasMermaidFlowchart::Concern
end
Expand Down Expand Up @@ -93,6 +94,18 @@ module Standard
use ConvenientService::Plugins::Service::CanHaveFallbacks::Middleware.with(status: :error)
end

##
# @internal
# NOTE: Check `Minimal` docs to understand why `use ConvenientService::Plugins::Common::NormalizesEnv::Middleware` for `:negated_result` is used in `Standard`, not in `Minimal` config.
#
middlewares :negated_result do
use ConvenientService::Plugins::Common::NormalizesEnv::Middleware
use ConvenientService::Plugins::Service::CollectsServicesInException::Middleware
use ConvenientService::Plugins::Common::CachesReturnValue::Middleware

use ConvenientService::Plugins::Service::HasNegatedJSendResult::Middleware
end

middlewares :step do
use ConvenientService::Plugins::Common::HasCallbacks::Middleware
use ConvenientService::Plugins::Common::HasAroundCallbacks::Middleware
Expand Down
1 change: 1 addition & 0 deletions lib/convenient_service/service/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require_relative "plugins/has_negated_result"

require_relative "plugins/has_j_send_result"
require_relative "plugins/has_negated_j_send_result"

require_relative "plugins/can_recalculate_result"
require_relative "plugins/can_have_method_steps"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@
end
end

example_group "#negated_result middlewares" do
let(:negated_result_middlewares) do
[
ConvenientService::Common::Plugins::NormalizesEnv::Middleware,
ConvenientService::Service::Plugins::CollectsServicesInException::Middleware,
ConvenientService::Common::Plugins::CachesReturnValue::Middleware,
ConvenientService::Service::Plugins::HasNegatedJSendResult::Middleware
]
end

it "sets service middlewares for `#negated_result`" do
expect(service_class.middlewares(:negated_result).to_a).to eq(negated_result_middlewares)
end
end

example_group "#step middlewares" do
let(:step_middlewares) do
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
ConvenientService::Common::Plugins::HasCallbacks::Concern,
ConvenientService::Common::Plugins::HasAroundCallbacks::Concern,
ConvenientService::Service::Plugins::HasNegatedResult::Concern,
ConvenientService::Service::Plugins::HasNegatedJSendResult::Concern,
ConvenientService::Service::Plugins::CanHaveFallbacks::Concern,
ConvenientService::Service::Plugins::HasMermaidFlowchart::Concern,
ConvenientService::Common::Plugins::AssignsAttributesInConstructor::UsingActiveModelAttributeAssignment::Concern,
Expand Down Expand Up @@ -133,6 +134,21 @@
end
end

example_group "#negated_result middlewares" do
let(:negated_result_middlewares) do
[
ConvenientService::Common::Plugins::NormalizesEnv::Middleware,
ConvenientService::Service::Plugins::CollectsServicesInException::Middleware,
ConvenientService::Common::Plugins::CachesReturnValue::Middleware,
ConvenientService::Service::Plugins::HasNegatedJSendResult::Middleware
]
end

it "sets service middlewares for `#negated_result`" do
expect(service_class.middlewares(:negated_result).to_a).to eq(negated_result_middlewares)
end
end

example_group "#step middlewares" do
let(:step_middlewares) do
[
Expand Down
16 changes: 16 additions & 0 deletions spec/lib/convenient_service/service/configs/standard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
ConvenientService::Common::Plugins::HasCallbacks::Concern,
ConvenientService::Common::Plugins::HasAroundCallbacks::Concern,
ConvenientService::Service::Plugins::HasNegatedResult::Concern,
ConvenientService::Service::Plugins::HasNegatedJSendResult::Concern,
ConvenientService::Service::Plugins::CanHaveFallbacks::Concern,
ConvenientService::Service::Plugins::HasMermaidFlowchart::Concern
]
Expand Down Expand Up @@ -126,6 +127,21 @@
end
end

example_group "#negated_result middlewares" do
let(:negated_result_middlewares) do
[
ConvenientService::Common::Plugins::NormalizesEnv::Middleware,
ConvenientService::Service::Plugins::CollectsServicesInException::Middleware,
ConvenientService::Common::Plugins::CachesReturnValue::Middleware,
ConvenientService::Service::Plugins::HasNegatedJSendResult::Middleware
]
end

it "sets service middlewares for `#negated_result`" do
expect(service_class.middlewares(:negated_result).to_a).to eq(negated_result_middlewares)
end
end

example_group "#step middlewares" do
let(:step_middlewares) do
[
Expand Down

0 comments on commit 6cb4e48

Please sign in to comment.