Skip to content

Commit e219ffa

Browse files
committed
Drop outdated Rubies and Rails, add Rails 7.1
1 parent ff5cde5 commit e219ffa

File tree

10 files changed

+81
-122
lines changed

10 files changed

+81
-122
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,21 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
ruby_version:
15-
- '2.5'
16-
- '2.6'
17-
- '2.7'
1815
- '3.0'
16+
- '3.1'
17+
- '3.2'
1918
gemfile:
20-
- gemfiles/rails_5_0.gemfile
21-
- gemfiles/rails_5_1.gemfile
22-
- gemfiles/rails_5_2.gemfile
23-
- gemfiles/rails_6_0.gemfile
2419
- gemfiles/rails_6_1.gemfile
2520
- gemfiles/rails_7_0.gemfile
26-
exclude:
27-
- ruby_version: '2.5'
28-
gemfile: gemfiles/rails_7_0.gemfile
29-
- ruby_version: '2.6'
30-
gemfile: gemfiles/rails_7_0.gemfile
31-
- ruby_version: '3.0'
32-
gemfile: gemfiles/rails_5_0.gemfile
33-
- ruby_version: '3.0'
34-
gemfile: gemfiles/rails_5_1.gemfile
35-
- ruby_version: '3.0'
36-
gemfile: gemfiles/rails_5_2.gemfile
21+
- gemfiles/rails_7_1.gemfile
3722

3823
name: Ruby ${{ matrix.ruby_version }} / Gemfile ${{ matrix.gemfile }}
3924

4025
env:
4126
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
4227

4328
steps:
44-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
4530

4631
- name: Setup Ruby
4732
uses: ruby/setup-ruby@v1
@@ -50,4 +35,6 @@ jobs:
5035
bundler-cache: true
5136

5237
- name: RSpec
38+
env:
39+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
5340
run: bundle exec rake

Appraisals

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1-
appraise "rails-7-0" do
2-
gem "activerecord", "~> 7.0.0"
3-
gem "sqlite3", "~> 1.4"
1+
appraise 'rails-7-1' do
2+
gem 'activerecord', '~> 7.1.0'
3+
gem 'sqlite3', '~> 1.4'
44
end
55

6-
appraise "rails-6-1" do
7-
gem "activerecord", "~> 6.1.2"
8-
gem "sqlite3", "~> 1.4"
6+
appraise 'rails-7-0' do
7+
gem 'activerecord', '~> 7.0.0'
8+
gem 'sqlite3', '~> 1.4'
99
end
1010

11-
appraise "rails-6-0" do
12-
gem "activerecord", "~> 6.0.3.5"
13-
gem "sqlite3", "~> 1.4"
14-
end
15-
16-
appraise "rails-5-2" do
17-
gem "activerecord", "~> 5.2.4.2"
18-
gem "sqlite3", "~> 1.3", ">= 1.3.6"
19-
end
20-
21-
appraise "rails-5-1" do
22-
gem "activerecord", "~> 5.1.7"
23-
gem "sqlite3", "~> 1.3", ">= 1.3.6"
24-
end
25-
26-
appraise "rails-5-0" do
27-
gem "activerecord", "~> 5.0.7.2"
28-
gem 'sqlite3', '~> 1.3.6'
11+
appraise 'rails-6-1' do
12+
gem 'activerecord', '~> 6.1.2'
13+
gem 'sqlite3', '~> 1.4'
2914
end

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016-2021 Georg Ledermann
3+
Copyright (c) 2016-2023 Georg Ledermann
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ This Ruby gem enhances `ActiveRecord::Base` to save a draft version of the curre
1818

1919
## Requirements
2020

21-
* Ruby 2.5 or newer
22-
* ActiveRecord 5.0 or newer (including 7.0)
23-
21+
- Ruby 3.0 or newer
22+
- ActiveRecord 6.1 or newer (including 7.1)
2423

2524
## Installation
2625

drafting.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ Gem::Specification.new do |spec|
66
spec.name = "drafting"
77
spec.version = Drafting::VERSION
88
spec.authors = ["Georg Ledermann"]
9-
spec.email = ["mail@georg-ledermann.de"]
9+
spec.email = ["georg@ledermann.dev"]
1010

1111
spec.summary = %q{Save draft version of any ActiveRecord object}
1212
spec.description = %q{}
1313
spec.homepage = "https://github.com/ledermann/drafting"
1414
spec.license = "MIT"
15-
spec.required_ruby_version = '>= 2.5'
15+
spec.required_ruby_version = '>= 3.0'
1616

1717
spec.files = `git ls-files`.split($/)
1818
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1919
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
2020
spec.require_paths = ["lib"]
2121

22-
spec.add_dependency "activerecord", ">= 5.0"
22+
spec.add_dependency "activerecord", ">= 6.1"
2323

2424
spec.add_development_dependency "bundler"
2525
spec.add_development_dependency "rake"
2626
spec.add_development_dependency "rspec"
2727
spec.add_development_dependency "sqlite3"
2828
spec.add_development_dependency "factory_bot"
29-
spec.add_development_dependency "coveralls"
29+
spec.add_development_dependency "coveralls_reborn"
3030
spec.add_development_dependency "simplecov"
3131
spec.add_development_dependency "appraisal"
3232
spec.add_development_dependency "generator_spec"

gemfiles/rails_7_1.gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "activerecord", "~> 7.1.0"
6+
gem "sqlite3", "~> 1.4"
7+
8+
gemspec path: "../"

lib/drafting.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@
88

99
ActiveRecord::Base.extend Drafting::BaseClassMethods
1010

11-
Drafting::MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
12-
ActiveRecord::Migration[5.0]
13-
else
14-
ActiveRecord::Migration
15-
end
11+
Drafting::MIGRATION_BASE_CLASS = ActiveRecord::Migration[6.1]

lib/generators/drafting/migration/migration_generator.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ def create_migration_file
1414
end
1515

1616
def self.next_migration_number(dirname)
17-
if ActiveRecord::Base.timestamped_migrations
18-
# ensure timestamp of the multiple migration files generated
19-
# will be different
20-
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
21-
timestamp += 1 if current_migration_number(dirname) == timestamp
17+
# ensure timestamp of the multiple migration files generated
18+
# will be different
19+
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
20+
timestamp += 1 if current_migration_number(dirname) == timestamp
2221

23-
timestamp
24-
else
25-
"%.3d" % (current_migration_number(dirname) + 1)
26-
end
22+
timestamp
2723
end
2824
end
2925
end

lib/generators/drafting/migration/templates/non_user_migration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class NonUserDraftingMigration < Drafting::MIGRATION_BASE_CLASS
22
def self.up
3-
add_column :drafts, :user_type, :string, index: true
3+
add_column :drafts, :user_type, :string
4+
add_index :drafts, :user_type
45

56
# add in user_type for existing drafts table
67
# for migration from old version

spec/lib/generators/drafting/migration/migration_generator_spec.rb

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,65 @@
44

55
module Drafting
66
describe MigrationGenerator, type: :generator do
7-
root_dir = File.expand_path("../../../../../../tmp", __FILE__)
7+
root_dir = File.expand_path('../../../../../../tmp', __FILE__)
88
destination root_dir
99

10-
[
11-
{
12-
configuration: 'timestamped migrations',
13-
timestamped_migrations: true
14-
},
15-
{
16-
configuration: 'numeric prefix migrations',
17-
timestamped_migrations: false
18-
}
19-
].each do |test_suite|
20-
describe test_suite[:configuration] do
10+
describe 'timestamped migrations' do
11+
describe 'new app' do
2112
before :each do
22-
ActiveRecord::Base.timestamped_migrations = test_suite[:timestamped_migrations]
13+
prepare_destination
14+
run_generator
2315
end
2416

25-
describe 'new app' do
26-
before :each do
27-
prepare_destination
28-
run_generator
29-
end
17+
it 'creates two installation db migration' do
18+
migration_files =
19+
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
3020

31-
it "creates two installation db migration" do
32-
migration_files =
33-
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
21+
assert_equal migration_files.count, 2
3422

35-
assert_equal migration_files.count, 2
36-
37-
assert_file migration_files[0],
38-
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
39-
assert_file migration_files[1],
40-
/class NonUserDraftingMigration < Drafting::MIGRATION_BASE_CLASS/
41-
end
23+
assert_file migration_files[0],
24+
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
25+
assert_file migration_files[1],
26+
/class NonUserDraftingMigration < Drafting::MIGRATION_BASE_CLASS/
27+
end
4228

43-
it "creates migration files of different timestamp" do
44-
migration_files =
45-
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
29+
it 'creates migration files of different timestamp' do
30+
migration_files =
31+
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
4632

47-
migration_no1 = File.basename(migration_files[0]).split("_").first
48-
migration_no2 = File.basename(migration_files[1]).split("_").first
33+
migration_no1 = File.basename(migration_files[0]).split('_').first
34+
migration_no2 = File.basename(migration_files[1]).split('_').first
4935

50-
assert_not_equal migration_no1, migration_no2
51-
end
36+
assert_not_equal migration_no1, migration_no2
5237
end
38+
end
5339

54-
describe 'existing app' do
55-
before :each do
56-
prepare_destination
57-
run_generator
58-
FileUtils.rm Dir.glob("#{root_dir}/db/migrate/*non_user_drafting_migration.rb")
40+
describe 'existing app' do
41+
before :each do
42+
prepare_destination
43+
run_generator
44+
FileUtils.rm Dir.glob(
45+
"#{root_dir}/db/migrate/*non_user_drafting_migration.rb",
46+
)
5947

60-
migration_files =
61-
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
62-
expect(migration_files.count).to eq 1
63-
assert_file migration_files[0],
64-
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
48+
migration_files =
49+
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
50+
expect(migration_files.count).to eq 1
51+
assert_file migration_files[0],
52+
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
6553

66-
run_generator
67-
end
54+
run_generator
55+
end
6856

69-
it "creates only one more db migration" do
70-
migration_files =
71-
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
72-
expect(migration_files.count).to eq 2
57+
it 'creates only one more db migration' do
58+
migration_files =
59+
Dir.glob("#{root_dir}/db/migrate/*drafting*.rb").sort
60+
expect(migration_files.count).to eq 2
7361

74-
assert_file migration_files[0],
75-
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
76-
assert_file migration_files[1],
77-
/class NonUserDraftingMigration < Drafting::MIGRATION_BASE_CLASS/
78-
end
62+
assert_file migration_files[0],
63+
/class DraftingMigration < Drafting::MIGRATION_BASE_CLASS/
64+
assert_file migration_files[1],
65+
/class NonUserDraftingMigration < Drafting::MIGRATION_BASE_CLASS/
7966
end
8067
end
8168
end

0 commit comments

Comments
 (0)