parlement 0.14 → 0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +41 -1
- data/MEMORY +66 -5
- data/README +10 -5
- data/Rakefile +15 -23
- data/app/controllers/account_controller.rb +48 -43
- data/app/controllers/{application.rb → application_controller.rb} +15 -12
- data/app/controllers/elt_controller.rb +77 -32
- data/app/controllers/subscriber_controller.rb +11 -10
- data/app/helpers/application_helper.rb +14 -1
- data/app/helpers/elt_helper.rb +9 -7
- data/app/models/elt.rb +25 -24
- data/app/models/mail.rb +44 -47
- data/app/models/person_notify.rb +2 -2
- data/app/models/user.rb +128 -2
- data/app/models/user_notify.rb +15 -15
- data/app/views/account/_login.rhtml +39 -39
- data/app/views/account/_show.rhtml +22 -30
- data/app/views/account/signup.rhtml +2 -2
- data/app/views/elt/_choice.rhtml +6 -6
- data/app/views/elt/_elt.rhtml +27 -32
- data/app/views/elt/choices.rhtml +16 -18
- data/app/views/elt/list/_byDate.rhtml +14 -14
- data/app/views/elt/list/_byVote.rhtml +15 -15
- data/app/views/elt/list/_children.rhtml +48 -40
- data/app/views/elt/list/_subscribers.rhtml +1 -1
- data/app/views/elt/new.rhtml +22 -21
- data/app/views/elt/rss.rxml +4 -11
- data/app/views/elt/show.rhtml +65 -61
- data/app/views/elt/vote_rss.rxml +4 -11
- data/app/views/layouts/top.rhtml +39 -50
- data/app/views/person/_listElts.rhtml +1 -1
- data/app/views/person/show.rhtml +1 -1
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/change_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/forgot_password.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/pending_delete.rhtml +0 -0
- data/{vendor/plugins/login_engine/app → app}/views/user_notify/signup.rhtml +0 -0
- data/config/boot.rb +97 -32
- data/config/environment.rb +37 -35
- data/config/environments/development.rb +2 -3
- data/config/environments/production.rb +3 -0
- data/config/initializers/string_ruby_1.8.rb +10 -0
- data/config/routes.rb +17 -22
- data/db/schema.rb +102 -74
- data/lib/tasks/rspec.rake +167 -0
- data/public/404.html +25 -7
- data/public/500.html +26 -7
- data/public/dispatch.cgi +0 -0
- data/public/dispatch.fcgi +0 -0
- data/public/dispatch.rb +0 -0
- data/public/images/live_tree_branch_collapsed_icon.gif +0 -0
- data/public/images/live_tree_branch_expanded_icon.gif +0 -0
- data/public/images/live_tree_leaf_icon.gif +0 -0
- data/public/javascripts/application.js +258 -0
- data/public/javascripts/controls.js +544 -414
- data/public/javascripts/dragdrop.js +229 -198
- data/public/javascripts/effects.js +499 -459
- data/public/javascripts/prototype.js +2926 -1121
- data/public/javascripts/shadedborder.js +68 -50
- data/public/stylesheets/default.css +34 -34
- data/public/stylesheets/live_tree.css +0 -0
- data/public/stylesheets/scaffold.css +6 -6
- data/script/about +0 -0
- data/script/autospec +6 -0
- data/script/benchmarker +0 -0
- data/script/breakpointer +0 -0
- data/script/console +0 -0
- data/script/dbconsole +3 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/plugin +0 -0
- data/script/profiler +0 -0
- data/script/runner +0 -0
- data/script/server +0 -0
- data/script/spec +10 -0
- data/script/spec_server +9 -0
- data/test/unit/attachment_test.rb +4 -4
- data/test/unit/choice_test.rb +1 -1
- data/test/unit/elt_test.rb +9 -9
- data/test/unit/mail_notify_test.rb +2 -2
- data/test/unit/mail_test.rb +18 -11
- data/test/unit/person_notify_test.rb +1 -1
- data/test/unit/person_test.rb +1 -1
- data/test/unit/subscriber_test.rb +1 -1
- data/test/unit/user_test.rb +81 -0
- data/test/unit/visit_test.rb +6 -6
- data/vendor/plugins/activerecord_foreign_key_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +182 -0
- data/vendor/plugins/activerecord_text_id_extensions/init.rb +2 -0
- data/vendor/plugins/activerecord_text_id_extensions/lib/active_record_extensions.rb +24 -0
- data/vendor/plugins/acts_as_nested_set/README +15 -0
- data/vendor/plugins/acts_as_nested_set/init.rb +1 -0
- data/vendor/plugins/acts_as_nested_set/lib/active_record/acts/nested_set.rb +210 -0
- data/vendor/plugins/acts_as_nested_set/test/nested_set_test.rb +269 -0
- data/vendor/plugins/acts_as_tree/README +26 -0
- data/vendor/plugins/acts_as_tree/Rakefile +22 -0
- data/vendor/plugins/acts_as_tree/init.rb +1 -0
- data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
- data/vendor/plugins/{output_compression/CHANGELOG → acts_as_tree/test/abstract_unit.rb} +0 -0
- data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
- data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
- data/vendor/plugins/classic_pagination/CHANGELOG +152 -0
- data/vendor/plugins/classic_pagination/README +18 -0
- data/vendor/plugins/{output_compression/rakefile → classic_pagination/Rakefile} +22 -22
- data/vendor/plugins/classic_pagination/init.rb +33 -0
- data/vendor/plugins/classic_pagination/install.rb +1 -0
- data/vendor/plugins/classic_pagination/lib/pagination.rb +405 -0
- data/vendor/plugins/classic_pagination/lib/pagination_helper.rb +135 -0
- data/vendor/plugins/classic_pagination/test/fixtures/companies.yml +24 -0
- data/vendor/plugins/classic_pagination/test/fixtures/company.rb +9 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developer.rb +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers.yml +21 -0
- data/vendor/plugins/classic_pagination/test/fixtures/developers_projects.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/project.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/projects.yml +7 -0
- data/vendor/plugins/classic_pagination/test/fixtures/replies.yml +13 -0
- data/vendor/plugins/classic_pagination/test/fixtures/reply.rb +5 -0
- data/vendor/plugins/classic_pagination/test/fixtures/schema.sql +42 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topic.rb +3 -0
- data/vendor/plugins/classic_pagination/test/fixtures/topics.yml +22 -0
- data/vendor/plugins/classic_pagination/test/helper.rb +117 -0
- data/vendor/plugins/classic_pagination/test/pagination_helper_test.rb +38 -0
- data/vendor/plugins/classic_pagination/test/pagination_test.rb +177 -0
- data/vendor/plugins/file_column/lib/file_column.rb +1 -1
- data/vendor/plugins/file_column/test/file_column_test.rb +0 -0
- metadata +151 -197
- data/app/helpers/live_tree.rb +0 -238
- data/app/views/elt/_form.rhtml +0 -31
- data/app/views/elt/show_tree.rhtml +0 -8
- data/config/environments/user_environment.rb +0 -1
- data/db/ROOT/Titemagli.txt +0 -3
- data/db/ROOT/titemagli.txt +0 -9
- data/public/javascripts/behaviour.js +0 -254
- data/public/javascripts/ie7-load.htc +0 -1
- data/public/javascripts/ie7.js +0 -6
- data/public/javascripts/live_tree.js +0 -749
- data/public/javascripts/mybehaviour.js +0 -225
- data/public/javascripts/scriptaculous.js +0 -47
- data/public/javascripts/slider.js +0 -283
- data/public/stylesheets/blue.css +0 -471
- data/vendor/plugins/engines/CHANGELOG +0 -241
- data/vendor/plugins/engines/MIT-LICENSE +0 -21
- data/vendor/plugins/engines/README +0 -64
- data/vendor/plugins/engines/Rakefile +0 -32
- data/vendor/plugins/engines/UPGRADING +0 -93
- data/vendor/plugins/engines/about.yml +0 -7
- data/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
- data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
- data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
- data/vendor/plugins/engines/init.rb +0 -40
- data/vendor/plugins/engines/install.rb +0 -32
- data/vendor/plugins/engines/lib/engines.rb +0 -323
- data/vendor/plugins/engines/lib/engines/deprecated_config_support.rb +0 -135
- data/vendor/plugins/engines/lib/engines/plugin.rb +0 -214
- data/vendor/plugins/engines/lib/engines/plugin_list.rb +0 -31
- data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +0 -60
- data/vendor/plugins/engines/lib/engines/rails_extensions.rb +0 -6
- data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -19
- data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -143
- data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -155
- data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +0 -116
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -20
- data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +0 -86
- data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -77
- data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +0 -140
- data/vendor/plugins/engines/lib/engines/testing.rb +0 -87
- data/vendor/plugins/engines/tasks/engines.rake +0 -149
- data/vendor/plugins/login_engine/CHANGELOG +0 -22
- data/vendor/plugins/login_engine/README +0 -344
- data/vendor/plugins/login_engine/app/controllers/user_controller.rb +0 -262
- data/vendor/plugins/login_engine/app/helpers/user_helper.rb +0 -88
- data/vendor/plugins/login_engine/app/models/user.rb +0 -7
- data/vendor/plugins/login_engine/app/models/user_notify.rb +0 -75
- data/vendor/plugins/login_engine/app/views/user/_edit.rhtml +0 -11
- data/vendor/plugins/login_engine/app/views/user/_password.rhtml +0 -9
- data/vendor/plugins/login_engine/app/views/user/change_password.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/edit.rhtml +0 -23
- data/vendor/plugins/login_engine/app/views/user/forgot_password.rhtml +0 -18
- data/vendor/plugins/login_engine/app/views/user/home.rhtml +0 -7
- data/vendor/plugins/login_engine/app/views/user/login.rhtml +0 -17
- data/vendor/plugins/login_engine/app/views/user/logout.rhtml +0 -8
- data/vendor/plugins/login_engine/app/views/user/signup.rhtml +0 -17
- data/vendor/plugins/login_engine/db/migrate/001_initial_schema.rb +0 -25
- data/vendor/plugins/login_engine/init_engine.rb +0 -11
- data/vendor/plugins/login_engine/install.rb +0 -4
- data/vendor/plugins/login_engine/lib/login_engine.rb +0 -62
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_system.rb +0 -113
- data/vendor/plugins/login_engine/lib/login_engine/authenticated_user.rb +0 -155
- data/vendor/plugins/login_engine/public/stylesheets/login_engine.css +0 -81
- data/vendor/plugins/login_engine/test/fixtures/users.yml +0 -41
- data/vendor/plugins/login_engine/test/functional/user_controller_test.rb +0 -536
- data/vendor/plugins/login_engine/test/mocks/mail.rb +0 -14
- data/vendor/plugins/login_engine/test/mocks/time.rb +0 -19
- data/vendor/plugins/login_engine/test/test_helper.rb +0 -11
- data/vendor/plugins/login_engine/test/unit/user_test.rb +0 -114
- data/vendor/plugins/output_compression/MIT-LICENSE +0 -20
- data/vendor/plugins/output_compression/README +0 -4
- data/vendor/plugins/output_compression/init.rb +0 -1
- data/vendor/plugins/output_compression/lib/output_compression.rb +0 -84
- data/vendor/plugins/output_compression/test/output_test.rb +0 -11
- data/vendor/plugins/output_compression/test/test_controller.rb +0 -3
- data/vendor/plugins/output_compression/test/test_helper.rb +0 -14
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
acts_as_tree
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
|
|
5
|
+
association. This requires that you have a foreign key column, which by default is called +parent_id+.
|
|
6
|
+
|
|
7
|
+
class Category < ActiveRecord::Base
|
|
8
|
+
acts_as_tree :order => "name"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
root
|
|
13
|
+
\_ child1
|
|
14
|
+
\_ subchild1
|
|
15
|
+
\_ subchild2
|
|
16
|
+
|
|
17
|
+
root = Category.create("name" => "root")
|
|
18
|
+
child1 = root.children.create("name" => "child1")
|
|
19
|
+
subchild1 = child1.children.create("name" => "subchild1")
|
|
20
|
+
|
|
21
|
+
root.parent # => nil
|
|
22
|
+
child1.parent # => root
|
|
23
|
+
root.children # => [child1]
|
|
24
|
+
root.children.first.children.first # => subchild1
|
|
25
|
+
|
|
26
|
+
Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'rake/rdoctask'
|
|
4
|
+
|
|
5
|
+
desc 'Default: run unit tests.'
|
|
6
|
+
task :default => :test
|
|
7
|
+
|
|
8
|
+
desc 'Test acts_as_tree plugin.'
|
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
|
10
|
+
t.libs << 'lib'
|
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
|
12
|
+
t.verbose = true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Generate documentation for acts_as_tree plugin.'
|
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
18
|
+
rdoc.title = 'acts_as_tree'
|
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
20
|
+
rdoc.rdoc_files.include('README')
|
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
22
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tree
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module ActiveRecord
|
|
2
|
+
module Acts
|
|
3
|
+
module Tree
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.extend(ClassMethods)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Specify this +acts_as+ extension if you want to model a tree structure by providing a parent association and a children
|
|
9
|
+
# association. This requires that you have a foreign key column, which by default is called +parent_id+.
|
|
10
|
+
#
|
|
11
|
+
# class Category < ActiveRecord::Base
|
|
12
|
+
# acts_as_tree :order => "name"
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# Example:
|
|
16
|
+
# root
|
|
17
|
+
# \_ child1
|
|
18
|
+
# \_ subchild1
|
|
19
|
+
# \_ subchild2
|
|
20
|
+
#
|
|
21
|
+
# root = Category.create("name" => "root")
|
|
22
|
+
# child1 = root.children.create("name" => "child1")
|
|
23
|
+
# subchild1 = child1.children.create("name" => "subchild1")
|
|
24
|
+
#
|
|
25
|
+
# root.parent # => nil
|
|
26
|
+
# child1.parent # => root
|
|
27
|
+
# root.children # => [child1]
|
|
28
|
+
# root.children.first.children.first # => subchild1
|
|
29
|
+
#
|
|
30
|
+
# In addition to the parent and children associations, the following instance methods are added to the class
|
|
31
|
+
# after calling <tt>acts_as_tree</tt>:
|
|
32
|
+
# * <tt>siblings</tt> - Returns all the children of the parent, excluding the current node (<tt>[subchild2]</tt> when called on <tt>subchild1</tt>)
|
|
33
|
+
# * <tt>self_and_siblings</tt> - Returns all the children of the parent, including the current node (<tt>[subchild1, subchild2]</tt> when called on <tt>subchild1</tt>)
|
|
34
|
+
# * <tt>ancestors</tt> - Returns all the ancestors of the current node (<tt>[child1, root]</tt> when called on <tt>subchild2</tt>)
|
|
35
|
+
# * <tt>root</tt> - Returns the root of the current node (<tt>root</tt> when called on <tt>subchild2</tt>)
|
|
36
|
+
module ClassMethods
|
|
37
|
+
# Configuration options are:
|
|
38
|
+
#
|
|
39
|
+
# * <tt>foreign_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
|
|
40
|
+
# * <tt>order</tt> - makes it possible to sort the children according to this SQL snippet.
|
|
41
|
+
# * <tt>counter_cache</tt> - keeps a count in a +children_count+ column if set to +true+ (default: +false+).
|
|
42
|
+
def acts_as_tree(options = {})
|
|
43
|
+
configuration = { :foreign_key => "parent_id", :order => nil, :counter_cache => nil }
|
|
44
|
+
configuration.update(options) if options.is_a?(Hash)
|
|
45
|
+
|
|
46
|
+
belongs_to :parent, :class_name => name, :foreign_key => configuration[:foreign_key], :counter_cache => configuration[:counter_cache]
|
|
47
|
+
has_many :children, :class_name => name, :foreign_key => configuration[:foreign_key], :order => configuration[:order], :dependent => :destroy
|
|
48
|
+
|
|
49
|
+
class_eval <<-EOV
|
|
50
|
+
include ActiveRecord::Acts::Tree::InstanceMethods
|
|
51
|
+
|
|
52
|
+
def self.roots
|
|
53
|
+
find(:all, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.root
|
|
57
|
+
find(:first, :conditions => "#{configuration[:foreign_key]} IS NULL", :order => #{configuration[:order].nil? ? "nil" : %Q{"#{configuration[:order]}"}})
|
|
58
|
+
end
|
|
59
|
+
EOV
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
module InstanceMethods
|
|
64
|
+
# Returns list of ancestors, starting from parent until root.
|
|
65
|
+
#
|
|
66
|
+
# subchild1.ancestors # => [child1, root]
|
|
67
|
+
def ancestors
|
|
68
|
+
node, nodes = self, []
|
|
69
|
+
nodes << node = node.parent while node.parent
|
|
70
|
+
nodes
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Returns the root node of the tree.
|
|
74
|
+
def root
|
|
75
|
+
node = self
|
|
76
|
+
node = node.parent while node.parent
|
|
77
|
+
node
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Returns all siblings of the current node.
|
|
81
|
+
#
|
|
82
|
+
# subchild1.siblings # => [subchild2]
|
|
83
|
+
def siblings
|
|
84
|
+
self_and_siblings - [self]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Returns all siblings and a reference to the current node.
|
|
88
|
+
#
|
|
89
|
+
# subchild1.self_and_siblings # => [subchild1, subchild2]
|
|
90
|
+
def self_and_siblings
|
|
91
|
+
parent ? parent.children : self.class.roots
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'active_record'
|
|
5
|
+
|
|
6
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
7
|
+
require File.dirname(__FILE__) + '/../init'
|
|
8
|
+
|
|
9
|
+
class Test::Unit::TestCase
|
|
10
|
+
def assert_queries(num = 1)
|
|
11
|
+
$query_count = 0
|
|
12
|
+
yield
|
|
13
|
+
ensure
|
|
14
|
+
assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def assert_no_queries(&block)
|
|
18
|
+
assert_queries(0, &block)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
|
23
|
+
|
|
24
|
+
# AR keeps printing annoying schema statements
|
|
25
|
+
$stdout = StringIO.new
|
|
26
|
+
|
|
27
|
+
def setup_db
|
|
28
|
+
ActiveRecord::Base.logger
|
|
29
|
+
ActiveRecord::Schema.define(:version => 1) do
|
|
30
|
+
create_table :mixins do |t|
|
|
31
|
+
t.column :type, :string
|
|
32
|
+
t.column :parent_id, :integer
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def teardown_db
|
|
38
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
|
39
|
+
ActiveRecord::Base.connection.drop_table(table)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class Mixin < ActiveRecord::Base
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class TreeMixin < Mixin
|
|
47
|
+
acts_as_tree :foreign_key => "parent_id", :order => "id"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class TreeMixinWithoutOrder < Mixin
|
|
51
|
+
acts_as_tree :foreign_key => "parent_id"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class RecursivelyCascadedTreeMixin < Mixin
|
|
55
|
+
acts_as_tree :foreign_key => "parent_id"
|
|
56
|
+
has_one :first_child, :class_name => 'RecursivelyCascadedTreeMixin', :foreign_key => :parent_id
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class TreeTest < Test::Unit::TestCase
|
|
60
|
+
|
|
61
|
+
def setup
|
|
62
|
+
setup_db
|
|
63
|
+
@root1 = TreeMixin.create!
|
|
64
|
+
@root_child1 = TreeMixin.create! :parent_id => @root1.id
|
|
65
|
+
@child1_child = TreeMixin.create! :parent_id => @root_child1.id
|
|
66
|
+
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
|
67
|
+
@root2 = TreeMixin.create!
|
|
68
|
+
@root3 = TreeMixin.create!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def teardown
|
|
72
|
+
teardown_db
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_children
|
|
76
|
+
assert_equal @root1.children, [@root_child1, @root_child2]
|
|
77
|
+
assert_equal @root_child1.children, [@child1_child]
|
|
78
|
+
assert_equal @child1_child.children, []
|
|
79
|
+
assert_equal @root_child2.children, []
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_parent
|
|
83
|
+
assert_equal @root_child1.parent, @root1
|
|
84
|
+
assert_equal @root_child1.parent, @root_child2.parent
|
|
85
|
+
assert_nil @root1.parent
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_delete
|
|
89
|
+
assert_equal 6, TreeMixin.count
|
|
90
|
+
@root1.destroy
|
|
91
|
+
assert_equal 2, TreeMixin.count
|
|
92
|
+
@root2.destroy
|
|
93
|
+
@root3.destroy
|
|
94
|
+
assert_equal 0, TreeMixin.count
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_insert
|
|
98
|
+
@extra = @root1.children.create
|
|
99
|
+
|
|
100
|
+
assert @extra
|
|
101
|
+
|
|
102
|
+
assert_equal @extra.parent, @root1
|
|
103
|
+
|
|
104
|
+
assert_equal 3, @root1.children.size
|
|
105
|
+
assert @root1.children.include?(@extra)
|
|
106
|
+
assert @root1.children.include?(@root_child1)
|
|
107
|
+
assert @root1.children.include?(@root_child2)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_ancestors
|
|
111
|
+
assert_equal [], @root1.ancestors
|
|
112
|
+
assert_equal [@root1], @root_child1.ancestors
|
|
113
|
+
assert_equal [@root_child1, @root1], @child1_child.ancestors
|
|
114
|
+
assert_equal [@root1], @root_child2.ancestors
|
|
115
|
+
assert_equal [], @root2.ancestors
|
|
116
|
+
assert_equal [], @root3.ancestors
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_root
|
|
120
|
+
assert_equal @root1, TreeMixin.root
|
|
121
|
+
assert_equal @root1, @root1.root
|
|
122
|
+
assert_equal @root1, @root_child1.root
|
|
123
|
+
assert_equal @root1, @child1_child.root
|
|
124
|
+
assert_equal @root1, @root_child2.root
|
|
125
|
+
assert_equal @root2, @root2.root
|
|
126
|
+
assert_equal @root3, @root3.root
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_roots
|
|
130
|
+
assert_equal [@root1, @root2, @root3], TreeMixin.roots
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_siblings
|
|
134
|
+
assert_equal [@root2, @root3], @root1.siblings
|
|
135
|
+
assert_equal [@root_child2], @root_child1.siblings
|
|
136
|
+
assert_equal [], @child1_child.siblings
|
|
137
|
+
assert_equal [@root_child1], @root_child2.siblings
|
|
138
|
+
assert_equal [@root1, @root3], @root2.siblings
|
|
139
|
+
assert_equal [@root1, @root2], @root3.siblings
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_self_and_siblings
|
|
143
|
+
assert_equal [@root1, @root2, @root3], @root1.self_and_siblings
|
|
144
|
+
assert_equal [@root_child1, @root_child2], @root_child1.self_and_siblings
|
|
145
|
+
assert_equal [@child1_child], @child1_child.self_and_siblings
|
|
146
|
+
assert_equal [@root_child1, @root_child2], @root_child2.self_and_siblings
|
|
147
|
+
assert_equal [@root1, @root2, @root3], @root2.self_and_siblings
|
|
148
|
+
assert_equal [@root1, @root2, @root3], @root3.self_and_siblings
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class TreeTestWithEagerLoading < Test::Unit::TestCase
|
|
153
|
+
|
|
154
|
+
def setup
|
|
155
|
+
teardown_db
|
|
156
|
+
setup_db
|
|
157
|
+
@root1 = TreeMixin.create!
|
|
158
|
+
@root_child1 = TreeMixin.create! :parent_id => @root1.id
|
|
159
|
+
@child1_child = TreeMixin.create! :parent_id => @root_child1.id
|
|
160
|
+
@root_child2 = TreeMixin.create! :parent_id => @root1.id
|
|
161
|
+
@root2 = TreeMixin.create!
|
|
162
|
+
@root3 = TreeMixin.create!
|
|
163
|
+
|
|
164
|
+
@rc1 = RecursivelyCascadedTreeMixin.create!
|
|
165
|
+
@rc2 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc1.id
|
|
166
|
+
@rc3 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc2.id
|
|
167
|
+
@rc4 = RecursivelyCascadedTreeMixin.create! :parent_id => @rc3.id
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def teardown
|
|
171
|
+
teardown_db
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def test_eager_association_loading
|
|
175
|
+
roots = TreeMixin.find(:all, :include => :children, :conditions => "mixins.parent_id IS NULL", :order => "mixins.id")
|
|
176
|
+
assert_equal [@root1, @root2, @root3], roots
|
|
177
|
+
assert_no_queries do
|
|
178
|
+
assert_equal 2, roots[0].children.size
|
|
179
|
+
assert_equal 0, roots[1].children.size
|
|
180
|
+
assert_equal 0, roots[2].children.size
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_has_many
|
|
185
|
+
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :children => { :children => :children } }, :order => 'mixins.id')
|
|
186
|
+
assert_equal @rc4, assert_no_queries { root_node.children.first.children.first.children.first }
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_has_one
|
|
190
|
+
root_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :first_child => { :first_child => :first_child } }, :order => 'mixins.id')
|
|
191
|
+
assert_equal @rc4, assert_no_queries { root_node.first_child.first_child.first_child }
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_eager_association_loading_with_recursive_cascading_three_levels_belongs_to
|
|
195
|
+
leaf_node = RecursivelyCascadedTreeMixin.find(:first, :include => { :parent => { :parent => :parent } }, :order => 'mixins.id DESC')
|
|
196
|
+
assert_equal @rc1, assert_no_queries { leaf_node.parent.parent.parent }
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
class TreeTestWithoutOrder < Test::Unit::TestCase
|
|
201
|
+
|
|
202
|
+
def setup
|
|
203
|
+
setup_db
|
|
204
|
+
@root1 = TreeMixinWithoutOrder.create!
|
|
205
|
+
@root2 = TreeMixinWithoutOrder.create!
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def teardown
|
|
209
|
+
teardown_db
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def test_root
|
|
213
|
+
assert [@root1, @root2].include?(TreeMixinWithoutOrder.root)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_roots
|
|
217
|
+
assert_equal [], [@root1, @root2] - TreeMixinWithoutOrder.roots
|
|
218
|
+
end
|
|
219
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
* Exported the changelog of Pagination code for historical reference.
|
|
2
|
+
|
|
3
|
+
* Imported some patches from Rails Trac (others closed as "wontfix"):
|
|
4
|
+
#8176, #7325, #7028, #4113. Documentation is much cleaner now and there
|
|
5
|
+
are some new unobtrusive features!
|
|
6
|
+
|
|
7
|
+
* Extracted Pagination from Rails trunk (r6795)
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# ChangeLog for /trunk/actionpack/lib/action_controller/pagination.rb
|
|
11
|
+
#
|
|
12
|
+
# Generated by Trac 0.10.3
|
|
13
|
+
# 05/20/07 23:48:02
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
09/03/06 23:28:54 david [4953]
|
|
17
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
18
|
+
Docs and deprecation
|
|
19
|
+
|
|
20
|
+
08/07/06 12:40:14 bitsweat [4715]
|
|
21
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
22
|
+
Deprecate direct usage of @params. Update ActionView::Base for
|
|
23
|
+
instance var deprecation.
|
|
24
|
+
|
|
25
|
+
06/21/06 02:16:11 rick [4476]
|
|
26
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
27
|
+
Fix indent in pagination documentation. Closes #4990. [Kevin Clark]
|
|
28
|
+
|
|
29
|
+
04/25/06 17:42:48 marcel [4268]
|
|
30
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
31
|
+
Remove all remaining references to @params in the documentation.
|
|
32
|
+
|
|
33
|
+
03/16/06 06:38:08 rick [3899]
|
|
34
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
35
|
+
trivial documentation patch for #pagination_links [Francois
|
|
36
|
+
Beausoleil] closes #4258
|
|
37
|
+
|
|
38
|
+
02/20/06 03:15:22 david [3620]
|
|
39
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
40
|
+
* trunk/actionpack/test/activerecord/pagination_test.rb (modified)
|
|
41
|
+
* trunk/activerecord/CHANGELOG (modified)
|
|
42
|
+
* trunk/activerecord/lib/active_record/base.rb (modified)
|
|
43
|
+
* trunk/activerecord/test/base_test.rb (modified)
|
|
44
|
+
Added :count option to pagination that'll make it possible for the
|
|
45
|
+
ActiveRecord::Base.count call to using something else than * for the
|
|
46
|
+
count. Especially important for count queries using DISTINCT #3839
|
|
47
|
+
[skaes]. Added :select option to Base.count that'll allow you to
|
|
48
|
+
select something else than * to be counted on. Especially important
|
|
49
|
+
for count queries using DISTINCT (closes #3839) [skaes].
|
|
50
|
+
|
|
51
|
+
02/09/06 09:17:40 nzkoz [3553]
|
|
52
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
53
|
+
* trunk/actionpack/test/active_record_unit.rb (added)
|
|
54
|
+
* trunk/actionpack/test/activerecord (added)
|
|
55
|
+
* trunk/actionpack/test/activerecord/active_record_assertions_test.rb (added)
|
|
56
|
+
* trunk/actionpack/test/activerecord/pagination_test.rb (added)
|
|
57
|
+
* trunk/actionpack/test/controller/active_record_assertions_test.rb (deleted)
|
|
58
|
+
* trunk/actionpack/test/fixtures/companies.yml (added)
|
|
59
|
+
* trunk/actionpack/test/fixtures/company.rb (added)
|
|
60
|
+
* trunk/actionpack/test/fixtures/db_definitions (added)
|
|
61
|
+
* trunk/actionpack/test/fixtures/db_definitions/sqlite.sql (added)
|
|
62
|
+
* trunk/actionpack/test/fixtures/developer.rb (added)
|
|
63
|
+
* trunk/actionpack/test/fixtures/developers_projects.yml (added)
|
|
64
|
+
* trunk/actionpack/test/fixtures/developers.yml (added)
|
|
65
|
+
* trunk/actionpack/test/fixtures/project.rb (added)
|
|
66
|
+
* trunk/actionpack/test/fixtures/projects.yml (added)
|
|
67
|
+
* trunk/actionpack/test/fixtures/replies.yml (added)
|
|
68
|
+
* trunk/actionpack/test/fixtures/reply.rb (added)
|
|
69
|
+
* trunk/actionpack/test/fixtures/topic.rb (added)
|
|
70
|
+
* trunk/actionpack/test/fixtures/topics.yml (added)
|
|
71
|
+
* Fix pagination problems when using include
|
|
72
|
+
* Introduce Unit Tests for pagination
|
|
73
|
+
* Allow count to work with :include by using count distinct.
|
|
74
|
+
|
|
75
|
+
[Kevin Clark & Jeremy Hopple]
|
|
76
|
+
|
|
77
|
+
11/05/05 02:10:29 bitsweat [2878]
|
|
78
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
79
|
+
Update paginator docs. Closes #2744.
|
|
80
|
+
|
|
81
|
+
10/16/05 15:42:03 minam [2649]
|
|
82
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
83
|
+
Update/clean up AP documentation (rdoc)
|
|
84
|
+
|
|
85
|
+
08/31/05 00:13:10 ulysses [2078]
|
|
86
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
87
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
88
|
+
Add option to specify the singular name used by pagination. Closes
|
|
89
|
+
#1960
|
|
90
|
+
|
|
91
|
+
08/23/05 14:24:15 minam [2041]
|
|
92
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
93
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
94
|
+
Add support for :include with pagination (subject to existing
|
|
95
|
+
constraints for :include with :limit and :offset) #1478
|
|
96
|
+
[michael@schubert.cx]
|
|
97
|
+
|
|
98
|
+
07/15/05 20:27:38 david [1839]
|
|
99
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
100
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
101
|
+
More pagination speed #1334 [Stefan Kaes]
|
|
102
|
+
|
|
103
|
+
07/14/05 08:02:01 david [1832]
|
|
104
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
105
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
106
|
+
* trunk/actionpack/test/controller/addresses_render_test.rb (modified)
|
|
107
|
+
Made pagination faster #1334 [Stefan Kaes]
|
|
108
|
+
|
|
109
|
+
04/13/05 05:40:22 david [1159]
|
|
110
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
111
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
112
|
+
* trunk/activerecord/lib/active_record/base.rb (modified)
|
|
113
|
+
Fixed pagination to work with joins #1034 [scott@sigkill.org]
|
|
114
|
+
|
|
115
|
+
04/02/05 09:11:17 david [1067]
|
|
116
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
117
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
118
|
+
* trunk/actionpack/lib/action_controller/scaffolding.rb (modified)
|
|
119
|
+
* trunk/actionpack/lib/action_controller/templates/scaffolds/list.rhtml (modified)
|
|
120
|
+
* trunk/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb (modified)
|
|
121
|
+
* trunk/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml (modified)
|
|
122
|
+
Added pagination for scaffolding (10 items per page) #964
|
|
123
|
+
[mortonda@dgrmm.net]
|
|
124
|
+
|
|
125
|
+
03/31/05 14:46:11 david [1048]
|
|
126
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
127
|
+
Improved the message display on the exception handler pages #963
|
|
128
|
+
[Johan Sorensen]
|
|
129
|
+
|
|
130
|
+
03/27/05 00:04:07 david [1017]
|
|
131
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
132
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
133
|
+
Fixed that pagination_helper would ignore :params #947 [Sebastian
|
|
134
|
+
Kanthak]
|
|
135
|
+
|
|
136
|
+
03/22/05 13:09:44 david [976]
|
|
137
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
138
|
+
Fixed documentation and prepared for 0.11.0 release
|
|
139
|
+
|
|
140
|
+
03/21/05 14:35:36 david [967]
|
|
141
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (modified)
|
|
142
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (modified)
|
|
143
|
+
Tweaked the documentation
|
|
144
|
+
|
|
145
|
+
03/20/05 23:12:05 david [949]
|
|
146
|
+
* trunk/actionpack/CHANGELOG (modified)
|
|
147
|
+
* trunk/actionpack/lib/action_controller.rb (modified)
|
|
148
|
+
* trunk/actionpack/lib/action_controller/pagination.rb (added)
|
|
149
|
+
* trunk/actionpack/lib/action_view/helpers/pagination_helper.rb (added)
|
|
150
|
+
* trunk/activesupport/lib/active_support/core_ext/kernel.rb (added)
|
|
151
|
+
Added pagination support through both a controller and helper add-on
|
|
152
|
+
#817 [Sam Stephenson]
|