activerecord 1.0.0 → 2.0.0
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.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +4928 -3
 - data/README +45 -46
 - data/RUNNING_UNIT_TESTS +8 -11
 - data/Rakefile +247 -0
 - data/install.rb +8 -38
 - data/lib/active_record/aggregations.rb +64 -49
 - data/lib/active_record/associations/association_collection.rb +217 -47
 - data/lib/active_record/associations/association_proxy.rb +159 -0
 - data/lib/active_record/associations/belongs_to_association.rb +56 -0
 - data/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
 - data/lib/active_record/associations/has_and_belongs_to_many_association.rb +155 -37
 - data/lib/active_record/associations/has_many_association.rb +145 -75
 - data/lib/active_record/associations/has_many_through_association.rb +283 -0
 - data/lib/active_record/associations/has_one_association.rb +96 -0
 - data/lib/active_record/associations.rb +1537 -304
 - data/lib/active_record/attribute_methods.rb +328 -0
 - data/lib/active_record/base.rb +2001 -588
 - data/lib/active_record/calculations.rb +269 -0
 - data/lib/active_record/callbacks.rb +169 -165
 - data/lib/active_record/connection_adapters/abstract/connection_specification.rb +308 -0
 - data/lib/active_record/connection_adapters/abstract/database_statements.rb +171 -0
 - data/lib/active_record/connection_adapters/abstract/query_cache.rb +87 -0
 - data/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
 - data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +472 -0
 - data/lib/active_record/connection_adapters/abstract/schema_statements.rb +306 -0
 - data/lib/active_record/connection_adapters/abstract_adapter.rb +125 -279
 - data/lib/active_record/connection_adapters/mysql_adapter.rb +442 -77
 - data/lib/active_record/connection_adapters/postgresql_adapter.rb +805 -135
 - data/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
 - data/lib/active_record/connection_adapters/sqlite_adapter.rb +353 -69
 - data/lib/active_record/fixtures.rb +946 -100
 - data/lib/active_record/locking/optimistic.rb +144 -0
 - data/lib/active_record/locking/pessimistic.rb +77 -0
 - data/lib/active_record/migration.rb +417 -0
 - data/lib/active_record/observer.rb +142 -32
 - data/lib/active_record/query_cache.rb +23 -0
 - data/lib/active_record/reflection.rb +163 -70
 - data/lib/active_record/schema.rb +58 -0
 - data/lib/active_record/schema_dumper.rb +171 -0
 - data/lib/active_record/serialization.rb +98 -0
 - data/lib/active_record/serializers/json_serializer.rb +71 -0
 - data/lib/active_record/serializers/xml_serializer.rb +315 -0
 - data/lib/active_record/timestamp.rb +41 -0
 - data/lib/active_record/transactions.rb +87 -57
 - data/lib/active_record/validations.rb +909 -122
 - data/lib/active_record/vendor/db2.rb +362 -0
 - data/lib/active_record/vendor/mysql.rb +126 -29
 - data/lib/active_record/version.rb +9 -0
 - data/lib/active_record.rb +35 -7
 - data/lib/activerecord.rb +1 -0
 - data/test/aaa_create_tables_test.rb +72 -0
 - data/test/abstract_unit.rb +73 -5
 - data/test/active_schema_test_mysql.rb +43 -0
 - data/test/adapter_test.rb +105 -0
 - data/test/adapter_test_sqlserver.rb +95 -0
 - data/test/aggregations_test.rb +110 -16
 - data/test/all.sh +2 -2
 - data/test/ar_schema_test.rb +33 -0
 - data/test/association_inheritance_reload.rb +14 -0
 - data/test/associations/ar_joins_test.rb +0 -0
 - data/test/associations/callbacks_test.rb +147 -0
 - data/test/associations/cascaded_eager_loading_test.rb +110 -0
 - data/test/associations/eager_singularization_test.rb +145 -0
 - data/test/associations/eager_test.rb +442 -0
 - data/test/associations/extension_test.rb +47 -0
 - data/test/associations/inner_join_association_test.rb +88 -0
 - data/test/associations/join_model_test.rb +553 -0
 - data/test/associations_test.rb +1930 -267
 - data/test/attribute_methods_test.rb +146 -0
 - data/test/base_test.rb +1316 -84
 - data/test/binary_test.rb +32 -0
 - data/test/calculations_test.rb +251 -0
 - data/test/callbacks_test.rb +400 -0
 - data/test/class_inheritable_attributes_test.rb +3 -4
 - data/test/column_alias_test.rb +17 -0
 - data/test/connection_test_firebird.rb +8 -0
 - data/test/connection_test_mysql.rb +30 -0
 - data/test/connections/native_db2/connection.rb +25 -0
 - data/test/connections/native_firebird/connection.rb +26 -0
 - data/test/connections/native_frontbase/connection.rb +27 -0
 - data/test/connections/native_mysql/connection.rb +21 -18
 - data/test/connections/native_openbase/connection.rb +21 -0
 - data/test/connections/native_oracle/connection.rb +27 -0
 - data/test/connections/native_postgresql/connection.rb +17 -18
 - data/test/connections/native_sqlite/connection.rb +17 -16
 - data/test/connections/native_sqlite3/connection.rb +25 -0
 - data/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
 - data/test/connections/native_sybase/connection.rb +23 -0
 - data/test/copy_table_test_sqlite.rb +69 -0
 - data/test/datatype_test_postgresql.rb +203 -0
 - data/test/date_time_test.rb +37 -0
 - data/test/default_test_firebird.rb +16 -0
 - data/test/defaults_test.rb +67 -0
 - data/test/deprecated_finder_test.rb +30 -0
 - data/test/finder_test.rb +607 -32
 - data/test/fixtures/accounts.yml +28 -0
 - data/test/fixtures/all/developers.yml +0 -0
 - data/test/fixtures/all/people.csv +0 -0
 - data/test/fixtures/all/tasks.yml +0 -0
 - data/test/fixtures/author.rb +107 -0
 - data/test/fixtures/author_favorites.yml +4 -0
 - data/test/fixtures/authors.yml +7 -0
 - data/test/fixtures/bad_fixtures/attr_with_numeric_first_char +1 -0
 - data/test/fixtures/bad_fixtures/attr_with_spaces +1 -0
 - data/test/fixtures/bad_fixtures/blank_line +3 -0
 - data/test/fixtures/bad_fixtures/duplicate_attributes +3 -0
 - data/test/fixtures/bad_fixtures/missing_value +1 -0
 - data/test/fixtures/binaries.yml +132 -0
 - data/test/fixtures/binary.rb +2 -0
 - data/test/fixtures/book.rb +4 -0
 - data/test/fixtures/books.yml +7 -0
 - data/test/fixtures/categories/special_categories.yml +9 -0
 - data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
 - data/test/fixtures/categories.yml +14 -0
 - data/test/fixtures/categories_ordered.yml +7 -0
 - data/test/fixtures/categories_posts.yml +23 -0
 - data/test/fixtures/categorization.rb +5 -0
 - data/test/fixtures/categorizations.yml +17 -0
 - data/test/fixtures/category.rb +26 -0
 - data/test/fixtures/citation.rb +6 -0
 - data/test/fixtures/comment.rb +23 -0
 - data/test/fixtures/comments.yml +59 -0
 - data/test/fixtures/companies.yml +55 -0
 - data/test/fixtures/company.rb +81 -4
 - data/test/fixtures/company_in_module.rb +32 -6
 - data/test/fixtures/computer.rb +4 -0
 - data/test/fixtures/computers.yml +4 -0
 - data/test/fixtures/contact.rb +16 -0
 - data/test/fixtures/courses.yml +7 -0
 - data/test/fixtures/customer.rb +28 -3
 - data/test/fixtures/customers.yml +17 -0
 - data/test/fixtures/db_definitions/db2.drop.sql +33 -0
 - data/test/fixtures/db_definitions/db2.sql +235 -0
 - data/test/fixtures/db_definitions/db22.drop.sql +2 -0
 - data/test/fixtures/db_definitions/db22.sql +5 -0
 - data/test/fixtures/db_definitions/firebird.drop.sql +65 -0
 - data/test/fixtures/db_definitions/firebird.sql +310 -0
 - data/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
 - data/test/fixtures/db_definitions/firebird2.sql +6 -0
 - data/test/fixtures/db_definitions/frontbase.drop.sql +33 -0
 - data/test/fixtures/db_definitions/frontbase.sql +273 -0
 - data/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
 - data/test/fixtures/db_definitions/frontbase2.sql +4 -0
 - data/test/fixtures/db_definitions/openbase.drop.sql +2 -0
 - data/test/fixtures/db_definitions/openbase.sql +318 -0
 - data/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
 - data/test/fixtures/db_definitions/openbase2.sql +7 -0
 - data/test/fixtures/db_definitions/oracle.drop.sql +67 -0
 - data/test/fixtures/db_definitions/oracle.sql +330 -0
 - data/test/fixtures/db_definitions/oracle2.drop.sql +2 -0
 - data/test/fixtures/db_definitions/oracle2.sql +6 -0
 - data/test/fixtures/db_definitions/postgresql.drop.sql +44 -0
 - data/test/fixtures/db_definitions/postgresql.sql +217 -38
 - data/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
 - data/test/fixtures/db_definitions/postgresql2.sql +2 -2
 - data/test/fixtures/db_definitions/schema.rb +354 -0
 - data/test/fixtures/db_definitions/schema2.rb +11 -0
 - data/test/fixtures/db_definitions/sqlite.drop.sql +33 -0
 - data/test/fixtures/db_definitions/sqlite.sql +139 -5
 - data/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
 - data/test/fixtures/db_definitions/sqlite2.sql +1 -0
 - data/test/fixtures/db_definitions/sybase.drop.sql +35 -0
 - data/test/fixtures/db_definitions/sybase.sql +222 -0
 - data/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
 - data/test/fixtures/db_definitions/sybase2.sql +5 -0
 - data/test/fixtures/developer.rb +70 -6
 - data/test/fixtures/developers.yml +21 -0
 - data/test/fixtures/developers_projects/david_action_controller +2 -1
 - data/test/fixtures/developers_projects/david_active_record +2 -1
 - data/test/fixtures/developers_projects.yml +17 -0
 - data/test/fixtures/edge.rb +5 -0
 - data/test/fixtures/edges.yml +6 -0
 - data/test/fixtures/entrants.yml +14 -0
 - data/test/fixtures/example.log +1 -0
 - data/test/fixtures/fk_test_has_fk.yml +3 -0
 - data/test/fixtures/fk_test_has_pk.yml +2 -0
 - data/test/fixtures/flowers.jpg +0 -0
 - data/test/fixtures/funny_jokes.yml +10 -0
 - data/test/fixtures/item.rb +7 -0
 - data/test/fixtures/items.yml +4 -0
 - data/test/fixtures/joke.rb +3 -0
 - data/test/fixtures/keyboard.rb +3 -0
 - data/test/fixtures/legacy_thing.rb +3 -0
 - data/test/fixtures/legacy_things.yml +3 -0
 - data/test/fixtures/matey.rb +4 -0
 - data/test/fixtures/mateys.yml +4 -0
 - data/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
 - data/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
 - data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
 - data/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
 - data/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
 - data/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
 - data/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
 - data/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
 - data/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
 - data/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
 - data/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
 - data/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
 - data/test/fixtures/minimalistic.rb +2 -0
 - data/test/fixtures/minimalistics.yml +2 -0
 - data/test/fixtures/mixed_case_monkey.rb +3 -0
 - data/test/fixtures/mixed_case_monkeys.yml +6 -0
 - data/test/fixtures/mixins.yml +29 -0
 - data/test/fixtures/movies.yml +7 -0
 - data/test/fixtures/naked/csv/accounts.csv +1 -0
 - data/test/fixtures/naked/yml/accounts.yml +1 -0
 - data/test/fixtures/naked/yml/companies.yml +1 -0
 - data/test/fixtures/naked/yml/courses.yml +1 -0
 - data/test/fixtures/order.rb +4 -0
 - data/test/fixtures/parrot.rb +13 -0
 - data/test/fixtures/parrots.yml +27 -0
 - data/test/fixtures/parrots_pirates.yml +7 -0
 - data/test/fixtures/people.yml +3 -0
 - data/test/fixtures/person.rb +4 -0
 - data/test/fixtures/pirate.rb +5 -0
 - data/test/fixtures/pirates.yml +9 -0
 - data/test/fixtures/post.rb +59 -0
 - data/test/fixtures/posts.yml +48 -0
 - data/test/fixtures/project.rb +27 -2
 - data/test/fixtures/projects.yml +7 -0
 - data/test/fixtures/reader.rb +4 -0
 - data/test/fixtures/readers.yml +4 -0
 - data/test/fixtures/reply.rb +18 -2
 - data/test/fixtures/reserved_words/distinct.yml +5 -0
 - data/test/fixtures/reserved_words/distincts_selects.yml +11 -0
 - data/test/fixtures/reserved_words/group.yml +14 -0
 - data/test/fixtures/reserved_words/select.yml +8 -0
 - data/test/fixtures/reserved_words/values.yml +7 -0
 - data/test/fixtures/ship.rb +3 -0
 - data/test/fixtures/ships.yml +5 -0
 - data/test/fixtures/subject.rb +4 -0
 - data/test/fixtures/subscriber.rb +4 -3
 - data/test/fixtures/tag.rb +7 -0
 - data/test/fixtures/tagging.rb +10 -0
 - data/test/fixtures/taggings.yml +25 -0
 - data/test/fixtures/tags.yml +7 -0
 - data/test/fixtures/task.rb +3 -0
 - data/test/fixtures/tasks.yml +7 -0
 - data/test/fixtures/topic.rb +20 -3
 - data/test/fixtures/topics.yml +22 -0
 - data/test/fixtures/treasure.rb +4 -0
 - data/test/fixtures/treasures.yml +10 -0
 - data/test/fixtures/vertex.rb +9 -0
 - data/test/fixtures/vertices.yml +4 -0
 - data/test/fixtures_test.rb +574 -8
 - data/test/inheritance_test.rb +113 -27
 - data/test/json_serialization_test.rb +180 -0
 - data/test/lifecycle_test.rb +56 -29
 - data/test/locking_test.rb +273 -0
 - data/test/method_scoping_test.rb +416 -0
 - data/test/migration_test.rb +933 -0
 - data/test/migration_test_firebird.rb +124 -0
 - data/test/mixin_test.rb +95 -0
 - data/test/modules_test.rb +23 -10
 - data/test/multiple_db_test.rb +17 -3
 - data/test/pk_test.rb +59 -15
 - data/test/query_cache_test.rb +104 -0
 - data/test/readonly_test.rb +107 -0
 - data/test/reflection_test.rb +124 -27
 - data/test/reserved_word_test_mysql.rb +177 -0
 - data/test/schema_authorization_test_postgresql.rb +75 -0
 - data/test/schema_dumper_test.rb +131 -0
 - data/test/schema_test_postgresql.rb +64 -0
 - data/test/serialization_test.rb +47 -0
 - data/test/synonym_test_oracle.rb +17 -0
 - data/test/table_name_test_sqlserver.rb +23 -0
 - data/test/threaded_connections_test.rb +48 -0
 - data/test/transactions_test.rb +227 -29
 - data/test/unconnected_test.rb +14 -6
 - data/test/validations_test.rb +1293 -32
 - data/test/xml_serialization_test.rb +202 -0
 - metadata +347 -143
 - data/dev-utils/eval_debugger.rb +0 -9
 - data/examples/associations.rb +0 -87
 - data/examples/shared_setup.rb +0 -15
 - data/examples/validation.rb +0 -88
 - data/lib/active_record/deprecated_associations.rb +0 -70
 - data/lib/active_record/support/class_attribute_accessors.rb +0 -43
 - data/lib/active_record/support/class_inheritable_attributes.rb +0 -37
 - data/lib/active_record/support/clean_logger.rb +0 -10
 - data/lib/active_record/support/inflector.rb +0 -70
 - data/lib/active_record/vendor/simple.rb +0 -702
 - data/lib/active_record/wrappers/yaml_wrapper.rb +0 -15
 - data/lib/active_record/wrappings.rb +0 -59
 - data/rakefile +0 -122
 - data/test/deprecated_associations_test.rb +0 -336
 - data/test/fixtures/accounts/signals37 +0 -3
 - data/test/fixtures/accounts/unknown +0 -2
 - data/test/fixtures/companies/first_client +0 -6
 - data/test/fixtures/companies/first_firm +0 -4
 - data/test/fixtures/companies/second_client +0 -6
 - data/test/fixtures/courses/java +0 -2
 - data/test/fixtures/courses/ruby +0 -2
 - data/test/fixtures/customers/david +0 -6
 - data/test/fixtures/db_definitions/mysql.sql +0 -96
 - data/test/fixtures/db_definitions/mysql2.sql +0 -4
 - data/test/fixtures/developers/david +0 -2
 - data/test/fixtures/developers/jamis +0 -2
 - data/test/fixtures/entrants/first +0 -3
 - data/test/fixtures/entrants/second +0 -3
 - data/test/fixtures/entrants/third +0 -3
 - data/test/fixtures/fixture_database.sqlite +0 -0
 - data/test/fixtures/fixture_database_2.sqlite +0 -0
 - data/test/fixtures/movies/first +0 -2
 - data/test/fixtures/movies/second +0 -2
 - data/test/fixtures/projects/action_controller +0 -2
 - data/test/fixtures/projects/active_record +0 -2
 - data/test/fixtures/topics/first +0 -9
 - data/test/fixtures/topics/second +0 -8
 - data/test/inflector_test.rb +0 -104
 - data/test/thread_safety_test.rb +0 -33
 
    
        data/test/fixtures_test.rb
    CHANGED
    
    | 
         @@ -1,20 +1,586 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'abstract_unit'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'fixtures/post'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'fixtures/binary'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'fixtures/topic'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'fixtures/computer'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'fixtures/developer'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'fixtures/company'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'fixtures/task'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'fixtures/reply'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'fixtures/joke'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'fixtures/course'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'fixtures/category'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'fixtures/parrot'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'fixtures/pirate'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require 'fixtures/treasure'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'fixtures/matey'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'fixtures/ship'
         
     | 
| 
       2 
18 
     | 
    
         | 
| 
       3 
19 
     | 
    
         
             
            class FixturesTest < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 21 
     | 
    
         
            +
              self.use_transactional_fixtures = false
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              FIXTURES = %w( accounts binaries companies customers
         
     | 
| 
      
 26 
     | 
    
         
            +
                             developers developers_projects entrants
         
     | 
| 
      
 27 
     | 
    
         
            +
                             movies projects subscribers topics tasks )
         
     | 
| 
      
 28 
     | 
    
         
            +
              MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg'
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def test_clean_fixtures
         
     | 
| 
      
 33 
     | 
    
         
            +
                FIXTURES.each do |name|
         
     | 
| 
      
 34 
     | 
    
         
            +
                  fixtures = nil
         
     | 
| 
      
 35 
     | 
    
         
            +
                  assert_nothing_raised { fixtures = create_fixtures(name) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  assert_kind_of(Fixtures, fixtures)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  fixtures.each { |name, fixture|
         
     | 
| 
      
 38 
     | 
    
         
            +
                    fixture.each { |key, value|
         
     | 
| 
      
 39 
     | 
    
         
            +
                      assert_match(MATCH_ATTRIBUTE_NAME, key)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    }
         
     | 
| 
      
 41 
     | 
    
         
            +
                  }
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              def test_multiple_clean_fixtures
         
     | 
| 
      
 46 
     | 
    
         
            +
                fixtures_array = nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                assert_nothing_raised { fixtures_array = create_fixtures(*FIXTURES) }
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert_kind_of(Array, fixtures_array)
         
     | 
| 
      
 49 
     | 
    
         
            +
                fixtures_array.each { |fixtures| assert_kind_of(Fixtures, fixtures) }
         
     | 
| 
       6 
50 
     | 
    
         
             
              end
         
     | 
| 
       7 
51 
     | 
    
         | 
| 
       8 
52 
     | 
    
         
             
              def test_attributes
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 53 
     | 
    
         
            +
                topics = create_fixtures("topics")
         
     | 
| 
      
 54 
     | 
    
         
            +
                assert_equal("The First Topic", topics["first"]["title"])
         
     | 
| 
      
 55 
     | 
    
         
            +
                assert_nil(topics["second"]["author_email_address"])
         
     | 
| 
       11 
56 
     | 
    
         
             
              end
         
     | 
| 
       12 
57 
     | 
    
         | 
| 
       13 
58 
     | 
    
         
             
              def test_inserts
         
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 59 
     | 
    
         
            +
                topics = create_fixtures("topics")
         
     | 
| 
      
 60 
     | 
    
         
            +
                first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert_equal("The First Topic", first_row["title"])
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'")
         
     | 
| 
      
 64 
     | 
    
         
            +
                assert_nil(second_row["author_email_address"])
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              if ActiveRecord::Base.connection.supports_migrations?
         
     | 
| 
      
 68 
     | 
    
         
            +
                def test_inserts_with_pre_and_suffix
         
     | 
| 
      
 69 
     | 
    
         
            +
                  # Reset cache to make finds on the new table work
         
     | 
| 
      
 70 
     | 
    
         
            +
                  Fixtures.reset_cache
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  ActiveRecord::Base.connection.create_table :prefix_topics_suffix do |t|
         
     | 
| 
      
 73 
     | 
    
         
            +
                    t.column :title, :string
         
     | 
| 
      
 74 
     | 
    
         
            +
                    t.column :author_name, :string
         
     | 
| 
      
 75 
     | 
    
         
            +
                    t.column :author_email_address, :string
         
     | 
| 
      
 76 
     | 
    
         
            +
                    t.column :written_on, :datetime
         
     | 
| 
      
 77 
     | 
    
         
            +
                    t.column :bonus_time, :time
         
     | 
| 
      
 78 
     | 
    
         
            +
                    t.column :last_read, :date
         
     | 
| 
      
 79 
     | 
    
         
            +
                    t.column :content, :string
         
     | 
| 
      
 80 
     | 
    
         
            +
                    t.column :approved, :boolean, :default => true
         
     | 
| 
      
 81 
     | 
    
         
            +
                    t.column :replies_count, :integer, :default => 0
         
     | 
| 
      
 82 
     | 
    
         
            +
                    t.column :parent_id, :integer
         
     | 
| 
      
 83 
     | 
    
         
            +
                    t.column :type, :string, :limit => 50
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  # Store existing prefix/suffix
         
     | 
| 
      
 87 
     | 
    
         
            +
                  old_prefix = ActiveRecord::Base.table_name_prefix
         
     | 
| 
      
 88 
     | 
    
         
            +
                  old_suffix = ActiveRecord::Base.table_name_suffix
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  # Set a prefix/suffix we can test against
         
     | 
| 
      
 91 
     | 
    
         
            +
                  ActiveRecord::Base.table_name_prefix = 'prefix_'
         
     | 
| 
      
 92 
     | 
    
         
            +
                  ActiveRecord::Base.table_name_suffix = '_suffix'
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                  topics = create_fixtures("topics")
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'David'")
         
     | 
| 
      
 97 
     | 
    
         
            +
                  assert_equal("The First Topic", first_row["title"])
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
         
     | 
| 
      
 100 
     | 
    
         
            +
                  assert_nil(second_row["author_email_address"])
         
     | 
| 
      
 101 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 102 
     | 
    
         
            +
                  # Restore prefix/suffix to its previous values
         
     | 
| 
      
 103 
     | 
    
         
            +
                  ActiveRecord::Base.table_name_prefix = old_prefix
         
     | 
| 
      
 104 
     | 
    
         
            +
                  ActiveRecord::Base.table_name_suffix = old_suffix
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  ActiveRecord::Base.connection.drop_table :prefix_topics_suffix rescue nil
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def test_insert_with_datetime
         
     | 
| 
      
 111 
     | 
    
         
            +
                topics = create_fixtures("tasks")
         
     | 
| 
      
 112 
     | 
    
         
            +
                first = Task.find(1)
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert first
         
     | 
| 
      
 114 
     | 
    
         
            +
              end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
              def test_bad_format
         
     | 
| 
      
 117 
     | 
    
         
            +
                path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures')
         
     | 
| 
      
 118 
     | 
    
         
            +
                Dir.entries(path).each do |file|
         
     | 
| 
      
 119 
     | 
    
         
            +
                  next unless File.file?(file) and file !~ Fixtures::DEFAULT_FILTER_RE
         
     | 
| 
      
 120 
     | 
    
         
            +
                  assert_raise(Fixture::FormatError) {
         
     | 
| 
      
 121 
     | 
    
         
            +
                    Fixture.new(bad_fixtures_path, file)
         
     | 
| 
      
 122 
     | 
    
         
            +
                  }
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
              def test_deprecated_yaml_extension
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_raise(Fixture::FormatError) {
         
     | 
| 
      
 128 
     | 
    
         
            +
                  Fixtures.new(nil, 'bad_extension', 'BadExtension', File.join(File.dirname(__FILE__), 'fixtures'))
         
     | 
| 
      
 129 
     | 
    
         
            +
                }
         
     | 
| 
      
 130 
     | 
    
         
            +
              end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              def test_logger_level_invariant
         
     | 
| 
      
 133 
     | 
    
         
            +
                level = ActiveRecord::Base.logger.level
         
     | 
| 
      
 134 
     | 
    
         
            +
                create_fixtures('topics')
         
     | 
| 
      
 135 
     | 
    
         
            +
                assert_equal level, ActiveRecord::Base.logger.level
         
     | 
| 
      
 136 
     | 
    
         
            +
              end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              def test_instantiation
         
     | 
| 
      
 139 
     | 
    
         
            +
                topics = create_fixtures("topics")
         
     | 
| 
      
 140 
     | 
    
         
            +
                assert_kind_of Topic, topics["first"].find
         
     | 
| 
      
 141 
     | 
    
         
            +
              end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
              def test_complete_instantiation
         
     | 
| 
      
 144 
     | 
    
         
            +
                assert_equal 2, @topics.size
         
     | 
| 
      
 145 
     | 
    
         
            +
                assert_equal "The First Topic", @first.title
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
              def test_fixtures_from_root_yml_with_instantiation
         
     | 
| 
      
 149 
     | 
    
         
            +
                # assert_equal 2, @accounts.size
         
     | 
| 
      
 150 
     | 
    
         
            +
                assert_equal 50, @unknown.credit_limit
         
     | 
| 
      
 151 
     | 
    
         
            +
              end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
              def test_erb_in_fixtures
         
     | 
| 
      
 154 
     | 
    
         
            +
                assert_equal 11, @developers.size
         
     | 
| 
      
 155 
     | 
    
         
            +
                assert_equal "fixture_5", @dev_5.name
         
     | 
| 
      
 156 
     | 
    
         
            +
              end
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
              def test_empty_yaml_fixture
         
     | 
| 
      
 159 
     | 
    
         
            +
                assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', File.dirname(__FILE__) + "/fixtures/naked/yml/accounts")
         
     | 
| 
      
 160 
     | 
    
         
            +
              end
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
              def test_empty_yaml_fixture_with_a_comment_in_it
         
     | 
| 
      
 163 
     | 
    
         
            +
                assert_not_nil Fixtures.new( Account.connection, "companies", 'Company', File.dirname(__FILE__) + "/fixtures/naked/yml/companies")
         
     | 
| 
      
 164 
     | 
    
         
            +
              end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
              def test_dirty_dirty_yaml_file
         
     | 
| 
      
 167 
     | 
    
         
            +
                assert_raises(Fixture::FormatError) do
         
     | 
| 
      
 168 
     | 
    
         
            +
                  Fixtures.new( Account.connection, "courses", 'Course', File.dirname(__FILE__) + "/fixtures/naked/yml/courses")
         
     | 
| 
      
 169 
     | 
    
         
            +
                end
         
     | 
| 
      
 170 
     | 
    
         
            +
              end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
              def test_empty_csv_fixtures
         
     | 
| 
      
 173 
     | 
    
         
            +
                assert_not_nil Fixtures.new( Account.connection, "accounts", 'Account', File.dirname(__FILE__) + "/fixtures/naked/csv/accounts")
         
     | 
| 
      
 174 
     | 
    
         
            +
              end
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
              def test_omap_fixtures
         
     | 
| 
      
 177 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 178 
     | 
    
         
            +
                  fixtures = Fixtures.new(Account.connection, 'categories', 'Category', File.dirname(__FILE__) + '/fixtures/categories_ordered')
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
                  i = 0
         
     | 
| 
      
 181 
     | 
    
         
            +
                  fixtures.each do |name, fixture|
         
     | 
| 
      
 182 
     | 
    
         
            +
                    assert_equal "fixture_no_#{i}", name
         
     | 
| 
      
 183 
     | 
    
         
            +
                    assert_equal "Category #{i}", fixture['name']
         
     | 
| 
      
 184 
     | 
    
         
            +
                    i += 1
         
     | 
| 
      
 185 
     | 
    
         
            +
                  end
         
     | 
| 
      
 186 
     | 
    
         
            +
                end
         
     | 
| 
      
 187 
     | 
    
         
            +
              end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
              def test_yml_file_in_subdirectory
         
     | 
| 
      
 190 
     | 
    
         
            +
                assert_equal(categories(:sub_special_1).name, "A special category in a subdir file")
         
     | 
| 
      
 191 
     | 
    
         
            +
                assert_equal(categories(:sub_special_1).class, SpecialCategory)
         
     | 
| 
      
 192 
     | 
    
         
            +
              end
         
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
      
 194 
     | 
    
         
            +
              def test_subsubdir_file_with_arbitrary_name
         
     | 
| 
      
 195 
     | 
    
         
            +
                assert_equal(categories(:sub_special_3).name, "A special category in an arbitrarily named subsubdir file")
         
     | 
| 
      
 196 
     | 
    
         
            +
                assert_equal(categories(:sub_special_3).class, SpecialCategory)
         
     | 
| 
      
 197 
     | 
    
         
            +
              end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
              def test_binary_in_fixtures
         
     | 
| 
      
 200 
     | 
    
         
            +
                assert_equal 1, @binaries.size
         
     | 
| 
      
 201 
     | 
    
         
            +
                data = File.open(BINARY_FIXTURE_PATH, "rb").read.freeze
         
     | 
| 
      
 202 
     | 
    
         
            +
                assert_equal data, @flowers.data
         
     | 
| 
      
 203 
     | 
    
         
            +
              end
         
     | 
| 
      
 204 
     | 
    
         
            +
            end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            if Account.connection.respond_to?(:reset_pk_sequence!)
         
     | 
| 
      
 207 
     | 
    
         
            +
              class FixturesResetPkSequenceTest < Test::Unit::TestCase
         
     | 
| 
      
 208 
     | 
    
         
            +
                fixtures :accounts
         
     | 
| 
      
 209 
     | 
    
         
            +
                fixtures :companies
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 212 
     | 
    
         
            +
                  @instances = [Account.new(:credit_limit => 50), Company.new(:name => 'RoR Consulting')]
         
     | 
| 
      
 213 
     | 
    
         
            +
                  Fixtures.reset_cache # make sure tables get reinitialized
         
     | 
| 
      
 214 
     | 
    
         
            +
                end
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
                def test_resets_to_min_pk_with_specified_pk_and_sequence
         
     | 
| 
      
 217 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 218 
     | 
    
         
            +
                    model = instance.class
         
     | 
| 
      
 219 
     | 
    
         
            +
                    model.delete_all
         
     | 
| 
      
 220 
     | 
    
         
            +
                    model.connection.reset_pk_sequence!(model.table_name, model.primary_key, model.sequence_name)
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 223 
     | 
    
         
            +
                    assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed."
         
     | 
| 
      
 224 
     | 
    
         
            +
                  end
         
     | 
| 
      
 225 
     | 
    
         
            +
                end
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                def test_resets_to_min_pk_with_default_pk_and_sequence
         
     | 
| 
      
 228 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 229 
     | 
    
         
            +
                    model = instance.class
         
     | 
| 
      
 230 
     | 
    
         
            +
                    model.delete_all
         
     | 
| 
      
 231 
     | 
    
         
            +
                    model.connection.reset_pk_sequence!(model.table_name)
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 234 
     | 
    
         
            +
                    assert_equal 1, instance.id, "Sequence reset for #{model.table_name} failed."
         
     | 
| 
      
 235 
     | 
    
         
            +
                  end
         
     | 
| 
      
 236 
     | 
    
         
            +
                end
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                def test_create_fixtures_resets_sequences_when_not_cached
         
     | 
| 
      
 239 
     | 
    
         
            +
                  @instances.each do |instance|
         
     | 
| 
      
 240 
     | 
    
         
            +
                    max_id = create_fixtures(instance.class.table_name).inject(0) do |max_id, (name, fixture)|
         
     | 
| 
      
 241 
     | 
    
         
            +
                      fixture_id = fixture['id'].to_i
         
     | 
| 
      
 242 
     | 
    
         
            +
                      fixture_id > max_id ? fixture_id : max_id
         
     | 
| 
      
 243 
     | 
    
         
            +
                    end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                    # Clone the last fixture to check that it gets the next greatest id.
         
     | 
| 
      
 246 
     | 
    
         
            +
                    instance.save!
         
     | 
| 
      
 247 
     | 
    
         
            +
                    assert_equal max_id + 1, instance.id, "Sequence reset for #{instance.class.table_name} failed."
         
     | 
| 
      
 248 
     | 
    
         
            +
                  end
         
     | 
| 
      
 249 
     | 
    
         
            +
                end
         
     | 
| 
      
 250 
     | 
    
         
            +
              end
         
     | 
| 
      
 251 
     | 
    
         
            +
            end
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
            class FixturesWithoutInstantiationTest < Test::Unit::TestCase
         
     | 
| 
      
 254 
     | 
    
         
            +
              self.use_instantiated_fixtures = false
         
     | 
| 
      
 255 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
              def test_without_complete_instantiation
         
     | 
| 
      
 258 
     | 
    
         
            +
                assert_nil @first
         
     | 
| 
      
 259 
     | 
    
         
            +
                assert_nil @topics
         
     | 
| 
      
 260 
     | 
    
         
            +
                assert_nil @developers
         
     | 
| 
      
 261 
     | 
    
         
            +
                assert_nil @accounts
         
     | 
| 
      
 262 
     | 
    
         
            +
              end
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
              def test_fixtures_from_root_yml_without_instantiation
         
     | 
| 
      
 265 
     | 
    
         
            +
                assert_nil @unknown
         
     | 
| 
      
 266 
     | 
    
         
            +
              end
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
              def test_accessor_methods
         
     | 
| 
      
 269 
     | 
    
         
            +
                assert_equal "The First Topic", topics(:first).title
         
     | 
| 
      
 270 
     | 
    
         
            +
                assert_equal "Jamis", developers(:jamis).name
         
     | 
| 
      
 271 
     | 
    
         
            +
                assert_equal 50, accounts(:signals37).credit_limit
         
     | 
| 
      
 272 
     | 
    
         
            +
              end
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
              def test_accessor_methods_with_multiple_args
         
     | 
| 
      
 275 
     | 
    
         
            +
                assert_equal 2, topics(:first, :second).size
         
     | 
| 
      
 276 
     | 
    
         
            +
                assert_raise(StandardError) { topics([:first, :second]) }
         
     | 
| 
      
 277 
     | 
    
         
            +
              end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
              uses_mocha 'reloading_fixtures_through_accessor_methods' do
         
     | 
| 
      
 280 
     | 
    
         
            +
                def test_reloading_fixtures_through_accessor_methods
         
     | 
| 
      
 281 
     | 
    
         
            +
                  assert_equal "The First Topic", topics(:first).title
         
     | 
| 
      
 282 
     | 
    
         
            +
                  @loaded_fixtures['topics']['first'].expects(:find).returns(stub(:title => "Fresh Topic!"))
         
     | 
| 
      
 283 
     | 
    
         
            +
                  assert_equal "Fresh Topic!", topics(:first, true).title
         
     | 
| 
      
 284 
     | 
    
         
            +
                end
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
            end
         
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
      
 288 
     | 
    
         
            +
            class FixturesWithoutInstanceInstantiationTest < Test::Unit::TestCase
         
     | 
| 
      
 289 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 290 
     | 
    
         
            +
              self.use_instantiated_fixtures = :no_instances
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
              def test_without_instance_instantiation
         
     | 
| 
      
 295 
     | 
    
         
            +
                assert_nil @first
         
     | 
| 
      
 296 
     | 
    
         
            +
                assert_not_nil @topics
         
     | 
| 
      
 297 
     | 
    
         
            +
                assert_not_nil @developers
         
     | 
| 
      
 298 
     | 
    
         
            +
                assert_not_nil @accounts
         
     | 
| 
      
 299 
     | 
    
         
            +
              end
         
     | 
| 
      
 300 
     | 
    
         
            +
            end
         
     | 
| 
      
 301 
     | 
    
         
            +
             
     | 
| 
      
 302 
     | 
    
         
            +
            class TransactionalFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 303 
     | 
    
         
            +
              self.use_instantiated_fixtures = true
         
     | 
| 
      
 304 
     | 
    
         
            +
              self.use_transactional_fixtures = true
         
     | 
| 
      
 305 
     | 
    
         
            +
             
     | 
| 
      
 306 
     | 
    
         
            +
              fixtures :topics
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
              def test_destroy
         
     | 
| 
      
 309 
     | 
    
         
            +
                assert_not_nil @first
         
     | 
| 
      
 310 
     | 
    
         
            +
                @first.destroy
         
     | 
| 
      
 311 
     | 
    
         
            +
              end
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
              def test_destroy_just_kidding
         
     | 
| 
      
 314 
     | 
    
         
            +
                assert_not_nil @first
         
     | 
| 
      
 315 
     | 
    
         
            +
              end
         
     | 
| 
      
 316 
     | 
    
         
            +
            end
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
            class MultipleFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 319 
     | 
    
         
            +
              fixtures :topics
         
     | 
| 
      
 320 
     | 
    
         
            +
              fixtures :developers, :accounts
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
              def test_fixture_table_names
         
     | 
| 
      
 323 
     | 
    
         
            +
                assert_equal %w(topics developers accounts), fixture_table_names
         
     | 
| 
      
 324 
     | 
    
         
            +
              end
         
     | 
| 
      
 325 
     | 
    
         
            +
            end
         
     | 
| 
      
 326 
     | 
    
         
            +
             
     | 
| 
      
 327 
     | 
    
         
            +
            class OverlappingFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 328 
     | 
    
         
            +
              fixtures :topics, :developers
         
     | 
| 
      
 329 
     | 
    
         
            +
              fixtures :developers, :accounts
         
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
      
 331 
     | 
    
         
            +
              def test_fixture_table_names
         
     | 
| 
      
 332 
     | 
    
         
            +
                assert_equal %w(topics developers accounts), fixture_table_names
         
     | 
| 
      
 333 
     | 
    
         
            +
              end
         
     | 
| 
      
 334 
     | 
    
         
            +
            end
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
            class ForeignKeyFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 337 
     | 
    
         
            +
              fixtures :fk_test_has_pk, :fk_test_has_fk
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
              # if foreign keys are implemented and fixtures
         
     | 
| 
      
 340 
     | 
    
         
            +
              # are not deleted in reverse order then this test
         
     | 
| 
      
 341 
     | 
    
         
            +
              # case will raise StatementInvalid
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
              def test_number1
         
     | 
| 
      
 344 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 345 
     | 
    
         
            +
              end
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
              def test_number2
         
     | 
| 
      
 348 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 349 
     | 
    
         
            +
              end
         
     | 
| 
      
 350 
     | 
    
         
            +
            end
         
     | 
| 
      
 351 
     | 
    
         
            +
             
     | 
| 
      
 352 
     | 
    
         
            +
            class SetTableNameFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 353 
     | 
    
         
            +
              set_fixture_class :funny_jokes => 'Joke'
         
     | 
| 
      
 354 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 355 
     | 
    
         
            +
             
     | 
| 
      
 356 
     | 
    
         
            +
              def test_table_method
         
     | 
| 
      
 357 
     | 
    
         
            +
                assert_kind_of Joke, funny_jokes(:a_joke)
         
     | 
| 
      
 358 
     | 
    
         
            +
              end
         
     | 
| 
      
 359 
     | 
    
         
            +
            end
         
     | 
| 
      
 360 
     | 
    
         
            +
             
     | 
| 
      
 361 
     | 
    
         
            +
            class CustomConnectionFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 362 
     | 
    
         
            +
              set_fixture_class :courses => Course
         
     | 
| 
      
 363 
     | 
    
         
            +
              fixtures :courses
         
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
              def test_connection
         
     | 
| 
      
 366 
     | 
    
         
            +
                assert_kind_of Course, courses(:ruby)
         
     | 
| 
      
 367 
     | 
    
         
            +
                assert_equal Course.connection, courses(:ruby).connection
         
     | 
| 
      
 368 
     | 
    
         
            +
              end
         
     | 
| 
      
 369 
     | 
    
         
            +
            end
         
     | 
| 
      
 370 
     | 
    
         
            +
             
     | 
| 
      
 371 
     | 
    
         
            +
            class InvalidTableNameFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 372 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 373 
     | 
    
         
            +
             
     | 
| 
      
 374 
     | 
    
         
            +
              def test_raises_error
         
     | 
| 
      
 375 
     | 
    
         
            +
                assert_raises FixtureClassNotFound do
         
     | 
| 
      
 376 
     | 
    
         
            +
                  funny_jokes(:a_joke)
         
     | 
| 
      
 377 
     | 
    
         
            +
                end
         
     | 
| 
      
 378 
     | 
    
         
            +
              end
         
     | 
| 
      
 379 
     | 
    
         
            +
            end
         
     | 
| 
      
 380 
     | 
    
         
            +
             
     | 
| 
      
 381 
     | 
    
         
            +
            class CheckEscapedYamlFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 382 
     | 
    
         
            +
              set_fixture_class :funny_jokes => 'Joke'
         
     | 
| 
      
 383 
     | 
    
         
            +
              fixtures :funny_jokes
         
     | 
| 
      
 384 
     | 
    
         
            +
             
     | 
| 
      
 385 
     | 
    
         
            +
              def test_proper_escaped_fixture
         
     | 
| 
      
 386 
     | 
    
         
            +
                assert_equal "The \\n Aristocrats\nAte the candy\n", funny_jokes(:another_joke).name
         
     | 
| 
      
 387 
     | 
    
         
            +
              end
         
     | 
| 
      
 388 
     | 
    
         
            +
            end
         
     | 
| 
      
 389 
     | 
    
         
            +
             
     | 
| 
      
 390 
     | 
    
         
            +
            class DevelopersProject; end
         
     | 
| 
      
 391 
     | 
    
         
            +
            class ManyToManyFixturesWithClassDefined < Test::Unit::TestCase
         
     | 
| 
      
 392 
     | 
    
         
            +
              fixtures :developers_projects
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
              def test_this_should_run_cleanly
         
     | 
| 
      
 395 
     | 
    
         
            +
                assert true
         
     | 
| 
      
 396 
     | 
    
         
            +
              end
         
     | 
| 
      
 397 
     | 
    
         
            +
            end
         
     | 
| 
      
 398 
     | 
    
         
            +
             
     | 
| 
      
 399 
     | 
    
         
            +
            class FixturesBrokenRollbackTest < Test::Unit::TestCase
         
     | 
| 
      
 400 
     | 
    
         
            +
              def blank_setup; end
         
     | 
| 
      
 401 
     | 
    
         
            +
              alias_method :ar_setup_with_fixtures, :setup_with_fixtures
         
     | 
| 
      
 402 
     | 
    
         
            +
              alias_method :setup_with_fixtures, :blank_setup
         
     | 
| 
      
 403 
     | 
    
         
            +
              alias_method :setup, :blank_setup
         
     | 
| 
      
 404 
     | 
    
         
            +
             
     | 
| 
      
 405 
     | 
    
         
            +
              def blank_teardown; end
         
     | 
| 
      
 406 
     | 
    
         
            +
              alias_method :ar_teardown_with_fixtures, :teardown_with_fixtures
         
     | 
| 
      
 407 
     | 
    
         
            +
              alias_method :teardown_with_fixtures, :blank_teardown
         
     | 
| 
      
 408 
     | 
    
         
            +
              alias_method :teardown, :blank_teardown
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
              def test_no_rollback_in_teardown_unless_transaction_active
         
     | 
| 
      
 411 
     | 
    
         
            +
                assert_equal 0, Thread.current['open_transactions']
         
     | 
| 
      
 412 
     | 
    
         
            +
                assert_raise(RuntimeError) { ar_setup_with_fixtures }
         
     | 
| 
      
 413 
     | 
    
         
            +
                assert_equal 0, Thread.current['open_transactions']
         
     | 
| 
      
 414 
     | 
    
         
            +
                assert_nothing_raised { ar_teardown_with_fixtures }
         
     | 
| 
      
 415 
     | 
    
         
            +
                assert_equal 0, Thread.current['open_transactions']
         
     | 
| 
      
 416 
     | 
    
         
            +
              end
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
              private
         
     | 
| 
      
 419 
     | 
    
         
            +
                def load_fixtures
         
     | 
| 
      
 420 
     | 
    
         
            +
                  raise 'argh'
         
     | 
| 
      
 421 
     | 
    
         
            +
                end
         
     | 
| 
      
 422 
     | 
    
         
            +
            end
         
     | 
| 
      
 423 
     | 
    
         
            +
             
     | 
| 
      
 424 
     | 
    
         
            +
            class LoadAllFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 425 
     | 
    
         
            +
              self.fixture_path= File.join(File.dirname(__FILE__), '/fixtures/all')
         
     | 
| 
      
 426 
     | 
    
         
            +
              fixtures :all
         
     | 
| 
      
 427 
     | 
    
         
            +
             
     | 
| 
      
 428 
     | 
    
         
            +
              def test_all_there
         
     | 
| 
      
 429 
     | 
    
         
            +
                assert_equal %w(developers people tasks), fixture_table_names.sort
         
     | 
| 
      
 430 
     | 
    
         
            +
              end
         
     | 
| 
      
 431 
     | 
    
         
            +
            end
         
     | 
| 
      
 432 
     | 
    
         
            +
             
     | 
| 
      
 433 
     | 
    
         
            +
            class FasterFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 434 
     | 
    
         
            +
              fixtures :categories, :authors
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
              def load_extra_fixture(name)
         
     | 
| 
      
 437 
     | 
    
         
            +
                fixture = create_fixtures(name)
         
     | 
| 
      
 438 
     | 
    
         
            +
                assert fixture.is_a?(Fixtures)
         
     | 
| 
      
 439 
     | 
    
         
            +
                @loaded_fixtures[fixture.table_name] = fixture
         
     | 
| 
      
 440 
     | 
    
         
            +
              end
         
     | 
| 
      
 441 
     | 
    
         
            +
             
     | 
| 
      
 442 
     | 
    
         
            +
              def test_cache
         
     | 
| 
      
 443 
     | 
    
         
            +
                assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'categories')
         
     | 
| 
      
 444 
     | 
    
         
            +
                assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'authors')
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
                assert_no_queries do
         
     | 
| 
      
 447 
     | 
    
         
            +
                  create_fixtures('categories')
         
     | 
| 
      
 448 
     | 
    
         
            +
                  create_fixtures('authors')
         
     | 
| 
      
 449 
     | 
    
         
            +
                end
         
     | 
| 
      
 450 
     | 
    
         
            +
             
     | 
| 
      
 451 
     | 
    
         
            +
                load_extra_fixture('posts')
         
     | 
| 
      
 452 
     | 
    
         
            +
                assert Fixtures.fixture_is_cached?(ActiveRecord::Base.connection, 'posts')
         
     | 
| 
      
 453 
     | 
    
         
            +
                self.class.setup_fixture_accessors('posts')
         
     | 
| 
      
 454 
     | 
    
         
            +
                assert_equal 'Welcome to the weblog', posts(:welcome).title
         
     | 
| 
      
 455 
     | 
    
         
            +
              end
         
     | 
| 
      
 456 
     | 
    
         
            +
            end
         
     | 
| 
      
 457 
     | 
    
         
            +
             
     | 
| 
      
 458 
     | 
    
         
            +
            class FoxyFixturesTest < Test::Unit::TestCase
         
     | 
| 
      
 459 
     | 
    
         
            +
              fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers, :developers
         
     | 
| 
      
 460 
     | 
    
         
            +
             
     | 
| 
      
 461 
     | 
    
         
            +
              def test_identifies_strings
         
     | 
| 
      
 462 
     | 
    
         
            +
                assert_equal(Fixtures.identify("foo"), Fixtures.identify("foo"))
         
     | 
| 
      
 463 
     | 
    
         
            +
                assert_not_equal(Fixtures.identify("foo"), Fixtures.identify("FOO"))
         
     | 
| 
      
 464 
     | 
    
         
            +
              end
         
     | 
| 
      
 465 
     | 
    
         
            +
             
     | 
| 
      
 466 
     | 
    
         
            +
              def test_identifies_symbols
         
     | 
| 
      
 467 
     | 
    
         
            +
                assert_equal(Fixtures.identify(:foo), Fixtures.identify(:foo))
         
     | 
| 
      
 468 
     | 
    
         
            +
              end
         
     | 
| 
      
 469 
     | 
    
         
            +
             
     | 
| 
      
 470 
     | 
    
         
            +
              TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on)
         
     | 
| 
      
 471 
     | 
    
         
            +
             
     | 
| 
      
 472 
     | 
    
         
            +
              def test_populates_timestamp_columns
         
     | 
| 
      
 473 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 474 
     | 
    
         
            +
                  assert_not_nil(parrots(:george).send(property), "should set #{property}")
         
     | 
| 
      
 475 
     | 
    
         
            +
                end
         
     | 
| 
      
 476 
     | 
    
         
            +
              end
         
     | 
| 
      
 477 
     | 
    
         
            +
             
     | 
| 
      
 478 
     | 
    
         
            +
              def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false
         
     | 
| 
      
 479 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 480 
     | 
    
         
            +
                  assert_nil(ships(:black_pearl).send(property), "should not set #{property}")
         
     | 
| 
      
 481 
     | 
    
         
            +
                end
         
     | 
| 
      
 482 
     | 
    
         
            +
              end
         
     | 
| 
      
 483 
     | 
    
         
            +
             
     | 
| 
      
 484 
     | 
    
         
            +
              def test_populates_all_columns_with_the_same_time
         
     | 
| 
      
 485 
     | 
    
         
            +
                last = nil
         
     | 
| 
      
 486 
     | 
    
         
            +
             
     | 
| 
      
 487 
     | 
    
         
            +
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
      
 488 
     | 
    
         
            +
                  current = parrots(:george).send(property)
         
     | 
| 
      
 489 
     | 
    
         
            +
                  last ||= current
         
     | 
| 
      
 490 
     | 
    
         
            +
             
     | 
| 
      
 491 
     | 
    
         
            +
                  assert_equal(last, current)
         
     | 
| 
      
 492 
     | 
    
         
            +
                  last = current
         
     | 
| 
      
 493 
     | 
    
         
            +
                end
         
     | 
| 
      
 494 
     | 
    
         
            +
              end
         
     | 
| 
      
 495 
     | 
    
         
            +
             
     | 
| 
      
 496 
     | 
    
         
            +
              def test_only_populates_columns_that_exist
         
     | 
| 
      
 497 
     | 
    
         
            +
                assert_not_nil(pirates(:blackbeard).created_on)
         
     | 
| 
      
 498 
     | 
    
         
            +
                assert_not_nil(pirates(:blackbeard).updated_on)
         
     | 
| 
      
 499 
     | 
    
         
            +
              end
         
     | 
| 
      
 500 
     | 
    
         
            +
             
     | 
| 
      
 501 
     | 
    
         
            +
              def test_preserves_existing_fixture_data
         
     | 
| 
      
 502 
     | 
    
         
            +
                assert_equal(2.weeks.ago.to_date, pirates(:redbeard).created_on.to_date)
         
     | 
| 
      
 503 
     | 
    
         
            +
                assert_equal(2.weeks.ago.to_date, pirates(:redbeard).updated_on.to_date)
         
     | 
| 
      
 504 
     | 
    
         
            +
              end
         
     | 
| 
      
 505 
     | 
    
         
            +
             
     | 
| 
      
 506 
     | 
    
         
            +
              def test_generates_unique_ids
         
     | 
| 
      
 507 
     | 
    
         
            +
                assert_not_nil(parrots(:george).id)
         
     | 
| 
      
 508 
     | 
    
         
            +
                assert_not_equal(parrots(:george).id, parrots(:louis).id)
         
     | 
| 
      
 509 
     | 
    
         
            +
              end
         
     | 
| 
      
 510 
     | 
    
         
            +
             
     | 
| 
      
 511 
     | 
    
         
            +
              def test_automatically_sets_primary_key
         
     | 
| 
      
 512 
     | 
    
         
            +
                assert_not_nil(ships(:black_pearl))
         
     | 
| 
      
 513 
     | 
    
         
            +
              end
         
     | 
| 
      
 514 
     | 
    
         
            +
             
     | 
| 
      
 515 
     | 
    
         
            +
              def test_preserves_existing_primary_key
         
     | 
| 
      
 516 
     | 
    
         
            +
                assert_equal(2, ships(:interceptor).id)
         
     | 
| 
      
 517 
     | 
    
         
            +
              end
         
     | 
| 
      
 518 
     | 
    
         
            +
             
     | 
| 
      
 519 
     | 
    
         
            +
              def test_resolves_belongs_to_symbols
         
     | 
| 
      
 520 
     | 
    
         
            +
                assert_equal(parrots(:george), pirates(:blackbeard).parrot)
         
     | 
| 
      
 521 
     | 
    
         
            +
              end
         
     | 
| 
      
 522 
     | 
    
         
            +
             
     | 
| 
      
 523 
     | 
    
         
            +
              def test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same
         
     | 
| 
      
 524 
     | 
    
         
            +
                assert_equal(developers(:david), computers(:workstation).developer)
         
     | 
| 
      
 525 
     | 
    
         
            +
              end
         
     | 
| 
      
 526 
     | 
    
         
            +
             
     | 
| 
      
 527 
     | 
    
         
            +
              def test_supports_join_tables
         
     | 
| 
      
 528 
     | 
    
         
            +
                assert(pirates(:blackbeard).parrots.include?(parrots(:george)))
         
     | 
| 
      
 529 
     | 
    
         
            +
                assert(pirates(:blackbeard).parrots.include?(parrots(:louis)))
         
     | 
| 
      
 530 
     | 
    
         
            +
                assert(parrots(:george).pirates.include?(pirates(:blackbeard)))
         
     | 
| 
      
 531 
     | 
    
         
            +
              end
         
     | 
| 
      
 532 
     | 
    
         
            +
             
     | 
| 
      
 533 
     | 
    
         
            +
              def test_supports_inline_habtm
         
     | 
| 
      
 534 
     | 
    
         
            +
                assert(parrots(:george).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 535 
     | 
    
         
            +
                assert(parrots(:george).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 536 
     | 
    
         
            +
                assert(!parrots(:george).treasures.include?(treasures(:ruby)))
         
     | 
| 
      
 537 
     | 
    
         
            +
              end
         
     | 
| 
      
 538 
     | 
    
         
            +
             
     | 
| 
      
 539 
     | 
    
         
            +
              def test_supports_inline_habtm_with_specified_id
         
     | 
| 
      
 540 
     | 
    
         
            +
                assert(parrots(:polly).treasures.include?(treasures(:ruby)))
         
     | 
| 
      
 541 
     | 
    
         
            +
                assert(parrots(:polly).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 542 
     | 
    
         
            +
                assert(!parrots(:polly).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 543 
     | 
    
         
            +
              end
         
     | 
| 
      
 544 
     | 
    
         
            +
             
     | 
| 
      
 545 
     | 
    
         
            +
              def test_supports_yaml_arrays
         
     | 
| 
      
 546 
     | 
    
         
            +
                assert(parrots(:louis).treasures.include?(treasures(:diamond)))
         
     | 
| 
      
 547 
     | 
    
         
            +
                assert(parrots(:louis).treasures.include?(treasures(:sapphire)))
         
     | 
| 
      
 548 
     | 
    
         
            +
              end
         
     | 
| 
      
 549 
     | 
    
         
            +
             
     | 
| 
      
 550 
     | 
    
         
            +
              def test_strips_DEFAULTS_key
         
     | 
| 
      
 551 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEFAULTS) }
         
     | 
| 
      
 552 
     | 
    
         
            +
             
     | 
| 
      
 553 
     | 
    
         
            +
                # this lets us do YAML defaults and not have an extra fixture entry
         
     | 
| 
      
 554 
     | 
    
         
            +
                %w(sapphire ruby).each { |t| assert(parrots(:davey).treasures.include?(treasures(t))) }
         
     | 
| 
      
 555 
     | 
    
         
            +
              end
         
     | 
| 
      
 556 
     | 
    
         
            +
             
     | 
| 
      
 557 
     | 
    
         
            +
              def test_supports_label_interpolation
         
     | 
| 
      
 558 
     | 
    
         
            +
                assert_equal("frederick", parrots(:frederick).name)
         
     | 
| 
      
 559 
     | 
    
         
            +
              end
         
     | 
| 
      
 560 
     | 
    
         
            +
             
     | 
| 
      
 561 
     | 
    
         
            +
              def test_supports_polymorphic_belongs_to
         
     | 
| 
      
 562 
     | 
    
         
            +
                assert_equal(pirates(:redbeard), treasures(:sapphire).looter)
         
     | 
| 
      
 563 
     | 
    
         
            +
                assert_equal(parrots(:louis), treasures(:ruby).looter)
         
     | 
| 
      
 564 
     | 
    
         
            +
              end
         
     | 
| 
      
 565 
     | 
    
         
            +
             
     | 
| 
      
 566 
     | 
    
         
            +
              def test_only_generates_a_pk_if_necessary
         
     | 
| 
      
 567 
     | 
    
         
            +
                m = Matey.find(:first)
         
     | 
| 
      
 568 
     | 
    
         
            +
                m.pirate = pirates(:blackbeard)
         
     | 
| 
      
 569 
     | 
    
         
            +
                m.target = pirates(:redbeard)
         
     | 
| 
      
 570 
     | 
    
         
            +
              end
         
     | 
| 
      
 571 
     | 
    
         
            +
             
     | 
| 
      
 572 
     | 
    
         
            +
              def test_supports_sti
         
     | 
| 
      
 573 
     | 
    
         
            +
                assert_kind_of DeadParrot, parrots(:polly)
         
     | 
| 
      
 574 
     | 
    
         
            +
                assert_equal pirates(:blackbeard), parrots(:polly).killer
         
     | 
| 
      
 575 
     | 
    
         
            +
              end
         
     | 
| 
      
 576 
     | 
    
         
            +
            end
         
     | 
| 
      
 577 
     | 
    
         
            +
             
     | 
| 
      
 578 
     | 
    
         
            +
            class ActiveSupportSubclassWithFixturesTest < ActiveSupport::TestCase
         
     | 
| 
      
 579 
     | 
    
         
            +
              fixtures :parrots
         
     | 
| 
       16 
580 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 581 
     | 
    
         
            +
              # This seemingly useless assertion catches a bug that caused the fixtures
         
     | 
| 
      
 582 
     | 
    
         
            +
              # setup code call nil[]
         
     | 
| 
      
 583 
     | 
    
         
            +
              def test_foo
         
     | 
| 
      
 584 
     | 
    
         
            +
                assert_equal parrots(:louis), Parrot.find_by_name("King Louis")
         
     | 
| 
       19 
585 
     | 
    
         
             
              end
         
     | 
| 
       20 
586 
     | 
    
         
             
            end
         
     |