Skip to content

Release v6.0.1 #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2016
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
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ cache: bundler
sudo: false
language: ruby
rvm:
- 2.3.1
- 2.2.5
- 2.0
- 2.2.3
- jruby-head
- rbx

gemfile:
- gemfiles/activerecord_4.1.gemfile
- gemfiles/activerecord_4.2.gemfile
- gemfiles/activerecord_5.0.rc1.gemfile
- gemfiles/activerecord_5.0.gemfile
- gemfiles/activerecord_edge.gemfile

env:
- DB=sqlite
- DB=mysql
- DB=postgresql

#addons:
# postgresql: "9.3"

script: WITH_ADVISORY_LOCK_PREFIX=$TRAVIS_JOB_ID bundle exec rake --trace spec:all

matrix:
Expand All @@ -32,3 +30,5 @@ matrix:
exclude:
- rvm: ruby-head
gemfile: gemfiles/activerecord_4.1.gemfile
- rvm: 2.0
gemfile: gemfiles/activerecord_5.0.gemfile
7 changes: 2 additions & 5 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ appraise 'activerecord-4.2' do
end
end

appraise 'activerecord-5.0.rc1' do
gem 'activerecord', '~> 5.0.0.rc1'
gem 'actionpack', '~> 5.0.0.rc1'
gem 'railties', '~> 5.0.0.rc1'
gem 'rspec-rails', '>= 3.5.0.beta4'
appraise 'activerecord-5.0' do
gem 'activerecord', '~> 5.0.0'
end

appraise 'activerecord-edge' do
Expand Down
2 changes: 1 addition & 1 deletion MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012-2015 Matthew McEachen
Copyright (c) 2012-2016 Matthew McEachen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ closure_tree has some great features:
* 2 SQL INSERTs on node creation
* 3 SQL INSERT/UPDATEs on node reparenting
* __Support for [concurrency](#concurrency)__ (using [with_advisory_lock](https://github.com/mceachen/with_advisory_lock))
* __Support for ActiveRecord 4.1, 4.2 and 5.0.alpha__
* __Support for Ruby 2.0, 2.1, 2.2 and JRuby 9000__
* __Support for ActiveRecord 4.1, 4.2 and 5.0__
* __Support for Ruby 2.0, 2.1, 2.2, 2.3.1 and JRuby 9000__
* Support for reparenting children (and all their descendants)
* Support for [single-table inheritance (STI)](#sti) within the hierarchy
* ```find_or_create_by_path``` for [building out heterogeneous hierarchies quickly and conveniently](#find_or_create_by_path)
Expand Down Expand Up @@ -547,10 +547,11 @@ end

Closure tree is [tested under every valid combination](http://travis-ci.org/#!/mceachen/closure_tree) of

* Ruby 2.0 (and sometimes head)
* Ruby 2.2 (and sometimes head)
* Ruby 2.0
* Ruby 2.2
* Ruby 2.3.1 (and sometimes head)
* jRuby 9000 (and sometimes head)
* The latest ActiveRecord 4.1, 4.2, and master branch
* The latest ActiveRecord 4.1, 4.2, 5.0 and master branch
* Concurrency tests for MySQL and PostgreSQL. SQLite is tested in a single-threaded environment.

Assuming you're using [rbenv](https://github.com/sstephenson/rbenv), you can use ```tests.sh``` to
Expand Down
4 changes: 2 additions & 2 deletions closure_tree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'with_advisory_lock', '>= 3.0.0'

gem.add_development_dependency 'rspec-instafail'
gem.add_development_dependency 'rspec-rails', '~> 3.2.3'
gem.add_development_dependency 'rspec-rails'
gem.add_development_dependency 'database_cleaner'
gem.add_development_dependency 'appraisal'
gem.add_development_dependency 'timecop'
gem.add_development_dependency 'parallel'
gem.add_development_dependency 'ammeter', '1.1.2' # See https://github.com/mceachen/closure_tree/issues/181
# gem.add_development_dependency 'ammeter', '1.1.2' # See https://github.com/mceachen/closure_tree/issues/181
# gem.add_development_dependency 'byebug'
# gem.add_development_dependency 'ruby-prof' # <- don't need this normally.
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

source "https://rubygems.org"

gem "activerecord", "~> 5.0.0.rc1"
gem "actionpack", "~> 5.0.0.rc1"
gem "railties", "~> 5.0.0.rc1"
gem "rspec-rails", ">= 3.5.0.beta4"
gem "activerecord", "~> 5.0.0"

platforms :ruby, :rbx do
gem "mysql2"
Expand Down
2 changes: 1 addition & 1 deletion lib/closure_tree.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'active_support'
require 'active_record'

module ClosureTree
extend ActiveSupport::Autoload
Expand Down
2 changes: 1 addition & 1 deletion lib/closure_tree/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Configuration # :nodoc:
attr_accessor :database_less

def initialize
@database_less = false
@database_less = ENV['DATABASE_URL'].to_s.include?('//user:[email protected]/')
end
end
end
2 changes: 2 additions & 0 deletions lib/closure_tree/test/matcher.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'closure_tree'

module ClosureTree
module Test
module Matcher
Expand Down
2 changes: 1 addition & 1 deletion lib/closure_tree/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ClosureTree
VERSION = Gem::Version.new('6.0.0')
VERSION = Gem::Version.new('6.0.1')
end
96 changes: 48 additions & 48 deletions spec/generators/migration_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
require 'spec_helper'
require 'ammeter/init'

# Generators are not automatically loaded by Rails
require 'generators/closure_tree/migration_generator'

RSpec.describe ClosureTree::Generators::MigrationGenerator, type: :generator do
TMPDIR = Dir.mktmpdir
# Tell generator where to put its output
destination TMPDIR
before { prepare_destination }

describe 'generator output' do
before { run_generator %w(tag) }
subject { migration_file('db/migrate/create_tag_hierarchies.rb') }
it { is_expected.to be_a_migration }
it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
it { is_expected.to contain(/t.integer :generations, null: false/) }
it { is_expected.to contain(/add_index :tag_hierarchies/) }
end

describe 'generator output with namespaced model' do
before { run_generator %w(Namespace::Type) }
subject { migration_file('db/migrate/create_namespace_type_hierarchies.rb') }
it { is_expected.to be_a_migration }
it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
it { is_expected.to contain(/t.integer :generations, null: false/) }
it { is_expected.to contain(/add_index :namespace_type_hierarchies/) }
end

describe 'generator output with namespaced model with /' do
before { run_generator %w(namespace/type) }
subject { migration_file('db/migrate/create_namespace_type_hierarchies.rb') }
it { is_expected.to be_a_migration }
it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
it { is_expected.to contain(/t.integer :generations, null: false/) }
it { is_expected.to contain(/add_index :namespace_type_hierarchies/) }
end

it 'should run all tasks in generator without errors' do
gen = generator %w(tag)
expect(gen).to receive :create_migration_file
capture(:stdout) { gen.invoke_all }
end
end
# require 'spec_helper'
# require 'ammeter/init'
#
# # Generators are not automatically loaded by Rails
# require 'generators/closure_tree/migration_generator'
#
# RSpec.describe ClosureTree::Generators::MigrationGenerator, type: :generator do
# TMPDIR = Dir.mktmpdir
# # Tell generator where to put its output
# destination TMPDIR
# before { prepare_destination }
#
# describe 'generator output' do
# before { run_generator %w(tag) }
# subject { migration_file('db/migrate/create_tag_hierarchies.rb') }
# it { is_expected.to be_a_migration }
# it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
# it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
# it { is_expected.to contain(/t.integer :generations, null: false/) }
# it { is_expected.to contain(/add_index :tag_hierarchies/) }
# end
#
# describe 'generator output with namespaced model' do
# before { run_generator %w(Namespace::Type) }
# subject { migration_file('db/migrate/create_namespace_type_hierarchies.rb') }
# it { is_expected.to be_a_migration }
# it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
# it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
# it { is_expected.to contain(/t.integer :generations, null: false/) }
# it { is_expected.to contain(/add_index :namespace_type_hierarchies/) }
# end
#
# describe 'generator output with namespaced model with /' do
# before { run_generator %w(namespace/type) }
# subject { migration_file('db/migrate/create_namespace_type_hierarchies.rb') }
# it { is_expected.to be_a_migration }
# it { is_expected.to contain(/t.integer :ancestor_id, null: false/) }
# it { is_expected.to contain(/t.integer :descendant_id, null: false/) }
# it { is_expected.to contain(/t.integer :generations, null: false/) }
# it { is_expected.to contain(/add_index :namespace_type_hierarchies/) }
# end
#
# it 'should run all tasks in generator without errors' do
# gen = generator %w(tag)
# expect(gen).to receive :create_migration_file
# capture(:stdout) { gen.invoke_all }
# end
# end
8 changes: 1 addition & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
begin
require 'rspec'
rescue LoadError
# explciitly requiring rspec in ActiveRecord 5+ tests throws exception
end
require 'active_record'

require 'database_cleaner'
require 'closure_tree'
require 'closure_tree/test/matcher'
require 'tmpdir'
require 'timecop'
Expand Down
2 changes: 1 addition & 1 deletion spec/support/database.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
database_folder = "#{File.dirname(__FILE__)}/../db"
database_adapter = ENV['DB'] ||= 'mysql'
database_adapter = ENV['DB'] ||= 'postgresql'

def sqlite?
ENV['DB'] == 'sqlite'
Expand Down