Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '2.6', '2.7' ]
ruby: [ '2.6', '2.7', '3.0' ]
env:
RUBY_IMAGE: ${{ matrix.ruby }}
name: Ruby ${{ matrix.ruby }}
Expand Down
4 changes: 2 additions & 2 deletions lib/active_record/postgres_enum/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def register_enum_type(row)

module ColumnMethods # :nodoc:
# Enables `t.enum :my_field, enum_name: :my_enum_name` on migrations
def enum(name, options = {})
column(name, options.delete(:enum_name), options.except(:enum_name))
def enum(name, enum_name:, **options)
column(name, enum_name, **options)
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/active_record/postgres_enum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@
expect(connection.enums[:foo]).to eq %w[a1 b2]
end

it "creates table with enum column" do
expect do
connection.create_table :albums do |t|
t.enum :bar, enum_name: :foo
end
end.to_not raise_error

col = connection.columns(:albums).find { |c| c.name == "bar" }
expect(col).not_to be nil
expect(col.type).to eq :enum
expect(col.sql_type).to eq "foo"
end

it "adds an enum value to an existing table" do
expect { connection.add_column(:tracks, :bar, :foo) }.to_not raise_error

Expand Down