nested_set 1.6.8 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +27 -0
- data/.travis.yml +21 -0
- data/Gemfile +16 -7
- data/README.md +2 -0
- data/Rakefile +5 -21
- data/lib/nested_set/base.rb +20 -12
- data/lib/nested_set/depth.rb +2 -2
- data/lib/nested_set/railtie.rb +2 -2
- data/lib/nested_set/version.rb +3 -0
- data/nested_set.gemspec +17 -78
- data/test/benchmarks.rb +2 -5
- data/test/db/schema.rb +2 -1
- data/test/fixtures/categories.yml +6 -6
- data/test/fixtures/category.rb +6 -4
- data/test/nested_set_test.rb +5 -3
- data/test/test_helper.rb +11 -10
- metadata +28 -43
- data/Gemfile.lock +0 -68
- data/VERSION +0 -1
data/.gitignore
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
# PROJECT::SPECIFIC
|
22
|
+
awesome_nested_set.sqlite3.db
|
23
|
+
test/debug.log
|
24
|
+
rdoc
|
25
|
+
*.sw?
|
26
|
+
.bundle
|
27
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- ruby-head
|
6
|
+
|
7
|
+
env:
|
8
|
+
- RAILS_VERSION=3.0.11
|
9
|
+
- RAILS_VERSION=3.1.3
|
10
|
+
- RAILS_VERSION=3.2.1
|
11
|
+
- RAILS_VERSION=3-0-stable
|
12
|
+
- RAILS_VERSION=3-1-stable
|
13
|
+
- RAILS_VERSION=3-2-stable
|
14
|
+
#- RAILS_VERSION=master
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
exclude:
|
18
|
+
- rvm: 1.9.2
|
19
|
+
env: RAILS_VERSION=master
|
20
|
+
- rvm: 1.8.7
|
21
|
+
env: RAILS_VERSION=master
|
data/Gemfile
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
|
4
|
-
gem "activerecord", ">= 3.0.0"
|
3
|
+
gemspec
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
gem "
|
9
|
-
gem "
|
10
|
-
|
5
|
+
case version = ENV['RAILS_VERSION'] || ">= 3.0.0"
|
6
|
+
when /3-0-stable/
|
7
|
+
gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-0-stable"
|
8
|
+
gem "arel", :git => "git://github.com/rails/arel.git", :branch => "2-0-stable"
|
9
|
+
when /3-1-stable/
|
10
|
+
gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-1-stable"
|
11
|
+
when /3-2-stable/
|
12
|
+
gem "rails", :git => "git://github.com/rails/rails.git", :branch => "3-2-stable"
|
13
|
+
gem "journey", :git => "git://github.com/rails/journey.git"
|
14
|
+
when /master/
|
15
|
+
gem "rails", :git => "git://github.com/rails/rails.git"
|
16
|
+
gem "arel", :git => "git://github.com/rails/arel.git"
|
17
|
+
gem "journey", :git => "git://github.com/rails/journey.git"
|
18
|
+
else
|
19
|
+
gem "rails", version
|
11
20
|
end
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/skyeagle/nested_set.png)](http://travis-ci.org/skyeagle/nested_set)
|
2
|
+
|
1
3
|
# NestedSet
|
2
4
|
|
3
5
|
Nested Set is an implementation of the nested set pattern for ActiveRecord models. It is replacement for acts_as_nested_set and BetterNestedSet, but awesomer. It supports Rails 3.0 and later.
|
data/Rakefile
CHANGED
@@ -1,30 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
3
|
begin
|
5
|
-
|
6
|
-
rescue Bundler::BundlerError => e
|
7
|
-
$stderr.puts e.message
|
8
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
-
exit e.status_code
|
10
|
-
end
|
11
|
-
require 'rake'
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
gem.name = "nested_set"
|
17
|
-
gem.summary = "An awesome nested set implementation for Active Record"
|
18
|
-
gem.description = gem.summary
|
19
|
-
gem.email = "info@collectiveidea.com"
|
20
|
-
gem.homepage = "http://github.com/skyeagle/nested_set"
|
21
|
-
gem.authors = ["Brandon Keepers", "Daniel Morrison"]
|
22
|
-
end
|
23
|
-
Jeweler::GemcutterTasks.new
|
4
|
+
require 'bundler/setup'
|
24
5
|
rescue LoadError
|
25
|
-
puts
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
26
7
|
end
|
27
8
|
|
9
|
+
require 'rake'
|
28
10
|
require 'rake/testtask'
|
29
11
|
Rake::TestTask.new(:test) do |test|
|
30
12
|
test.libs << 'lib' << 'test'
|
@@ -56,3 +38,5 @@ Rake::RDocTask.new do |rdoc|
|
|
56
38
|
rdoc.rdoc_files.include('README*')
|
57
39
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
58
40
|
end
|
41
|
+
|
42
|
+
require "bundler/gem_tasks"
|
data/lib/nested_set/base.rb
CHANGED
@@ -49,7 +49,7 @@ module CollectiveIdea #:nodoc:
|
|
49
49
|
:left_column => 'lft',
|
50
50
|
:right_column => 'rgt',
|
51
51
|
:depth_column => 'depth',
|
52
|
-
:dependent => :delete_all
|
52
|
+
:dependent => :delete_all
|
53
53
|
}.merge(options)
|
54
54
|
|
55
55
|
if options[:scope].is_a?(Symbol) && options[:scope].to_s !~ /_id$/
|
@@ -173,7 +173,7 @@ module CollectiveIdea #:nodoc:
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def no_duplicates_for_columns?
|
176
|
-
scope_string =
|
176
|
+
scope_string = scope_column_names.map do |c|
|
177
177
|
connection.quote_column_name(c)
|
178
178
|
end.push(nil).join(", ")
|
179
179
|
[quoted_left_column_name, quoted_right_column_name].all? do |column|
|
@@ -345,6 +345,10 @@ module CollectiveIdea #:nodoc:
|
|
345
345
|
def quoted_depth_column_name
|
346
346
|
connection.quote_column_name(depth_column_name)
|
347
347
|
end
|
348
|
+
|
349
|
+
def quoted_primary_key_column_name
|
350
|
+
connection.quote_column_name(primary_key_column_name)
|
351
|
+
end
|
348
352
|
end
|
349
353
|
|
350
354
|
# Any instance method that returns a collection makes use of Rails 2.1's named_scope (which is bundled for Rails 2.0), so it can be treated as a finder.
|
@@ -401,12 +405,12 @@ module CollectiveIdea #:nodoc:
|
|
401
405
|
|
402
406
|
# Returns the array of all children and self
|
403
407
|
def self_and_children
|
404
|
-
nested_set_scope.
|
408
|
+
nested_set_scope.where("#{q_parent} = :id or #{q_primary_key} = :id", :id => self)
|
405
409
|
end
|
406
410
|
|
407
411
|
# Returns the array of all parents and self
|
408
412
|
def self_and_ancestors
|
409
|
-
nested_set_scope.
|
413
|
+
nested_set_scope.where("#{q_left} <= ? AND #{q_right} >= ?", left, right)
|
410
414
|
end
|
411
415
|
|
412
416
|
# Returns an array of all parents
|
@@ -416,7 +420,7 @@ module CollectiveIdea #:nodoc:
|
|
416
420
|
|
417
421
|
# Returns the array of all children of the parent, including self
|
418
422
|
def self_and_siblings
|
419
|
-
nested_set_scope.
|
423
|
+
nested_set_scope.where(parent_column_name => parent_id)
|
420
424
|
end
|
421
425
|
|
422
426
|
# Returns the array of all children of the parent, except self
|
@@ -426,7 +430,7 @@ module CollectiveIdea #:nodoc:
|
|
426
430
|
|
427
431
|
# Returns a set of all of its nested children which do not have children
|
428
432
|
def leaves
|
429
|
-
descendants.
|
433
|
+
descendants.where("#{q_right} - #{q_left} = 1")
|
430
434
|
end
|
431
435
|
|
432
436
|
# Returns the level of this object in the tree
|
@@ -437,7 +441,7 @@ module CollectiveIdea #:nodoc:
|
|
437
441
|
|
438
442
|
# Returns a set of itself and all of its nested children
|
439
443
|
def self_and_descendants
|
440
|
-
nested_set_scope.
|
444
|
+
nested_set_scope.where("#{q_left} >= ? AND #{q_right} <= ?", left, right)
|
441
445
|
end
|
442
446
|
|
443
447
|
# Returns a set of all of its children and nested children
|
@@ -463,14 +467,14 @@ module CollectiveIdea #:nodoc:
|
|
463
467
|
|
464
468
|
# Check if other model is in the same scope
|
465
469
|
def same_scope?(other)
|
466
|
-
|
470
|
+
scope_column_names.all? do |attr|
|
467
471
|
self.send(attr) == other.send(attr)
|
468
472
|
end
|
469
473
|
end
|
470
474
|
|
471
475
|
# Find the first sibling to the left
|
472
476
|
def left_sibling
|
473
|
-
siblings.where("#{q_left} < ?", left).
|
477
|
+
siblings.where("#{q_left} < ?", left).last
|
474
478
|
end
|
475
479
|
|
476
480
|
# Find the first sibling to the right
|
@@ -541,15 +545,19 @@ module CollectiveIdea #:nodoc:
|
|
541
545
|
"#{self.class.quoted_table_name}.#{quoted_parent_column_name}"
|
542
546
|
end
|
543
547
|
|
548
|
+
def q_primary_key
|
549
|
+
"#{self.class.quoted_table_name}.#{quoted_primary_key_column_name}"
|
550
|
+
end
|
551
|
+
|
544
552
|
def without_self(scope)
|
545
|
-
scope.where("#{
|
553
|
+
scope.where("#{q_primary_key} != ?", self)
|
546
554
|
end
|
547
555
|
|
548
556
|
# All nested set queries should use this nested_set_scope, which performs finds on
|
549
557
|
# the base ActiveRecord class, using the :scope declared in the acts_as_nested_set
|
550
558
|
# declaration.
|
551
559
|
def nested_set_scope
|
552
|
-
conditions =
|
560
|
+
conditions = scope_column_names.inject({}) do |cnd, attr|
|
553
561
|
cnd.merge attr => self[attr]
|
554
562
|
end
|
555
563
|
|
@@ -693,7 +701,7 @@ module CollectiveIdea #:nodoc:
|
|
693
701
|
end
|
694
702
|
target.reload_nested_set if target
|
695
703
|
self.reload_nested_set
|
696
|
-
self.update_depth if
|
704
|
+
self.update_depth if has_depth_column?
|
697
705
|
end
|
698
706
|
end
|
699
707
|
end
|
data/lib/nested_set/depth.rb
CHANGED
@@ -15,7 +15,7 @@ module CollectiveIdea #:nodoc:
|
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
|
-
def
|
18
|
+
def has_depth_column?
|
19
19
|
respond_to?(depth_column_name)
|
20
20
|
end
|
21
21
|
|
@@ -31,7 +31,7 @@ module CollectiveIdea #:nodoc:
|
|
31
31
|
|
32
32
|
# Update cached_level attribute for all record tree
|
33
33
|
def update_all_depth
|
34
|
-
if
|
34
|
+
if has_depth_column?
|
35
35
|
self.class.connection.execute("UPDATE #{self.class.quoted_table_name} a SET a.depth = \
|
36
36
|
(SELECT count(*) - 1 FROM (SELECT * FROM #{self.class.quoted_table_name} WHERE #{scope_condition}) AS b \
|
37
37
|
WHERE #{scope_condition('a')} AND \
|
data/lib/nested_set/railtie.rb
CHANGED
@@ -16,8 +16,8 @@ module CollectiveIdea
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.extend_active_record
|
20
|
-
ActiveRecord::Base.send :include, CollectiveIdea::Acts::NestedSet::Base
|
19
|
+
def self.extend_active_record!
|
20
|
+
::ActiveRecord::Base.send :include, CollectiveIdea::Acts::NestedSet::Base
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/nested_set.gemspec
CHANGED
@@ -1,86 +1,25 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nested_set/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = "nested_set"
|
7
|
+
s.version = NestedSet::VERSION
|
8
|
+
s.authors = ["Brandon Keepers", "Daniel Morrison"]
|
9
|
+
s.email = ["info@collectiveidea.com"]
|
10
|
+
s.homepage = "http://github.com/skyeagle/nested_set"
|
11
|
+
s.summary = %q{An awesome nested set implementation for Active Record}
|
13
12
|
s.description = %q{An awesome nested set implementation for Active Record}
|
14
|
-
|
15
|
-
s.
|
16
|
-
"
|
17
|
-
|
18
|
-
s.files = [
|
19
|
-
".autotest",
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"MIT-LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"init.rb",
|
27
|
-
"lib/nested_set.rb",
|
28
|
-
"lib/nested_set/base.rb",
|
29
|
-
"lib/nested_set/depth.rb",
|
30
|
-
"lib/nested_set/descendants.rb",
|
31
|
-
"lib/nested_set/helper.rb",
|
32
|
-
"lib/nested_set/railtie.rb",
|
33
|
-
"nested_set.gemspec",
|
34
|
-
"rails/init.rb",
|
35
|
-
"test/benchmarks.rb",
|
36
|
-
"test/db/database.yml",
|
37
|
-
"test/db/schema.rb",
|
38
|
-
"test/fixtures/categories.yml",
|
39
|
-
"test/fixtures/category.rb",
|
40
|
-
"test/fixtures/departments.yml",
|
41
|
-
"test/fixtures/notes.yml",
|
42
|
-
"test/nested_set/helper_test.rb",
|
43
|
-
"test/nested_set_test.rb",
|
44
|
-
"test/test_helper.rb"
|
45
|
-
]
|
46
|
-
s.homepage = %q{http://github.com/skyeagle/nested_set}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
47
17
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = %q{1.6.2}
|
49
|
-
s.summary = %q{An awesome nested set implementation for Active Record}
|
50
|
-
s.test_files = [
|
51
|
-
"test/benchmarks.rb",
|
52
|
-
"test/db/schema.rb",
|
53
|
-
"test/fixtures/category.rb",
|
54
|
-
"test/nested_set/helper_test.rb",
|
55
|
-
"test/nested_set_test.rb",
|
56
|
-
"test/test_helper.rb"
|
57
|
-
]
|
58
18
|
|
59
|
-
|
60
|
-
|
19
|
+
s.add_runtime_dependency(%q<railties>, [">= 3.0.0"])
|
20
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
61
21
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
66
|
-
s.add_development_dependency(%q<actionpack>, [">= 3.0.0"])
|
67
|
-
s.add_development_dependency(%q<bench_press>, [">= 0.3.1"])
|
68
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
69
|
-
else
|
70
|
-
s.add_dependency(%q<railties>, [">= 3.0.0"])
|
71
|
-
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
72
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
73
|
-
s.add_dependency(%q<actionpack>, [">= 3.0.0"])
|
74
|
-
s.add_dependency(%q<bench_press>, [">= 0.3.1"])
|
75
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
76
|
-
end
|
77
|
-
else
|
78
|
-
s.add_dependency(%q<railties>, [">= 3.0.0"])
|
79
|
-
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
80
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
81
|
-
s.add_dependency(%q<actionpack>, [">= 3.0.0"])
|
82
|
-
s.add_dependency(%q<bench_press>, [">= 0.3.1"])
|
83
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
84
|
-
end
|
22
|
+
s.add_development_dependency(%q<rails>, [">= 3.0.0"])
|
23
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
24
|
+
s.add_development_dependency(%q<bench_press>, [">= 0.3.1"])
|
85
25
|
end
|
86
|
-
|
data/test/benchmarks.rb
CHANGED
@@ -4,14 +4,11 @@ if $0 == __FILE__
|
|
4
4
|
|
5
5
|
$:.unshift(plugin_test_dir + '/../lib')
|
6
6
|
|
7
|
-
|
8
|
-
require 'active_support'
|
9
|
-
require 'active_record'
|
7
|
+
require 'rails/all'
|
10
8
|
require 'nested_set'
|
11
9
|
require 'bench_press'
|
12
10
|
|
13
|
-
|
14
|
-
CollectiveIdea::Acts::NestedSet::Railtie.extend_active_record
|
11
|
+
CollectiveIdea::Acts::NestedSet::Railtie.extend_active_record!
|
15
12
|
#ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
|
16
13
|
ActiveRecord::Base.configurations = YAML::load(IO.read(plugin_test_dir + "/db/database.yml"))
|
17
14
|
ActiveRecord::Base.establish_connection(ENV["DB"] || "sqlite3mem")
|
data/test/db/schema.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
ActiveRecord::Schema.define(:version => 0) do
|
2
2
|
|
3
|
-
create_table :categories, :force => true do |t|
|
3
|
+
create_table :categories, :force => true, :id => false do |t|
|
4
|
+
t.primary_key :not_default_id_name
|
4
5
|
t.column :name, :string
|
5
6
|
t.column :parent_id, :integer
|
6
7
|
t.column :lft, :integer
|
@@ -10,41 +10,41 @@
|
|
10
10
|
# top_level_2 --
|
11
11
|
|
12
12
|
top_level:
|
13
|
-
|
13
|
+
not_default_id_name: 1
|
14
14
|
name: Top Level
|
15
15
|
lft: 1
|
16
16
|
rgt: 10
|
17
17
|
#depth: NULL
|
18
18
|
child_1:
|
19
|
-
|
19
|
+
not_default_id_name: 2
|
20
20
|
name: Child 1
|
21
21
|
parent_id: 1
|
22
22
|
lft: 2
|
23
23
|
rgt: 3
|
24
24
|
depth: 1
|
25
25
|
child_2:
|
26
|
-
|
26
|
+
not_default_id_name: 3
|
27
27
|
name: Child 2
|
28
28
|
parent_id: 1
|
29
29
|
lft: 4
|
30
30
|
rgt: 7
|
31
31
|
depth: 1
|
32
32
|
child_2_1:
|
33
|
-
|
33
|
+
not_default_id_name: 4
|
34
34
|
name: Child 2.1
|
35
35
|
parent_id: 3
|
36
36
|
lft: 5
|
37
37
|
rgt: 6
|
38
38
|
depth: 2
|
39
39
|
child_3:
|
40
|
-
|
40
|
+
not_default_id_name: 5
|
41
41
|
name: Child 3
|
42
42
|
parent_id: 1
|
43
43
|
lft: 8
|
44
44
|
rgt: 9
|
45
45
|
depth: 1
|
46
46
|
top_level_2:
|
47
|
-
|
47
|
+
not_default_id_name: 6
|
48
48
|
name: Top Level 2
|
49
49
|
lft: 11
|
50
50
|
rgt: 12
|
data/test/fixtures/category.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
class Category < ActiveRecord::Base
|
2
|
+
self.primary_key = 'not_default_id_name'
|
2
3
|
acts_as_nested_set
|
3
|
-
|
4
|
+
|
4
5
|
def to_s
|
5
6
|
name
|
6
7
|
end
|
7
|
-
|
8
|
+
|
8
9
|
def recurse(&block)
|
9
10
|
block.call self, lambda{
|
10
11
|
self.children.each do |child|
|
@@ -22,11 +23,12 @@ class Category_NoToArray < Category
|
|
22
23
|
end
|
23
24
|
|
24
25
|
class Category_DefaultScope < Category
|
25
|
-
default_scope order('categories.
|
26
|
+
default_scope order('categories.not_default_id_name ASC')
|
26
27
|
end
|
27
28
|
|
28
29
|
class Category_WithCustomDestroy < ActiveRecord::Base
|
29
|
-
|
30
|
+
self.table_name = 'categories'
|
31
|
+
self.primary_key = 'not_default_id_name'
|
30
32
|
acts_as_nested_set
|
31
33
|
|
32
34
|
private :destroy
|
data/test/nested_set_test.rb
CHANGED
@@ -5,12 +5,14 @@ class Note < ActiveRecord::Base
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class Default < ActiveRecord::Base
|
8
|
-
|
8
|
+
self.table_name = 'categories'
|
9
|
+
self.primary_key = 'not_default_id_name'
|
9
10
|
acts_as_nested_set
|
10
11
|
end
|
11
12
|
|
12
13
|
class ScopedCategory < ActiveRecord::Base
|
13
|
-
|
14
|
+
self.table_name = 'categories'
|
15
|
+
self.primary_key = 'not_default_id_name'
|
14
16
|
acts_as_nested_set :scope => :organization
|
15
17
|
end
|
16
18
|
|
@@ -834,7 +836,7 @@ class NestedSetTest < ActiveSupport::TestCase
|
|
834
836
|
|
835
837
|
def test_model_with_attr_accessible
|
836
838
|
model = Class.new(ActiveRecord::Base)
|
837
|
-
model.
|
839
|
+
model.table_name = 'categories'
|
838
840
|
model.attr_accessible :name
|
839
841
|
assert_nothing_raised do
|
840
842
|
model.acts_as_nested_set
|
data/test/test_helper.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= "test"
|
2
|
+
|
1
3
|
plugin_test_dir = File.dirname(__FILE__)
|
2
4
|
|
3
5
|
$:.unshift(plugin_test_dir + '/../lib')
|
4
6
|
|
5
7
|
require 'rubygems'
|
6
8
|
require 'test/unit'
|
7
|
-
require '
|
8
|
-
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
|
12
|
-
require 'action_view'
|
13
|
-
require 'action_view/base'
|
14
|
-
require 'action_view/template/handlers/erb'
|
15
|
-
require 'action_view/test_case'
|
9
|
+
require 'rails/all'
|
10
|
+
if Rails.version < '3.1.0'
|
11
|
+
require 'action_view/base'
|
12
|
+
require 'action_view/template/handlers/erb'
|
13
|
+
end
|
16
14
|
require 'nested_set'
|
17
15
|
|
18
|
-
|
16
|
+
class NestedSetApplication < Rails::Application
|
17
|
+
end
|
18
|
+
|
19
|
+
CollectiveIdea::Acts::NestedSet::Railtie.extend_active_record!
|
19
20
|
|
20
21
|
ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
|
21
22
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
default_executable:
|
13
|
+
date: 2012-02-21 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: railties
|
18
|
-
requirement: &
|
17
|
+
requirement: &7512700 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ! '>='
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
version: 3.0.0
|
24
23
|
type: :runtime
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *7512700
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: activerecord
|
29
|
-
requirement: &
|
28
|
+
requirement: &7510820 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
@@ -34,32 +33,32 @@ dependencies:
|
|
34
33
|
version: 3.0.0
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *7510820
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
40
|
-
requirement: &
|
38
|
+
name: rails
|
39
|
+
requirement: &7508320 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
44
43
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
44
|
+
version: 3.0.0
|
46
45
|
type: :development
|
47
46
|
prerelease: false
|
48
|
-
version_requirements: *
|
47
|
+
version_requirements: *7508320
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
51
|
-
requirement: &
|
49
|
+
name: sqlite3
|
50
|
+
requirement: &7504440 !ruby/object:Gem::Requirement
|
52
51
|
none: false
|
53
52
|
requirements:
|
54
53
|
- - ! '>='
|
55
54
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
55
|
+
version: '0'
|
57
56
|
type: :development
|
58
57
|
prerelease: false
|
59
|
-
version_requirements: *
|
58
|
+
version_requirements: *7504440
|
60
59
|
- !ruby/object:Gem::Dependency
|
61
60
|
name: bench_press
|
62
|
-
requirement: &
|
61
|
+
requirement: &7502500 !ruby/object:Gem::Requirement
|
63
62
|
none: false
|
64
63
|
requirements:
|
65
64
|
- - ! '>='
|
@@ -67,32 +66,21 @@ dependencies:
|
|
67
66
|
version: 0.3.1
|
68
67
|
type: :development
|
69
68
|
prerelease: false
|
70
|
-
version_requirements: *
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: jeweler
|
73
|
-
requirement: &27658160 !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0'
|
79
|
-
type: :development
|
80
|
-
prerelease: false
|
81
|
-
version_requirements: *27658160
|
69
|
+
version_requirements: *7502500
|
82
70
|
description: An awesome nested set implementation for Active Record
|
83
|
-
email:
|
71
|
+
email:
|
72
|
+
- info@collectiveidea.com
|
84
73
|
executables: []
|
85
74
|
extensions: []
|
86
|
-
extra_rdoc_files:
|
87
|
-
- README.md
|
75
|
+
extra_rdoc_files: []
|
88
76
|
files:
|
89
77
|
- .autotest
|
78
|
+
- .gitignore
|
79
|
+
- .travis.yml
|
90
80
|
- Gemfile
|
91
|
-
- Gemfile.lock
|
92
81
|
- MIT-LICENSE
|
93
82
|
- README.md
|
94
83
|
- Rakefile
|
95
|
-
- VERSION
|
96
84
|
- init.rb
|
97
85
|
- lib/nested_set.rb
|
98
86
|
- lib/nested_set/base.rb
|
@@ -100,6 +88,7 @@ files:
|
|
100
88
|
- lib/nested_set/descendants.rb
|
101
89
|
- lib/nested_set/helper.rb
|
102
90
|
- lib/nested_set/railtie.rb
|
91
|
+
- lib/nested_set/version.rb
|
103
92
|
- nested_set.gemspec
|
104
93
|
- rails/init.rb
|
105
94
|
- test/benchmarks.rb
|
@@ -112,7 +101,6 @@ files:
|
|
112
101
|
- test/nested_set/helper_test.rb
|
113
102
|
- test/nested_set_test.rb
|
114
103
|
- test/test_helper.rb
|
115
|
-
has_rdoc: true
|
116
104
|
homepage: http://github.com/skyeagle/nested_set
|
117
105
|
licenses: []
|
118
106
|
post_install_message:
|
@@ -127,23 +115,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
115
|
version: '0'
|
128
116
|
segments:
|
129
117
|
- 0
|
130
|
-
hash:
|
118
|
+
hash: 1989674500396068183
|
131
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
120
|
none: false
|
133
121
|
requirements:
|
134
122
|
- - ! '>='
|
135
123
|
- !ruby/object:Gem::Version
|
136
124
|
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: 1989674500396068183
|
137
128
|
requirements: []
|
138
129
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
130
|
+
rubygems_version: 1.8.15
|
140
131
|
signing_key:
|
141
132
|
specification_version: 3
|
142
133
|
summary: An awesome nested set implementation for Active Record
|
143
|
-
test_files:
|
144
|
-
- test/benchmarks.rb
|
145
|
-
- test/db/schema.rb
|
146
|
-
- test/fixtures/category.rb
|
147
|
-
- test/nested_set/helper_test.rb
|
148
|
-
- test/nested_set_test.rb
|
149
|
-
- test/test_helper.rb
|
134
|
+
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
abstract (1.0.0)
|
5
|
-
actionpack (3.0.3)
|
6
|
-
activemodel (= 3.0.3)
|
7
|
-
activesupport (= 3.0.3)
|
8
|
-
builder (~> 2.1.2)
|
9
|
-
erubis (~> 2.6.6)
|
10
|
-
i18n (~> 0.4)
|
11
|
-
rack (~> 1.2.1)
|
12
|
-
rack-mount (~> 0.6.13)
|
13
|
-
rack-test (~> 0.5.6)
|
14
|
-
tzinfo (~> 0.3.23)
|
15
|
-
activemodel (3.0.3)
|
16
|
-
activesupport (= 3.0.3)
|
17
|
-
builder (~> 2.1.2)
|
18
|
-
i18n (~> 0.4)
|
19
|
-
activerecord (3.0.3)
|
20
|
-
activemodel (= 3.0.3)
|
21
|
-
activesupport (= 3.0.3)
|
22
|
-
arel (~> 2.0.2)
|
23
|
-
tzinfo (~> 0.3.23)
|
24
|
-
activesupport (3.0.3)
|
25
|
-
arel (2.0.4)
|
26
|
-
bench_press (0.3.1)
|
27
|
-
activesupport (>= 2.3.5)
|
28
|
-
facter (>= 1.5.7)
|
29
|
-
httparty (>= 0.6.1)
|
30
|
-
jeweler (>= 1.4.0)
|
31
|
-
builder (2.1.2)
|
32
|
-
crack (0.1.8)
|
33
|
-
erubis (2.6.6)
|
34
|
-
abstract (>= 1.0.0)
|
35
|
-
facter (1.5.8)
|
36
|
-
git (1.2.5)
|
37
|
-
httparty (0.6.1)
|
38
|
-
crack (= 0.1.8)
|
39
|
-
i18n (0.4.2)
|
40
|
-
jeweler (1.5.1)
|
41
|
-
bundler (~> 1.0.0)
|
42
|
-
git (>= 1.2.5)
|
43
|
-
rake
|
44
|
-
rack (1.2.1)
|
45
|
-
rack-mount (0.6.13)
|
46
|
-
rack (>= 1.0.0)
|
47
|
-
rack-test (0.5.6)
|
48
|
-
rack (>= 1.0)
|
49
|
-
railties (3.0.3)
|
50
|
-
actionpack (= 3.0.3)
|
51
|
-
activesupport (= 3.0.3)
|
52
|
-
rake (>= 0.8.7)
|
53
|
-
thor (~> 0.14.4)
|
54
|
-
rake (0.8.7)
|
55
|
-
sqlite3 (1.3.4)
|
56
|
-
thor (0.14.6)
|
57
|
-
tzinfo (0.3.23)
|
58
|
-
|
59
|
-
PLATFORMS
|
60
|
-
ruby
|
61
|
-
|
62
|
-
DEPENDENCIES
|
63
|
-
actionpack (>= 3.0.0)
|
64
|
-
activerecord (>= 3.0.0)
|
65
|
-
bench_press (>= 0.3.1)
|
66
|
-
jeweler
|
67
|
-
railties (>= 3.0.0)
|
68
|
-
sqlite3
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.6.8
|