Skip to content

Commit c46c513

Browse files
committed
ninit
1 parent 1b07d5b commit c46c513

31 files changed

+1036
-897
lines changed

Appraisals

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

Gemfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,12 @@ source 'https://rubygems.org'
44

55
gemspec
66

7-
gem 'with_advisory_lock', github: 'closuretree/with_advisory_lock'
7+
gem 'with_advisory_lock', github: 'closuretree/with_advisory_lock'
8+
gem 'railties'
9+
# Test with ActiveRecord 7.1 directly
10+
gem 'activerecord', '~> 7.1.0'
11+
12+
# Database adapters
13+
gem 'sqlite3'
14+
gem 'pg'
15+
gem 'mysql2'

bin/rails

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
5+
require_relative '../test/dummy/config/boot'
6+
require 'rails/commands'

closure_tree.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Gem::Specification.new do |gem|
3030
gem.add_runtime_dependency 'activerecord', '>= 7.1.0'
3131
gem.add_runtime_dependency 'with_advisory_lock', '>= 6.0.0'
3232

33-
gem.add_development_dependency 'appraisal'
3433
gem.add_development_dependency 'database_cleaner'
3534
gem.add_development_dependency 'parallel'
3635
gem.add_development_dependency 'minitest'

gemfiles/activerecord_7.1.gemfile

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

gemfiles/activerecord_7.2.gemfile

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

gemfiles/activerecord_8.0.gemfile

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

gemfiles/activerecord_edge.gemfile

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

test/closure_tree/tag_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require 'test_helper'
44
require 'support/tag_examples'
55

6-
describe Tag do
6+
class TagTest < ActiveSupport::TestCase
7+
TAG_CLASS = Tag
78
include TagExamples
8-
end
9+
end

test/dummy/Rakefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
# Add your own tasks in files placed in lib/tasks ending in .rake,
4+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5+
6+
require_relative 'config/application'
7+
8+
Rails.application.load_tasks
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class ApplicationController < ActionController::Base
4+
# Prevent CSRF attacks by raising an exception.
5+
# For APIs, you may want to use :null_session instead.
6+
protect_from_forgery with: :exception
7+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
class ApplicationRecord < ActiveRecord::Base
4+
self.abstract_class = true
5+
establish_connection(:primary)
6+
end

test/dummy/app/models/label.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
class Label < ApplicationRecord
4+
end

test/dummy/app/models/mysql_label.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
class MysqlLabel < MysqlRecord
4+
self.table_name = 'mysql_labels'
5+
end

test/dummy/app/models/mysql_record.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
class MysqlRecord < ActiveRecord::Base
4+
self.abstract_class = true
5+
establish_connection :secondary
6+
end

test/dummy/app/models/mysql_tag.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
class MysqlTag < MysqlRecord
4+
self.table_name = 'mysql_tags'
5+
6+
after_save do
7+
MysqlTagAudit.create(tag_name: name)
8+
MysqlLabel.create(name: name)
9+
end
10+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
class MysqlTagAudit < MysqlRecord
4+
self.table_name = 'mysql_tag_audits'
5+
end

test/dummy/app/models/tag.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
class Tag < ApplicationRecord
4+
after_save do
5+
TagAudit.create(tag_name: name)
6+
Label.create(name: name)
7+
end
8+
end

test/dummy/app/models/tag_audit.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
class TagAudit < ApplicationRecord
4+
end

test/dummy/config.ru

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'config/environment'
4+
5+
run Rails.application
6+
Rails.application.load_server

test/dummy/config/application.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
require_relative 'boot'
4+
5+
require 'rails'
6+
require 'active_record/railtie'
7+
require 'rails/test_unit/railtie'
8+
9+
Bundler.require(*Rails.groups)
10+
require 'closure_tree'
11+
12+
module Dummy
13+
class Application < Rails::Application
14+
config.load_defaults Rails::VERSION::STRING.to_f
15+
config.eager_load = false
16+
end
17+
end

test/dummy/config/boot.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# Set up gems listed in the Gemfile.
4+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
5+
6+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

test/dummy/config/database.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
test:
2+
adapter: sqlite3
3+
database: ":memory:"
4+
pool: 50
5+
timeout: 5000

test/dummy/config/environment.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# Load the Rails application.
4+
require_relative 'application'
5+
6+
# Initialize the Rails application.
7+
Rails.application.initialize!
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
Rails.application.configure do
4+
config.cache_classes = true
5+
config.eager_load = false
6+
config.consider_all_requests_local = true
7+
config.action_controller.perform_caching = false
8+
config.action_dispatch.show_exceptions = false
9+
config.active_support.deprecation = :stderr
10+
end

test/dummy/config/routes.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
Rails.application.routes.draw do
4+
end

test/dummy/db/schema.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
ActiveRecord::Schema.define(version: 1) do
4+
create_table 'tags', force: true do |t|
5+
t.string 'name'
6+
end
7+
8+
create_table 'tag_audits', id: false, force: true do |t|
9+
t.string 'tag_name'
10+
end
11+
12+
create_table 'labels', id: false, force: true do |t|
13+
t.string 'name'
14+
end
15+
end

test/dummy/db/secondary_schema.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
ActiveRecord::Schema.define(version: 1) do
4+
create_table 'mysql_tags', force: true do |t|
5+
t.string 'name'
6+
end
7+
8+
create_table 'mysql_tag_audits', id: false, force: true do |t|
9+
t.string 'tag_name'
10+
end
11+
12+
create_table 'mysql_labels', id: false, force: true do |t|
13+
t.string 'name'
14+
end
15+
end

test/dummy/lib/tasks/db.rake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
namespace :db do
4+
namespace :test do
5+
desc 'Load schema for all databases'
6+
task prepare: :environment do
7+
# Load schema for primary database
8+
ActiveRecord::Base.establish_connection(:primary)
9+
ActiveRecord::Schema.define(version: 1) do
10+
create_table 'tags', force: true do |t|
11+
t.string 'name'
12+
end
13+
14+
create_table 'tag_audits', id: false, force: true do |t|
15+
t.string 'tag_name'
16+
end
17+
18+
create_table 'labels', id: false, force: true do |t|
19+
t.string 'name'
20+
end
21+
end
22+
23+
# Load schema for secondary database
24+
ActiveRecord::Base.establish_connection(:secondary)
25+
ActiveRecord::Schema.define(version: 1) do
26+
create_table 'mysql_tags', force: true do |t|
27+
t.string 'name'
28+
end
29+
30+
create_table 'mysql_tag_audits', id: false, force: true do |t|
31+
t.string 'tag_name'
32+
end
33+
34+
create_table 'mysql_labels', id: false, force: true do |t|
35+
t.string 'name'
36+
end
37+
end
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)