Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Dec 6, 2024
1 parent 6d6327e commit 3099672
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/operation/contract_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class Form < Reform::Form
->(*) { validate(options["params"][:song]) } # <-- TODO
end

class UpdateHit < Update
step Contract::Persist( method: :sync ), id: 'persist.syncer'
step Contract::Persist()
end

# success
it do
result = Update.(params: {title: "SVG"})
Expand All @@ -38,6 +43,12 @@ class Form < Reform::Form
result[:"result.contract.default"].errors.messages.must_equal({:title=>["can't be blank"]})
end

# override id
it 'override id' do
railway = Trailblazer::Developer.railway(UpdateHit)
assert_equal railway, %([>model.build,>contract.build,>contract.default.validate,>persist.syncer,>persist.save])
end

#---
# Contract::Validate[key: :song]
class Upsert < Trailblazer::Operation
Expand Down
2 changes: 1 addition & 1 deletion trailblazer-macro-contract.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
spec.email = ["[email protected]"]
spec.description = 'Operation macros for form objects'
spec.summary = 'Macros for form objects: Build, Validate, Persist'
spec.homepage = "http://trailblazer.to"
spec.homepage = "https://trailblazer.to"
spec.license = "LGPL-3.0"

spec.files = `git ls-files -z`.split("\x0").reject do |f|
Expand Down

0 comments on commit 3099672

Please sign in to comment.