Skip to content

Commit

Permalink
Merge pull request #168 from jpmcgrath/165-generator
Browse files Browse the repository at this point in the history
Add spec for ShortenerGenerator
  • Loading branch information
fschwahn authored Feb 19, 2024
2 parents 95d06a5 + a589fee commit 0a7d557
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/shortener/shortener_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.source_root
end

def self.next_migration_number(dirname)
if ActiveRecord::Base.timestamped_migrations
if ActiveRecord.respond_to?(:timestamped_migrations) ? ActiveRecord.timestamped_migrations : ActiveRecord::Base.timestamped_migrations
Time.new.utc.strftime("%Y%m%d%H%M%S")
else
"%.3d" % (current_migration_number(dirname) + 1)
Expand Down
10 changes: 10 additions & 0 deletions spec/generators/shortener_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "spec_helper"
require File.expand_path("../../../lib/generators/shortener/shortener_generator.rb", __FILE__)

RSpec.describe ShortenerGenerator do
describe ".next_migration_number" do
it "returns the next migration number" do
expect { described_class.next_migration_number(".") }.not_to raise_error
end
end
end

0 comments on commit 0a7d557

Please sign in to comment.