From 86d090c83c136569c619acfb2f5d2ab3492e0c72 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 19 Aug 2024 01:04:09 +0900 Subject: [PATCH] This models is directly invoked via graph_test.rb so this model has to cover both old and new enum syntax --- test/dummy/app/models/bug.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/dummy/app/models/bug.rb b/test/dummy/app/models/bug.rb index 8c4d05f..d963b57 100644 --- a/test/dummy/app/models/bug.rb +++ b/test/dummy/app/models/bug.rb @@ -3,7 +3,7 @@ class Bug < ActiveRecord::Base belongs_to :assigned_to, class_name: 'User' - enum :status, {unassigned: 0, assigned: 1, resolved: 2, closed: 3} do + block = ->(_) { event :assign do transition :unassigned => :assigned, if: -> { !!assigned_to } end @@ -27,6 +27,12 @@ class Bug < ActiveRecord::Base transition all - [:closed] => :closed end + } + + if Rails::VERSION::MAJOR >= 7 + enum :status, {unassigned: 0, assigned: 1, resolved: 2, closed: 3}, &block + else + enum status: {unassigned: 0, assigned: 1, resolved: 2, closed: 3}, &block end class Notifier