diff --git a/vendor/plugins/nested_has_many_through/test/helper.rb b/vendor/plugins/nested_has_many_through/test/helper.rb new file mode 100644 index 0000000..57bbf06 --- /dev/null +++ b/vendor/plugins/nested_has_many_through/test/helper.rb @@ -0,0 +1,24 @@ +require File.dirname(__FILE__) + '/../../../../config/environment' +load(File.dirname(__FILE__) + '/schema.rb') + +class Pub < ActiveRecord::Base + set_table_name :nested_has_many_through_pubs +end + +class City < ActiveRecord::Base + set_table_name :nested_has_many_through_cities + has_many :pubs +end + +class Country < ActiveRecord::Base + set_table_name :nested_has_many_through_countries + has_many :cities + has_many :pubs, :through => :cities +end + +class Planet < ActiveRecord::Base + set_table_name :nested_has_many_through_planets + has_many :countries + has_many :cities, :through => :countries + has_many :pubs, :through => :cities +end diff --git a/vendor/plugins/nested_has_many_through/test/nested_has_many_through_test.rb b/vendor/plugins/nested_has_many_through/test/nested_has_many_through_test.rb index 7a756c8..dab6258 100644 --- a/vendor/plugins/nested_has_many_through/test/nested_has_many_through_test.rb +++ b/vendor/plugins/nested_has_many_through/test/nested_has_many_through_test.rb @@ -1,8 +1,26 @@ require 'test/unit' +require File.join(File.dirname(__FILE__), 'helper') class NestedHasManyThroughTest < Test::Unit::TestCase - # Replace this with your real tests. - def test_this_plugin - flunk + + def test_nested_has_many_through + + planet = Planet.create! + pubs = [] + 2.times do + planet.countries.build.save! + planet.countries.each do |country| + 2.times do + country.cities.build.save! + end + country.cities.each do |city| + pubs << city.pubs.build + pubs.last.save! + end + end + end + + assert_equal pubs, planet.pubs + end end diff --git a/vendor/plugins/nested_has_many_through/test/schema.rb b/vendor/plugins/nested_has_many_through/test/schema.rb new file mode 100644 index 0000000..1b77d48 --- /dev/null +++ b/vendor/plugins/nested_has_many_through/test/schema.rb @@ -0,0 +1,30 @@ +ActiveRecord::Schema.define(:version => 0) do + + create_table "nested_has_many_through_cities", :force => true do |t| + t.string "name" + t.integer "country_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "nested_has_many_through_countries", :force => true do |t| + t.string "name" + t.integer "planet_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "nested_has_many_through_planets", :force => true do |t| + t.string "name" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "nested_has_many_through_pubs", :force => true do |t| + t.string "name" + t.integer "city_id" + t.datetime "created_at" + t.datetime "updated_at" + end + +end -- libgit2 0.21.2