Skip to content
Browse files

introduced fixies adjusted to work with factories; created test for m…

…id-level sorted hierarchy object
  • Loading branch information...
1 parent 5d3c8ae commit 957e28762c5c7a71038c5c7dd6b0ae232299fe3d @khustochka committed
View
22 lib/fixie.rb
@@ -0,0 +1,22 @@
+require 'active_record/fixtures'
+
+# Based on Fixie plugin Copyright (c) 2009 Luke Francl (look@recursion.org)
+# http://github.com/look/fixie
+module Fixie
+ def self.create(model, label, *attrs)
+ obj = Factory.build(model, *attrs)
+
+ obj.id = Fixtures.identify(label)
+ obj.save!
+
+ obj
+ end
+
+ def self.method_missing(symbol, args, &blck)
+ find(symbol, args)
+ end
+
+ def self.find(table_name, identifier)
+ table_name.to_s.classify.constantize.find(Fixtures.identify(identifier))
+ end
+end
View
1 lib/sorted_hierarchy/active_record.rb
@@ -12,6 +12,7 @@ module ClassMethods
def parent_for(association_id, options = {}, &extension)
has_many(association_id, options, &extension)
+ # TODO: should :order option be specified explicitly?
write_inheritable_hash :reflections, :children => read_inheritable_attribute(:reflections)[association_id]
instance_methods.select{|m| m.include?(association_id.to_s)}.each do |method|
alias_method method.sub(/#{association_id}/, "children"), method
View
4 lib/tasks/db_test_prepare.rake
@@ -1,14 +1,14 @@
# Taken from http://github.com/look/fixie
namespace :db do
namespace :test do
- desc 'Causes db:test:prepare to also run the fixture creation files in test/fixtures'
+ desc 'Causes db:test:prepare to also run the fixture creation files in test/fixie'
# Somewhat obscure(?) fact: if you create a rake task with the
# same name as another one (in this case test:db:prepare), it will
# be run after the first one. That's how this works.
task :prepare do
RAILS_ENV = 'test'
load 'test/unit/sorted_hierarchy/schema.rb'
- Dir[File.join(RAILS_ROOT, 'test', 'fixtures', '*.rb')].sort.each { |fixture| load fixture }
+ Dir[File.join(RAILS_ROOT, 'test', 'fixie', '*.rb')].sort.each { |fixture| load fixture }
end
end
end
View
14 test/fixie/cities_districts_streets.rb
@@ -0,0 +1,14 @@
+require 'factory_girl'
+require 'test/unit/sorted_hierarchy/model'
+require 'test/unit/sorted_hierarchy/factories'
+
+city1 = Fixie.create(:city, :with_5_districts)
+
+(1..5).each do |n|
+ Fixie.create(:district, "district#{n}".to_sym, :city => city1)
+end
+
+Factory.create(:city)
+Fixie.create(:city, :to_delete)
+Factory.create(:city)
+Factory.create(:city)
View
13 test/fixtures/cities_districts_streets.rb
@@ -1,13 +0,0 @@
-require 'factory_girl'
-require 'test/unit/sorted_hierarchy/model'
-require 'test/unit/sorted_hierarchy/factories'
-
-city = Array.new(5) do |n|
- Factory.create(:city)
-end
-
-city[1].children.create(Factory.attributes_for(:district))
-
-5.times do
- city[2].children.create(Factory.attributes_for(:district))
-end
View
645 test/fixtures/familiae.yml
@@ -1,645 +0,0 @@
----
-familiae_044:
- name_en: ""
- name_la: Passeridae
- ordo_id: "21"
- name_uk: !binary |
- 0JPQvtGA0L7QsdGG0LXQstGW
-
- name_ru: !binary |
- 0JLQvtGA0L7QsdGM0LjQvdGL0LU=
-
- id: "44"
- sort: "19"
- description: ""
- synonims: ""
-familiae_033:
- name_en: ""
- name_la: Troglodytidae
- ordo_id: "21"
- name_uk: !binary |
- 0JLQvtC70L7QstC+0L7Rh9C60L7QstGW
-
- name_ru: !binary |
- 0JrRgNCw0L/QuNCy0L3QuNC60L7QstGL0LU=
-
- id: "33"
- sort: "8"
- description: ""
- synonims: ""
-familiae_022:
- name_en: Rollers
- name_la: Coraciidae
- ordo_id: "19"
- name_uk: !binary |
- 0KDQsNC60YjQtdCy0ZY=
-
- name_ru: !binary |
- 0KHQuNC30L7QstC+0YDQvtC90LrQvtCy0YvQtQ==
-
- id: "22"
- sort: "1"
- description: ""
- synonims: ""
-familiae_011:
- name_en: ""
- name_la: Haematopodidae
- ordo_id: "11"
- name_uk: !binary |
- 0JrRg9C70LjQutC+0YHQvtGA0L7QutC+0LLRlg==
-
- name_ru: !binary |
- 0JrRg9C70LjQutC+0YHQvtGA0L7QutC+0LLRi9C1
-
- id: "11"
- sort: "1"
- description: ""
- synonims: ""
-familiae_045:
- name_en: ""
- name_la: Fringillidae
- ordo_id: "21"
- name_uk: !binary |
- 0JLigJnRjtGA0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0JLRjNGO0YDQutC+0LLRi9C1
-
- id: "45"
- sort: "20"
- description: ""
- synonims: ""
-familiae_034:
- name_en: ""
- name_la: Bombycillidae
- ordo_id: "21"
- name_uk: !binary |
- 0J7QvNC10LvRjtGF0L7QstGW
-
- name_ru: !binary |
- 0KHQstC40YDQuNGB0YLQtdC70LXQstGL0LU=
-
- id: "34"
- sort: "9"
- description: ""
- synonims: ""
-familiae_023:
- name_en: ""
- name_la: Alcedinidae
- ordo_id: "19"
- name_uk: !binary |
- 0KDQuNCx0LDQu9C+0YfQutC+0LLRlg==
-
- name_ru: !binary |
- 0JfQuNC80L7RgNC+0LTQutC+0LLRi9C1
-
- id: "23"
- sort: "2"
- description: ""
- synonims: ""
-familiae_012:
- name_en: ""
- name_la: Charadriidae
- ordo_id: "11"
- name_uk: !binary |
- 0KHQuNCy0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0KDQttCw0L3QutC+0LLRi9C1
-
- id: "12"
- sort: "2"
- description: ""
- synonims: ""
-familiae_001:
- name_en: Grebes
- name_la: Podicipedidae
- ordo_id: "2"
- name_uk: !binary |
- 0J/RltGA0L3QuNC60L7Qt9C+0LLRlg==
-
- name_ru: !binary |
- 0J/QvtCz0LDQvdC60L7QstGL0LU=
-
- id: "1"
- sort: "1"
- description: ""
- synonims: ""
-familiae_046:
- name_en: ""
- name_la: Emberizidae
- ordo_id: "21"
- name_uk: !binary |
- 0JLRltCy0YHRj9C90LrQvtCy0ZY=
-
- name_ru: !binary |
- 0J7QstGB0Y/QvdC60L7QstGL0LU=
-
- id: "46"
- sort: "21"
- description: ""
- synonims: ""
-familiae_035:
- name_en: ""
- name_la: Prunellidae
- ordo_id: "21"
- name_uk: !binary |
- 0KLQuNC90ZbQstC60L7QstGW
-
- name_ru: !binary |
- 0JfQsNCy0LjRgNGD0YjQutC+0LLRi9C1
-
- id: "35"
- sort: "10"
- description: ""
- synonims: ""
-familiae_024:
- name_en: Bee-eaters
- name_la: Meropidae
- ordo_id: "19"
- name_uk: !binary |
- 0JHQtNC20L7Qu9C+0ZfQtNC60L7QstGW
-
- name_ru: !binary |
- 0KnRg9GA0LrQvtCy0YvQtQ==
-
- id: "24"
- sort: "3"
- description: ""
- synonims: ""
-familiae_013:
- name_en: ""
- name_la: Recurvirostridae
- ordo_id: "11"
- name_uk: !binary |
- 0KfQvtCx0L7RgtCw0YDQvtCy0ZY=
-
- name_ru: !binary |
- 0KjQuNC70L7QutC70Y7QstC60L7QstGL0LU=
-
- id: "13"
- sort: "3"
- description: ""
- synonims: ""
-familiae_002:
- name_en: ""
- name_la: Phalacrocoracidae
- ordo_id: "4"
- name_uk: !binary |
- 0JHQsNC60LvQsNC90L7QstGW
-
- name_ru: !binary |
- 0JHQsNC60LvQsNC90L7QstGL0LU=
-
- id: "2"
- sort: "1"
- description: ""
- synonims: ""
-familiae_036:
- name_en: ""
- name_la: Sylviidae
- ordo_id: "21"
- name_uk: !binary |
- 0JrRgNC+0L/QuNCy4oCZ0Y/QvdC60L7QstGW
-
- name_ru: !binary |
- 0KHQu9Cw0LLQutC+0LLRi9C1
-
- id: "36"
- sort: "11"
- description: ""
- synonims: ""
-familiae_025:
- name_en: ""
- name_la: Picidae
- ordo_id: "20"
- name_uk: !binary |
- 0JTRj9GC0LvQvtCy0ZY=
-
- name_ru: !binary |
- 0JTRj9GC0LvQvtCy0YvQtQ==
-
- id: "25"
- sort: "1"
- description: ""
- synonims: ""
-familiae_014:
- name_en: ""
- name_la: Scolopacidae
- ordo_id: "11"
- name_uk: !binary |
- 0JHQsNGA0LDQvdGG0LXQstGW
-
- name_ru: !binary |
- 0JHQtdC60LDRgdC+0LLRi9C1
-
- id: "14"
- sort: "4"
- description: ""
- synonims: ""
-familiae_003:
- name_en: ""
- name_la: Ardeidae
- ordo_id: "5"
- name_uk: !binary |
- 0KfQsNC/0LvQtdCy0ZY=
-
- name_ru: !binary |
- 0KbQsNC/0LvQtdCy0YvQtQ==
-
- id: "3"
- sort: "1"
- description: ""
- synonims: ""
-familiae_037:
- name_en: ""
- name_la: Regulidae
- ordo_id: "21"
- name_uk: !binary |
- 0JfQvtC70L7RgtC+0LzRg9GI0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0JrQvtGA0L7Qu9GM0LrQvtCy0YvQtQ==
-
- id: "37"
- sort: "12"
- description: ""
- synonims: ""
-familiae_026:
- name_en: ""
- name_la: Hirundinidae
- ordo_id: "21"
- name_uk: !binary |
- 0JvQsNGB0YLRltCy0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0JvQsNGB0YLQvtGH0LrQvtCy0YvQtQ==
-
- id: "26"
- sort: "1"
- description: ""
- synonims: ""
-familiae_015:
- name_en: ""
- name_la: Laridae
- ordo_id: "11"
- name_uk: !binary |
- 0JzQsNGA0YLQuNC90L7QstGW
-
- name_ru: !binary |
- 0KfQsNC50LrQvtCy0YvQtQ==
-
- id: "15"
- sort: "5"
- description: ""
- synonims: ""
-familiae_004:
- name_en: ""
- name_la: Ciconiidae
- ordo_id: "5"
- name_uk: !binary |
- 0JvQtdC70LXQutC+0LLRlg==
-
- name_ru: !binary |
- 0JDQuNGB0YLQvtCy0YvQtQ==
-
- id: "4"
- sort: "2"
- description: ""
- synonims: ""
-familiae_038:
- name_en: ""
- name_la: Muscicapidae
- ordo_id: "21"
- name_uk: !binary |
- 0JzRg9GF0L7Qu9C+0LLQutC+0LLRlg==
-
- name_ru: !binary |
- 0JzRg9GF0L7Qu9C+0LLQutC+0LLRi9C1
-
- id: "38"
- sort: "13"
- description: ""
- synonims: ""
-familiae_027:
- name_en: ""
- name_la: Alaudidae
- ordo_id: "21"
- name_uk: !binary |
- 0JbQsNC50LLQvtGA0L7QvdC60L7QstGW
-
- name_ru: !binary |
- 0JbQsNCy0L7RgNC+0L3QutC+0LLRi9C1
-
- id: "27"
- sort: "2"
- description: ""
- synonims: ""
-familiae_016:
- name_en: ""
- name_la: Pteroclididae
- ordo_id: "12"
- name_uk: !binary |
- 0KDRj9Cx0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0KDRj9Cx0LrQvtCy0YvQtQ==
-
- id: "16"
- sort: "1"
- description: ""
- synonims: ""
-familiae_005:
- name_en: ""
- name_la: Anatidae
- ordo_id: "7"
- name_uk: !binary |
- 0JrQsNGH0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0KPRgtC40L3Ri9C1
-
- id: "5"
- sort: "1"
- description: ""
- synonims: ""
-familiae_039:
- name_en: ""
- name_la: Paradoxornithidae
- ordo_id: "21"
- name_uk: !binary |
- 0KHRg9GC0L7RgNC+0LLRlg==
-
- name_ru: !binary |
- 0KHRg9GC0L7RgNC+0LLRi9C1
-
- id: "39"
- sort: "14"
- description: ""
- synonims: ""
-familiae_028:
- name_en: ""
- name_la: Motacillidae
- ordo_id: "21"
- name_uk: !binary |
- 0J/Qu9C40YHQutC+0LLRlg==
-
- name_ru: !binary |
- 0KLRgNGP0YHQvtCz0YPQt9C60L7QstGL0LU=
-
- id: "28"
- sort: "3"
- description: ""
- synonims: ""
-familiae_017:
- name_en: ""
- name_la: Columbidae
- ordo_id: "12"
- name_uk: !binary |
- 0JPQvtC70YPQsdC+0LLRlg==
-
- name_ru: !binary |
- 0JPQvtC70YPQsdC40L3Ri9C1
-
- id: "17"
- sort: "2"
- description: ""
- synonims: ""
-familiae_006:
- name_en: ""
- name_la: Accipitridae
- ordo_id: "8"
- name_uk: !binary |
- 0K/RgdGC0YDRg9Cx0L7QstGW
-
- name_ru: !binary |
- 0K/RgdGC0YDQtdCx0LjQvdGL0LU=
-
- id: "6"
- sort: "1"
- description: ""
- synonims: ""
-familiae_040:
- name_en: ""
- name_la: Aegithalidae
- ordo_id: "21"
- name_uk: !binary |
- 0JTQvtCy0LPQvtGF0LLQvtGB0YLQvtGB0LjQvdC40YbQtdCy0ZY=
-
- name_ru: !binary |
- 0JTQu9C40L3QvdC+0YXQstC+0YHRgtC+0YHQuNC90LjRhtC10LLRi9C1
-
- id: "40"
- sort: "15"
- description: ""
- synonims: ""
-familiae_029:
- name_en: ""
- name_la: Laniidae
- ordo_id: "21"
- name_uk: !binary |
- 0KHQvtGA0L7QutC+0L/Rg9C00L7QstGW
-
- name_ru: !binary |
- 0KHQvtGA0L7QutC+0L/Rg9GC0L7QstGL0LU=
-
- id: "29"
- sort: "4"
- description: ""
- synonims: ""
-familiae_018:
- name_en: ""
- name_la: Cuculidae
- ordo_id: "13"
- name_uk: !binary |
- 0JfQvtC30YPQu9C10LLRlg==
-
- name_ru: !binary |
- 0JrRg9C60YPRiNC60L7QstGL0LU=
-
- id: "18"
- sort: "1"
- description: ""
- synonims: ""
-familiae_007:
- name_en: Falcons
- name_la: Falconidae
- ordo_id: "8"
- name_uk: !binary |
- 0KHQvtC60L7Qu9C+0LLRlg==
-
- name_ru: !binary |
- 0KHQvtC60L7Qu9C40L3Ri9C1
-
- id: "7"
- sort: "2"
- description: ""
- synonims: ""
-familiae_041:
- name_en: ""
- name_la: Paridae
- ordo_id: "21"
- name_uk: !binary |
- 0KHQuNC90LjRhtC10LLRlg==
-
- name_ru: !binary |
- 0KHQuNC90LjRhtC10LLRi9C1
-
- id: "41"
- sort: "16"
- description: ""
- synonims: ""
-familiae_030:
- name_en: ""
- name_la: Oriolidae
- ordo_id: "21"
- name_uk: !binary |
- 0JLQuNCy0ZbQu9GM0LPQvtCy0ZY=
-
- name_ru: !binary |
- 0JjQstC+0LvQs9C+0LLRi9C1
-
- id: "30"
- sort: "5"
- description: ""
- synonims: ""
-familiae_019:
- name_en: ""
- name_la: Apodidae
- ordo_id: "16"
- name_uk: !binary |
- 0KHQtdGA0L/QvtC60YDQuNC70YzRhtC10LLRlg==
-
- name_ru: !binary |
- 0KHRgtGA0LjQttC40L3Ri9C1
-
- id: "19"
- sort: "1"
- description: ""
- synonims: ""
-familiae_008:
- name_en: ""
- name_la: Phasianidae
- ordo_id: "9"
- name_uk: !binary |
- 0KTQsNC30LDQvdC+0LLRlg==
-
- name_ru: !binary |
- 0KTQsNC30LDQvdC+0LLRi9C1
-
- id: "8"
- sort: "1"
- description: ""
- synonims: ""
-familiae_042:
- name_en: ""
- name_la: Sittidae
- ordo_id: "21"
- name_uk: !binary |
- 0J/QvtCy0LfQuNC60L7QstGW
-
- name_ru: !binary |
- 0J/QvtC/0L7Qu9C30L3QtdCy0YvQtQ==
-
- id: "42"
- sort: "17"
- description: ""
- synonims: ""
-familiae_031:
- name_en: ""
- name_la: Sturnidae
- ordo_id: "21"
- name_uk: !binary |
- 0KjQv9Cw0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0KHQutCy0L7RgNGG0L7QstGL0LU=
-
- id: "31"
- sort: "6"
- description: ""
- synonims: ""
-familiae_020:
- name_en: ""
- name_la: Caprimulgidae
- ordo_id: "17"
- name_uk: !binary |
- 0JTRgNGW0LzQu9GO0LPQvtCy0ZY=
-
- name_ru: !binary |
- 0JrQvtC30L7QtNC+0LXQstGL0LU=
-
- id: "20"
- sort: "1"
- description: ""
- synonims: ""
-familiae_009:
- name_en: ""
- name_la: Gruidae
- ordo_id: "10"
- name_uk: !binary |
- 0JbRg9GA0LDQstC70LXQstGW
-
- name_ru: !binary |
- 0JbRg9GA0LDQstC70LjQvdGL0LU=
-
- id: "9"
- sort: "1"
- description: ""
- synonims: ""
-familiae_043:
- name_en: ""
- name_la: Certhiidae
- ordo_id: "21"
- name_uk: !binary |
- 0J/RltC00LrQvtGA0LjRiNC90LjQutC+0LLRlg==
-
- name_ru: !binary |
- 0J/QuNGJ0YPRhdC+0LLRi9C1
-
- id: "43"
- sort: "18"
- description: ""
- synonims: ""
-familiae_032:
- name_en: ""
- name_la: Corvidae
- ordo_id: "21"
- name_uk: !binary |
- 0JLQvtGA0L7QvdC+0LLRlg==
-
- name_ru: !binary |
- 0JLQvtGA0L7QvdC+0LLRi9C1
-
- id: "32"
- sort: "7"
- description: ""
- synonims: ""
-familiae_021:
- name_en: ""
- name_la: Upupidae
- ordo_id: "18"
- name_uk: !binary |
- 0J7QtNGD0LTQvtCy0ZY=
-
- name_ru: !binary |
- 0KPQtNC+0LTQvtCy0YvQtQ==
-
- id: "21"
- sort: "1"
- description: ""
- synonims: ""
-familiae_010:
- name_en: ""
- name_la: Rallidae
- ordo_id: "10"
- name_uk: !binary |
- 0J/QsNGB0YLRg9GI0LrQvtCy0ZY=
-
- name_ru: !binary |
- 0J/QsNGB0YLRg9GI0LrQvtCy0YvQtQ==
-
- id: "10"
- sort: "2"
- description: ""
- synonims: ""
View
280 test/fixtures/ordines.yml
@@ -1,280 +0,0 @@
----
-ordines_015:
- name_en: ""
- name_la: Strigiformes
- name_uk: !binary |
- 0KHQvtCy0L7Qv9C+0LTRltCx0L3Rlg==
-
- name_ru: !binary |
- 0KHQvtCy0L7QvtCx0YDQsNC30L3Ri9C1
-
- id: "15"
- sort: "15"
- description: ""
- synonims: ""
-ordines_004:
- name_en: ""
- name_la: Pelecaniformes
- name_uk: !binary |
- 0J/QtdC70ZbQutCw0L3QvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0J/QtdC70LjQutCw0L3QvtC+0LHRgNCw0LfQvdGL0LU=
-
- id: "4"
- sort: "4"
- description: ""
- synonims: ""
-ordines_016:
- name_en: ""
- name_la: Apodiformes
- name_uk: !binary |
- 0KHQtdGA0L/QvtC60YDQuNC70YzRhtC10L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0KHRgtGA0LjQttC10L7QsdGA0LDQt9C90YvQtQ==
-
- id: "16"
- sort: "16"
- description: ""
- synonims: ""
-ordines_005:
- name_en: ""
- name_la: Ciconiiformes
- name_uk: !binary |
- 0JvQtdC70LXQutC+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0JDQuNGB0YLQvtC+0LHRgNCw0LfQvdGL0LU=
-
- id: "5"
- sort: "5"
- description: ""
- synonims: !binary |
- 0JPQvtC70LXQvdCw0YHRgtGL0LUsINCT0L7Qu9C10L3QsNGB0YLRlg==
-
-ordines_017:
- name_en: ""
- name_la: Caprimulgiformes
- name_uk: !binary |
- 0JTRgNGW0LzQu9GO0LPQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0JrQvtC30L7QtNC+0LXQvtCx0YDQsNC30L3Ri9C1
-
- id: "17"
- sort: "17"
- description: ""
- synonims: ""
-ordines_006:
- name_en: ""
- name_la: Phoenicopteriformes
- name_uk: !binary |
- 0KTQu9Cw0LzRltC90LPQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0KTQu9Cw0LzQuNC90LPQvtC+0LHRgNCw0LfQvdGL0LU=
-
- id: "6"
- sort: "6"
- description: ""
- synonims: ""
-ordines_018:
- name_en: ""
- name_la: Upupiformes
- name_uk: !binary |
- 0J7QtNGD0LTQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0KPQtNC+0LTQvtC+0LHRgNCw0LfQvdGL0LU=
-
- id: "18"
- sort: "18"
- description: !binary |
- 0JjQvdC+0LPQtNCwINCy0LrQu9GO0YfQsNGO0YLRgdGPINCyINGB0LXQvNC1
- 0LnRgdGC0LLQviA8YSBocmVmPSIvYXZlcy9jb3JhY2lpZm9ybWVzLyI+0KDQ
- sNC60YjQtdC+0LHRgNCw0LfQvdGL0YU8L2E+Lg==
-
- synonims: ""
-ordines_007:
- name_en: ""
- name_la: Anseriformes
- name_uk: !binary |
- 0JPRg9GB0LXQv9C+0LTRltCx0L3Rlg==
-
- name_ru: !binary |
- 0JPRg9GB0LXQvtCx0YDQsNC30L3Ri9C1
-
- id: "7"
- sort: "7"
- description: ""
- synonims: ""
-ordines_019:
- name_en: ""
- name_la: Coraciiformes
- name_uk: !binary |
- 0KDQsNC60YjQtdC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0KDQsNC60YjQtdC+0LHRgNCw0LfQvdGL0LU=
-
- id: "19"
- sort: "19"
- description: ""
- synonims: ""
-ordines_008:
- name_en: ""
- name_la: Falconiformes
- name_uk: !binary |
- 0KHQvtC60L7Qu9C+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0KHQvtC60L7Qu9C+0L7QsdGA0LDQt9C90YvQtQ==
-
- id: "8"
- sort: "8"
- description: ""
- synonims: ""
-ordines_020:
- name_en: ""
- name_la: Piciformes
- name_uk: !binary |
- 0JTRj9GC0LvQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0JTRj9GC0LvQvtC+0LHRgNCw0LfQvdGL0LU=
-
- id: "20"
- sort: "20"
- description: ""
- synonims: ""
-ordines_009:
- name_en: ""
- name_la: Galiiformes
- name_uk: !binary |
- 0JrRg9GA0L7Qv9C+0LTRltCx0L3Rlg==
-
- name_ru: !binary |
- 0JrRg9GA0L7QvtCx0YDQsNC30L3Ri9C1
-
- id: "9"
- sort: "9"
- description: ""
- synonims: ""
-ordines_021:
- name_en: ""
- name_la: Passeriformes
- name_uk: !binary |
- 0JPQvtGA0L7QsdGG0LXQv9C+0LTRltCx0L3Rlg==
-
- name_ru: !binary |
- 0JLQvtGA0L7QsdGM0LjQvdC+0L7QsdGA0LDQt9C90YvQtQ==
-
- id: "21"
- sort: "21"
- description: ""
- synonims: ""
-ordines_010:
- name_en: ""
- name_la: Gruiformes
- name_uk: !binary |
- 0JbRg9GA0LDQstC70LXQv9C+0LTRltCx0L3Rlg==
-
- name_ru: !binary |
- 0JbRg9GA0LDQstC70LXQvtCx0YDQsNC30L3Ri9C1
-
- id: "10"
- sort: "10"
- description: ""
- synonims: ""
-ordines_011:
- name_en: ""
- name_la: Charadriiformes
- name_uk: !binary |
- 0KHQuNCy0LrQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0KDQttCw0L3QutC+0L7QsdGA0LDQt9C90YvQtQ==
-
- id: "11"
- sort: "11"
- description: ""
- synonims: ""
-ordines_012:
- name_en: ""
- name_la: Columbiformes
- name_uk: !binary |
- 0JPQvtC70YPQsdC+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0JPQvtC70YPQsdC10L7QsdGA0LDQt9C90YvQtQ==
-
- id: "12"
- sort: "12"
- description: ""
- synonims: ""
-ordines_001:
- name_en: ""
- name_la: Gaviiformes
- name_uk: !binary |
- 0JPQsNCz0LDRgNC+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0JPQsNCz0LDRgNC+0L7QsdGA0LDQt9C90YvQtQ==
-
- id: "1"
- sort: "1"
- description: ""
- synonims: ""
-ordines_013:
- name_en: ""
- name_la: Cuculiformes
- name_uk: !binary |
- 0JfQvtC30YPQu9C10L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0JrRg9C60YPRiNC60L7QvtCx0YDQsNC30L3Ri9C1
-
- id: "13"
- sort: "13"
- description: ""
- synonims: ""
-ordines_002:
- name_en: ""
- name_la: Podicipediformes
- name_uk: !binary |
- 0J/RltGA0L3QuNC60L7Qt9C+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0J/QvtCz0LDQvdC60L7QvtCx0YDQsNC30L3Ri9C1
-
- id: "2"
- sort: "2"
- description: ""
- synonims: ""
-ordines_014:
- name_en: ""
- name_la: Psittaciformes
- name_uk: !binary |
- 0J/QsNC/0YPQs9C+0L/QvtC00ZbQsdC90ZY=
-
- name_ru: !binary |
- 0J/QvtC/0YPQs9Cw0LXQvtCx0YDQsNC30L3Ri9C1
-
- id: "14"
- sort: "14"
- description: ""
- synonims: ""
-ordines_003:
- name_en: ""
- name_la: Procellariiformes
- name_uk: !binary |
- 0JHRg9GA0LXQstGW0YHQvdC40LrQvtC/0L7QtNGW0LHQvdGW
-
- name_ru: !binary |
- 0JHRg9GA0LXQstC10YHRgtC90LjQutC+0L7QsdGA0LDQt9C90YvQtQ==
-
- id: "3"
- sort: "3"
- description: ""
- synonims: ""
View
3 test/fixtures/schema_migrations.yml
@@ -1,3 +0,0 @@
----
-schema_migrations_001:
- version: "20100103001528"
View
4,380 test/fixtures/species.yml
0 additions, 4,380 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 test/test_helper.rb
@@ -54,7 +54,7 @@ def be_sorted
klass.all(:select => sort_column, :order => sort_column).map {|item| item[sort_column] }.should == Array(1..klass.count)
else
klass.parent_class.all(:order => klass.parent_class.get_sort_column, :include => :children).each do |parent|
- parent.children.map {|item| item[sort_column] }.should == Array(1..parent.children.size)
+ parent.children.map {|item| item[sort_column] }.sort.should == Array(1..parent.children.size)
end
end
end
View
18 test/unit/sorted_hierarchy/mid_level_test.rb
@@ -4,21 +4,21 @@ class SortedHierarchyMidLevelTest < ActiveSupport::TestCase
context "Mid level object" do
setup do
- District.count.should == 6
+ District.count.should == 5
District.should be_sorted
end
- should "be created successfully with sort = 6" do
- @new_district = Factory.build(:district, :city => City.find_by_sort(3), :sort_num => 6)
+ should "be created successfully with sort = 3" do
+ @new_district = Factory.build(:district, :city => Fixie.cities(:with_5_districts), :sort_num => 3)
lambda {
@new_district.save!
}.should change(District, :count).by(1)
- @new_district.sort_num.should == 6
+ @new_district.sort_num.should == 3
District.should be_sorted
end
should "be created successfully with sort = nil" do
- @new_district = Factory.build(:district, :city => City.find_by_sort(3))
+ @new_district = Factory.build(:district, :city => Fixie.cities(:with_5_districts))
lambda {
@new_district.save!
}.should change(District, :count).by(1)
@@ -28,22 +28,22 @@ class SortedHierarchyMidLevelTest < ActiveSupport::TestCase
should "not be created with invalid sort" do
lambda {
- Factory.build(:district, :city => City.find_by_sort(3), :sort_num => "first").save!
+ Factory.build(:district, :city => Fixie.cities(:with_5_districts), :sort_num => "first").save!
}.should raise_exception(ActiveRecord::RecordInvalid)
District.should be_sorted
end
should "not be created with sort too large" do
lambda {
- Factory.build(:district, :city => City.find_by_sort(3), :sort_num => 56).save!
+ Factory.build(:district, :city => Fixie.cities(:with_5_districts), :sort_num => 56).save!
}.should raise_exception(ActiveRecord::RecordInvalid)
District.should be_sorted
end
should "preserve sorting when destroyed" do
- @old_district = District.find_by_sort_num(5)
+ @to_delete = Fixie.districts(:district3)
lambda {
- @old_district.destroy
+ @to_delete.destroy
}.should change(District, :count).by(-1)
District.should be_sorted
end
View
4 test/unit/sorted_hierarchy/top_level_test.rb
@@ -41,9 +41,9 @@ class SortedHierarchyTopLevelTest < ActiveSupport::TestCase
end
should "preserve sorting when destroyed" do
- @old_city = City.find_by_sort(3)
+ @to_delete = Fixie.cities(:to_delete)
lambda {
- @old_city.destroy
+ @to_delete.destroy
}.should change(City, :count).by(-1)
City.should be_sorted
end

0 comments on commit 957e287

Please sign in to comment.
Something went wrong with that request. Please try again.