Skip to content

Commit 5ba986e

Browse files
committed
resume work
1 parent adabb8a commit 5ba986e

53 files changed

Lines changed: 1719 additions & 1544 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copy this file to .env and update with your database connection strings
2+
3+
# PostgreSQL primary database
4+
DATABASE_URL_PG=postgresql://closure_tree:closure_tree_pass@localhost:5434/closure_tree_test
5+
6+
# MySQL secondary database
7+
DATABASE_URL_MYSQL=mysql2://closure_tree:closure_tree_pass@localhost:3367/closure_tree_test
8+
9+
# SQLite database (optional, in-memory by default)
10+
# DATABASE_URL_SQLITE3=sqlite3:closure_tree_test.db

.release-please-manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
12
{".":"8.0.0"}

Gemfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
44

55
gemspec
66

7+
gem 'dotenv'
78
gem 'railties'
89
gem 'with_advisory_lock', github: 'closuretree/with_advisory_lock'
910

@@ -16,9 +17,8 @@ platforms :ruby, :truffleruby do
1617
gem 'sqlite3'
1718
end
1819

19-
platform :jruby do
20-
# JRuby-specific gems
21-
gem 'activerecord-jdbcmysql-adapter'
22-
gem 'activerecord-jdbcpostgresql-adapter'
23-
gem 'activerecord-jdbcsqlite3-adapter'
20+
# Testing gems
21+
group :test do
22+
gem 'maxitest'
23+
gem 'mocha'
2424
end

README.md

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ closure_tree has some great features:
2424
* 2 SQL INSERTs on node creation
2525
* 3 SQL INSERT/UPDATEs on node reparenting
2626
* __Support for [concurrency](#concurrency)__ (using [with_advisory_lock](https://github.com/ClosureTree/with_advisory_lock))
27-
* __Tested against ActiveRecord 7.1+ with Ruby 3.3+__
27+
* __Tested against ActiveRecord 7.2+ with Ruby 3.3+__
2828
* Support for reparenting children (and all their descendants)
2929
* Support for [single-table inheritance (STI)](#sti) within the hierarchy
3030
* ```find_or_create_by_path``` for [building out heterogeneous hierarchies quickly and conveniently](#find_or_create_by_path)
@@ -52,7 +52,7 @@ for a description of different tree storage algorithms.
5252

5353
## Installation
5454

55-
Note that closure_tree only supports ActiveRecord 7.1 and later, and has test coverage for MySQL, PostgreSQL, and SQLite.
55+
Note that closure_tree only supports ActiveRecord 7.2 and later, and has test coverage for MySQL, PostgreSQL, and SQLite.
5656

5757
1. Add `gem 'closure_tree'` to your Gemfile
5858

@@ -629,57 +629,37 @@ Upgrade to MySQL 5.7.12 or later if you see [this issue](https://github.com/Clos
629629
630630
## Testing with Closure Tree
631631
632-
Closure tree comes with some RSpec2/3 matchers which you may use for your tests:
632+
Closure tree comes with test matchers which you may use in your tests:
633633
634634
```ruby
635-
require 'spec_helper'
635+
require 'test_helper'
636636
require 'closure_tree/test/matcher'
637637
638-
describe Category do
639-
# Should syntax
640-
it { should be_a_closure_tree }
641-
# Expect syntax
642-
it { is_expected.to be_a_closure_tree }
643-
end
644-
645-
describe Label do
646-
# Should syntax
647-
it { should be_a_closure_tree.ordered }
648-
# Expect syntax
649-
it { is_expected.to be_a_closure_tree.ordered }
650-
end
651-
652-
describe TodoList::Item do
653-
# Should syntax
654-
it { should be_a_closure_tree.ordered(:priority_order) }
655-
# Expect syntax
656-
it { is_expected.to be_a_closure_tree.ordered(:priority_order) }
638+
class CategoryTest < ActiveSupport::TestCase
639+
test "should be a closure tree" do
640+
assert Category.new.is_a?(ClosureTree::Model)
641+
end
657642
end
658-
659643
```
660644
661645
## Testing
662646
663647
Closure tree is [tested under every valid combination](https://github.com/ClosureTree/closure_tree/blob/master/.github/workflows/ci.yml) of
664648
665649
* Ruby 3.3+
666-
* ActiveRecord 7.1+
650+
* ActiveRecord 7.2+
667651
* PostgreSQL, MySQL, and SQLite. Concurrency tests are only run with MySQL and PostgreSQL.
668652
669653
```shell
670654
$ bundle
671-
$ appraisal bundle # this will install the matrix of dependencies
672-
$ appraisal rake # this will run the tests in all combinations
673-
$ appraisal activerecord-7.0 rake # this will run the tests in AR 7.0 only
674-
$ appraisal activerecord-7.0 rake spec # this will run rspec in AR 7.0 only
675-
$ appraisal activerecord-7.0 rake test # this will run minitest in AR 7.0 only
655+
$ rake test # this will run the tests
676656
```
677657
678658
By default the test are run with sqlite3 only.
679659
You run test with other databases by passing the database url as environment variable:
680660
681661
```shell
682-
$ DATABASE_URL=postgres://localhost/my_database appraisal activerecord-7.0 rake test
662+
$ DATABASE_URL=postgres://localhost/my_database rake test
683663
```
684664
685665
## Change log

Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace :test do
2424
end
2525
end
2626

27-
2827
require_relative 'test/dummy/config/application'
2928

30-
Rails.application.load_tasks
29+
Rails.application.load_tasks

bin/appraisal

Lines changed: 0 additions & 29 deletions
This file was deleted.

bin/rails

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
1212
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
1313

1414
require 'rails/all'
15-
require 'rails/engine/commands'
15+
require 'rails/engine/commands'

bin/rake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
require 'pathname'
12+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13+
Pathname.new(__FILE__).realpath)
1414

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
15+
bundle_binstub = File.expand_path('bundle', __dir__)
1616

1717
if File.file?(bundle_binstub)
1818
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
@@ -23,7 +23,7 @@ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this
2323
end
2424
end
2525

26-
require "rubygems"
27-
require "bundler/setup"
26+
require 'rubygems'
27+
require 'bundler/setup'
2828

29-
load Gem.bin_path("rake", "rake")
29+
load Gem.bin_path('rake', 'rake')

bin/rspec

Lines changed: 0 additions & 29 deletions
This file was deleted.

closure_tree.gemspec

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ Gem::Specification.new do |gem|
99
gem.email = %w[matthew+github@mceachen.org terminale@gmail.com]
1010
gem.homepage = 'https://github.com/ClosureTree/closure_tree/'
1111

12-
gem.summary = %q(Easily and efficiently make your ActiveRecord model support hierarchies)
12+
gem.summary = 'Easily and efficiently make your ActiveRecord model support hierarchies'
1313
gem.license = 'MIT'
1414

1515
gem.metadata = {
16-
'bug_tracker_uri' => "https://github.com/ClosureTree/closure_tree/issues",
17-
'changelog_uri' => "https://github.com/ClosureTree/closure_tree/blob/master/CHANGELOG.md",
16+
'bug_tracker_uri' => 'https://github.com/ClosureTree/closure_tree/issues',
17+
'changelog_uri' => 'https://github.com/ClosureTree/closure_tree/blob/master/CHANGELOG.md',
1818
'documentation_uri' => "https://www.rubydoc.info/gems/closure_tree/#{gem.version}",
19-
'homepage_uri' => "https://closuretree.github.io/closure_tree/",
20-
'source_code_uri' => "https://github.com/ClosureTree/closure_tree",
19+
'homepage_uri' => 'https://closuretree.github.io/closure_tree/',
20+
'source_code_uri' => 'https://github.com/ClosureTree/closure_tree',
21+
'rubygems_mfa_required' => 'true'
2122
}
2223

23-
gem.files = `git ls-files`.split($/).reject do |f|
24-
f.match(%r{^(test|img|gemfiles)})
24+
gem.files = `git ls-files`.split($/).reject do |f|
25+
f.match(/^(test|img|gemfiles)/)
2526
end
2627

27-
gem.test_files = gem.files.grep(%r{^test/})
2828
gem.required_ruby_version = '>= 3.3.0'
2929

30-
gem.add_runtime_dependency 'activerecord', '>= 7.1.0'
31-
gem.add_runtime_dependency 'with_advisory_lock', '>= 6.0.0'
30+
gem.add_dependency 'activerecord', '>= 7.2.0'
31+
gem.add_dependency 'with_advisory_lock', '>= 7.0.0'
3232

3333
gem.add_development_dependency 'database_cleaner'
34-
gem.add_development_dependency 'parallel'
3534
gem.add_development_dependency 'minitest'
3635
gem.add_development_dependency 'minitest-reporters'
36+
gem.add_development_dependency 'parallel'
3737
gem.add_development_dependency 'simplecov'
3838
gem.add_development_dependency 'timecop'
3939
# gem.add_development_dependency 'byebug'

0 commit comments

Comments
 (0)