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
4 changes: 0 additions & 4 deletions lib/generators/fx/function/function_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def migration_class_name
end
end

def active_record_migration_class
migration_helper.active_record_migration_class
end

def formatted_name
NameHelper.format_for_migration(singular_name)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class <%= migration_class_name %> < <%= active_record_migration_class %>
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
create_function <%= formatted_name %>
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class <%= migration_class_name %> < <%= active_record_migration_class %>
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
update_function <%= formatted_name %>, version: <%= version %>, revert_to_version: <%= previous_version %>
end
Expand Down
8 changes: 0 additions & 8 deletions lib/generators/fx/migration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ def skip_creation?
!should_create_migration?
end

def active_record_migration_class
if ActiveRecord::Migration.respond_to?(:current_version)
"ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]"
else
"ActiveRecord::Migration"
end
end

def update_migration_class_name(object_type:, class_name:, version:)
"Update#{object_type.capitalize}#{class_name}ToVersion#{version}"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class <%= migration_class_name %> < <%= active_record_migration_class %>
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
create_trigger <%= formatted_name %>, on: <%= formatted_table_name %>
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class <%= migration_class_name %> < <%= active_record_migration_class %>
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
def change
update_trigger <%= formatted_name %>, on: <%= formatted_table_name %>, version: <%= version %>, revert_to_version: <%= previous_version %>
end
Expand Down
4 changes: 0 additions & 4 deletions lib/generators/fx/trigger/trigger_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ def migration_class_name
end
end

def active_record_migration_class
migration_helper.active_record_migration_class
end

def formatted_name
NameHelper.format_for_migration(singular_name)
end
Expand Down
25 changes: 0 additions & 25 deletions spec/generators/fx/migration_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@
end
end

describe "#active_record_migration_class" do
it "returns versioned migration class when current_version is available" do
allow(ActiveRecord::Migration).to receive(:current_version)
.and_return(7.0)

helper = described_class.new({})

expect(helper.active_record_migration_class).to eq(
"ActiveRecord::Migration[7.0]"
)
end

it "returns base migration class when current_version is not available" do
allow(ActiveRecord::Migration).to receive(:respond_to?)
.with(:current_version)
.and_return(false)

helper = described_class.new({})

expect(helper.active_record_migration_class).to eq(
"ActiveRecord::Migration"
)
end
end

describe "#update_migration_class_name" do
it "generates correct class name for functions" do
helper = described_class.new({})
Expand Down