diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/fixtures/mixin.rb | 18 | ||||
-rw-r--r-- | activerecord/test/fixtures/mixins.yml | 30 | ||||
-rw-r--r-- | activerecord/test/mixin_test.rb | 1 |
3 files changed, 49 insertions, 0 deletions
diff --git a/activerecord/test/fixtures/mixin.rb b/activerecord/test/fixtures/mixin.rb index b14b0f3132..c583fe495e 100644 --- a/activerecord/test/fixtures/mixin.rb +++ b/activerecord/test/fixtures/mixin.rb @@ -17,4 +17,22 @@ class ListWithStringScopeMixin < ActiveRecord::Base acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}' def self.table_name() "mixins" end +end + +class NestedSet < Mixin + acts_as_nested_set :scope => "ROOT_ID IS NULL" + + def self.table_name() "mixins" end +end + +class NestedSetWithStringScope < Mixin + acts_as_nested_set :scope => 'root_id = #{root_id}' + + def self.table_name() "mixins" end +end + +class NestedSetWithSymbolScope < Mixin + acts_as_nested_set :scope => :root + + def self.table_name() "mixins" end end
\ No newline at end of file diff --git a/activerecord/test/fixtures/mixins.yml b/activerecord/test/fixtures/mixins.yml index 49297cc241..9f8e1ee8de 100644 --- a/activerecord/test/fixtures/mixins.yml +++ b/activerecord/test/fixtures/mixins.yml @@ -28,3 +28,33 @@ list_<%= counter %>: type: ListMixin parent_id: 5 <% end %> + +# Nested set mixins + +<% (1..10).each do |counter| %> +set_<%= counter %>: + id: <%= counter+3000 %> + type: NestedSet +<% end %> + +# Big old set +<% +[[4001, 0, 1, 20], + [4002, 4001, 2, 7], + [4003, 4002, 3, 4], + [4004, 4002, 5, 6], + [4005, 4001, 8, 13], + [4006, 4005, 9, 10], + [4007, 4005, 11, 12], + [4008, 4001, 14, 19], + [4009, 4008, 15, 16], + [4010, 4008, 17, 18]].each do |set| %> +tree_<%= set[0] %>: + id: <%= set[0]%> + parent_id: <%= set[1]%> + type: NestedSetWithStringScope + lft: <%= set[2]%> + rgt: <%= set[3]%> + root_id: 42 + +<% end %> diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/mixin_test.rb index 52aa95117b..1efce934e2 100644 --- a/activerecord/test/mixin_test.rb +++ b/activerecord/test/mixin_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' require 'active_record/acts/tree' require 'active_record/acts/list' +require 'active_record/acts/nested_set' require 'fixtures/mixin' class ListTest < Test::Unit::TestCase |