Skip to content

Commit 0881f1b

Browse files
committed
Test the Rails 7 new syntax
1 parent 52d082c commit 0881f1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/mechanic_machine_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,16 @@ def test_enum_definition_with_prefix_and_suffix
252252
assert_equal 'archived', tes.status
253253
end
254254
end
255+
256+
if Rails::VERSION::MAJOR >= 7
257+
def test_rails7_new_syntax
258+
ActiveRecord::Migration.create_table(:rails7) { |t| t.integer :status }
259+
tes = Class.new(ActiveRecord::Base) do
260+
self.table_name = 'rails7'
261+
enum(:status, [:active, :archived], prefix: 'prefix', suffix: 'suffix') { event(:archive) { transition(active: :archived) } }
262+
end.new status: :active
263+
tes.prefix_archive_suffix
264+
assert_equal 'archived', tes.status
265+
end
266+
end
255267
end

0 commit comments

Comments
 (0)