From 3099672cad9b185153464135d30c78e354026dc1 Mon Sep 17 00:00:00 2001 From: Abdelkader Boudih Date: Fri, 6 Dec 2024 13:03:11 +0100 Subject: [PATCH] add tests --- test/operation/contract_test.rb | 11 +++++++++++ trailblazer-macro-contract.gemspec | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/operation/contract_test.rb b/test/operation/contract_test.rb index 6f19040..cb0504c 100644 --- a/test/operation/contract_test.rb +++ b/test/operation/contract_test.rb @@ -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"}) @@ -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 diff --git a/trailblazer-macro-contract.gemspec b/trailblazer-macro-contract.gemspec index bfcbe81..1e054d8 100644 --- a/trailblazer-macro-contract.gemspec +++ b/trailblazer-macro-contract.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.email = ["apotonick@gmail.com"] 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|