Skip to content

Commit

Permalink
Merge pull request #51 from seuros/fix2
Browse files Browse the repository at this point in the history
chore: cleanup tests
  • Loading branch information
apotonick authored May 24, 2024
2 parents cf3ebf9 + f7546f4 commit f0bf06b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test/docs/guard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def process(options, **)
end
#:proc end

it { Create.(pass: false)[:x].must_be_nil }
it { assert_nil Create.(pass: false)[:x] }

it { assert_equal Create.(pass: true)[:x], true }

Expand Down Expand Up @@ -59,7 +59,7 @@ def process(options, **)
end
#:callable-op end

it { Create.(pass: false)[:x].must_be_nil }
it { assert_nil Create.(pass: false)[:x] }

it { assert_equal Create.(pass: true)[:x], true }
end
Expand Down
12 changes: 6 additions & 6 deletions test/operation/pundit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ def process(options, **)
assert_equal result[:process], true
#- result object, policy
assert_equal result[:"result.policy.default"].success?, true
result[:"result.policy.default"][:message].must_be_nil
assert_nil result[:"result.policy.default"][:message]
# result[:valid].must_be_nil
assert_equal result[:"policy.default"].inspect, %{<Auth: user:Module, model:nil>}
end
# breach.
it do
result = Create.(params: {}, current_user: nil)
result[:process].must_be_nil
assert_nil result[:process]
#- result object, policy
assert_equal result[:"result.policy.default"].success?, false
assert_equal result[:"result.policy.default"][:message], "Breach"
end
# inject different policy.Condition it { Create.(params: {}, current_user: Object, "policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))["process"], true }
it { Create.(params: {}, current_user: Module, :"policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))[:process].must_be_nil }
it { assert_nil Create.(params: {}, current_user: Module, :"policy.default.eval" => Trailblazer::Operation::Policy::Pundit::Condition.new(Auth, :user_object?))[:process] }


#---
Expand All @@ -58,7 +58,7 @@ class Show < Create
# invalid because user AND model.
it do
result = Show.(params: {}, current_user: Module)
result[:process].must_be_nil
assert_nil result[:process]

assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=nil>}
# result["policy"].inspect, %{#<struct PolicyTest::Song id=nil>}
Expand Down Expand Up @@ -93,7 +93,7 @@ def process(options, **)
assert_equal result[:process], true
assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=1>}
assert_equal result[:"result.policy.default"].success?, true
result[:"result.policy.default"][:message].must_be_nil
assert_nil result[:"result.policy.default"][:message]
# result[:valid].must_be_nil
assert_equal result[:"policy.default"].inspect, %{<Auth: user:Module, model:#<struct PolicyTest::Song id=1>>}
end
Expand All @@ -103,7 +103,7 @@ def process(options, **)
result = Edit.(params: { id: 4 }, current_user: nil)

assert_equal result[:model].inspect, %{#<struct PolicyTest::Song id=4>}
result[:process].must_be_nil
assert_nil result[:process]

assert_equal result[:"result.policy.default"].success?, false
assert_equal result[:"result.policy.default"][:message], "Breach"
Expand Down

0 comments on commit f0bf06b

Please sign in to comment.