diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7c4279c..850e6e2 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -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 }} diff --git a/lib/active_record/postgres_enum/extensions.rb b/lib/active_record/postgres_enum/extensions.rb index 049411a..ba74c20 100644 --- a/lib/active_record/postgres_enum/extensions.rb +++ b/lib/active_record/postgres_enum/extensions.rb @@ -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 diff --git a/spec/active_record/postgres_enum_spec.rb b/spec/active_record/postgres_enum_spec.rb index d03d997..22e76a9 100644 --- a/spec/active_record/postgres_enum_spec.rb +++ b/spec/active_record/postgres_enum_spec.rb @@ -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