backlog 0.35.3 → 0.35.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/History.txt +13 -0
  2. data/MODIFICATIONS.txt +13 -0
  3. data/app/controllers/absences_controller.rb +1 -1
  4. data/app/controllers/public_holidays_controller.rb +1 -1
  5. data/app/controllers/work_locks_controller.rb +1 -1
  6. data/app/controllers/works_controller.rb +7 -1
  7. data/app/models/absence.rb +0 -3
  8. data/app/models/work.rb +0 -10
  9. data/app/views/absences/list.rhtml +1 -3
  10. data/app/views/public_holidays/list.rhtml +1 -3
  11. data/app/views/work_locks/list.rhtml +1 -3
  12. data/app/views/works/_row.rhtml +10 -3
  13. data/app/views/works/daily_work_sheet.rhtml +14 -18
  14. data/app/views/works/list.rhtml +1 -1
  15. data/app/views/works/update_row.rjs +1 -0
  16. data/jira.log +33881 -0
  17. data/public/javascripts/controls.js +1 -0
  18. data/test/unit/absence_test.rb +2 -4
  19. data/test/unit/work_test.rb +2 -4
  20. data/vendor/plugins/acts_as_list/README +23 -0
  21. data/vendor/plugins/acts_as_list/init.rb +3 -0
  22. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  23. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  24. data/vendor/plugins/acts_as_tree/README +26 -0
  25. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  26. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  27. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  28. data/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
  29. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  30. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  31. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  32. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  33. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  34. metadata +28 -2
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.3
4
+ version: 0.35.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-07 00:00:00 +01:00
12
+ date: 2009-01-26 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -459,6 +459,22 @@ files:
459
459
  - vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/abstract_adapter.rb
460
460
  - vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/base.rb
461
461
  - vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/schema.rb
462
+ - vendor/plugins/acts_as_tree
463
+ - vendor/plugins/acts_as_tree/README
464
+ - vendor/plugins/acts_as_tree/init.rb
465
+ - vendor/plugins/acts_as_tree/test
466
+ - vendor/plugins/acts_as_tree/test/database.yml
467
+ - vendor/plugins/acts_as_tree/test/abstract_unit.rb
468
+ - vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb
469
+ - vendor/plugins/acts_as_tree/test/schema.rb
470
+ - vendor/plugins/acts_as_tree/test/fixtures
471
+ - vendor/plugins/acts_as_tree/test/fixtures/mixins.yml
472
+ - vendor/plugins/acts_as_tree/test/fixtures/mixin.rb
473
+ - vendor/plugins/acts_as_tree/Rakefile
474
+ - vendor/plugins/acts_as_tree/lib
475
+ - vendor/plugins/acts_as_tree/lib/active_record
476
+ - vendor/plugins/acts_as_tree/lib/active_record/acts
477
+ - vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb
462
478
  - vendor/plugins/foreign_key_migrations
463
479
  - vendor/plugins/foreign_key_migrations/README
464
480
  - vendor/plugins/foreign_key_migrations/init.rb
@@ -553,6 +569,15 @@ files:
553
569
  - vendor/plugins/rails_time/lib
554
570
  - vendor/plugins/rails_time/lib/time_of_day.rb
555
571
  - vendor/plugins/rails_time/lib/activerecord_time_extension.rb
572
+ - vendor/plugins/acts_as_list
573
+ - vendor/plugins/acts_as_list/README
574
+ - vendor/plugins/acts_as_list/init.rb
575
+ - vendor/plugins/acts_as_list/test
576
+ - vendor/plugins/acts_as_list/test/list_test.rb
577
+ - vendor/plugins/acts_as_list/lib
578
+ - vendor/plugins/acts_as_list/lib/active_record
579
+ - vendor/plugins/acts_as_list/lib/active_record/acts
580
+ - vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
556
581
  - vendor/plugins/has_history
557
582
  - vendor/plugins/has_history/README
558
583
  - vendor/plugins/has_history/init.rb
@@ -756,6 +781,7 @@ files:
756
781
  - config/war.rb
757
782
  - config/boot.rb
758
783
  - config/warble.rb
784
+ - MODIFICATIONS.txt
759
785
  - cruise_config.rb
760
786
  - db
761
787
  - db/test.db