From 9093abe8d0f039488d8a47e79a1de152b26fa8fb Mon Sep 17 00:00:00 2001 From: Misha Merkushin Date: Fri, 15 Jan 2021 17:33:34 +0300 Subject: [PATCH 1/2] tests: cover table creation --- spec/active_record/postgres_enum_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 From 34c8c9d5286bcc05957c7f74508ca3dc4cbd0a18 Mon Sep 17 00:00:00 2001 From: Misha Merkushin Date: Sun, 17 Jan 2021 12:16:50 +0300 Subject: [PATCH 2/2] chore: add ruby 3 --- .github/workflows/ruby.yml | 2 +- lib/active_record/postgres_enum/extensions.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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