1. 13 1月, 2016 1 次提交
  2. 16 12月, 2015 1 次提交
  3. 30 10月, 2015 1 次提交
    • J
      FixtureSet.fixture_class_names should have no default value · 0c843640
      Jamis Buck 提交于
      Look at `TestFixtures.set_fixture_class`. As documented, it
      accepts a mapping of fixture identifiers (string or symbol) to Classes
      (the model classes that implement the named fixture).
      
      Look now at the initialization of `TestFixtures.fixture_class_names`.
      It defines a Hash, which will return a string by default (where the
      string is the estimated class name of the given fixture identifier).
      
      Now look at TestFixtures.load_fixtures. It calls `FixtureSet.create_fixtures`,
      passing in the mapping of `fixture_class_names`.
      
      Following this on to `FixtureSet.create_fixtures`, this instantiates a
      `FixtureSet::ClassCache`, passing in the map of class names.
      
      `ClassCache`, in turn, calls `insert_class` for each value in the cache.
      (Recall that `set_fixture_class` puts Class objects in there, while the
      default proc for the mapping puts String objects.)
      
      Look finally at `insert_class`. If the value is present, it checks to
      see if the value is a subclass of `AR::Base`. Fair enough...but wait!
      What if the value is a String? You get an exception, because a String
      instance cannot be compared with a Class.
      
      Judging from the implementation, it seems like the expected behavior
      here is for `fixture_class_names` to have no default proc. Look-ups are
      supposed to happen via `ClassCache`, with `fixture_class_names` existing
      solely as a repository for explicitly-registered class mappings.
      
      That is what this change does.
      0c843640
  4. 17 9月, 2015 1 次提交
  5. 12 9月, 2015 1 次提交
    • R
      Allow fixtures YAML files to set the model class in the file itself · 2acec465
      Roque Pinel 提交于
      Currently, `set_fixture_class` is only available using the
      `TestFixtures` concern and it is ignored for `rake db:fixtures:load`.
      Using the correct model class, it is possible for the fixture load
      to also load the associations from the YAML files (e.g., `:belongs_to`
      and `:has_many`).
      2acec465
  6. 27 8月, 2015 1 次提交
  7. 26 8月, 2015 1 次提交
  8. 13 8月, 2015 1 次提交
  9. 05 6月, 2015 1 次提交
  10. 28 5月, 2015 1 次提交
    • G
      Resolve enums in test fixtures · 908cfef6
      George Claghorn 提交于
      Currently, values for columns backing Active Record enums must be
      specified as integers in test fixtures:
      
          awdr:
            title: "Agile Web Development with Rails"
            status: 2
      
          rfr:
            title: "Ruby for Rails"
            status: <%= Book.statuses[:proposed] %>
      
      This is potentially confusing, since enum values are typically
      specified as symbols or strings in application code. To resolve the
      confusion, this change permits the use of symbols or strings to specify
      enum values:
      
          awdr:
            status: :published
      
      It is compatible with fixtures that specify enum values as integers.
      908cfef6
  11. 21 4月, 2015 1 次提交
    • A
      Rename association option :class to :anonymous_class · ac2b7a5c
      Andrew White 提交于
      In 1f006c an option was added called :class to allow passing anonymous
      classes to association definitions. Since using :class instead of
      :class_name is a fairly common typo even amongst experienced developers
      this can result in hard to debug errors arising in raise_on_type_mismatch?
      
      To fix this we're renaming the option from :class to :anonymous_class as
      that is a more correct description of what the option is for. Since this
      was an internal, undocumented option there is no need for a deprecation.
      
      Fixes #19659
      ac2b7a5c
  12. 17 3月, 2015 1 次提交
    • B
      Closes rails/rails#18864: Renaming transactional fixtures to transactional tests · 09658635
      Brandon Weiss 提交于
      I’m renaming all instances of `use_transcational_fixtures` to
      `use_transactional_tests` and “transactional fixtures” to
      “transactional tests”.
      
      I’m deprecating `use_transactional_fixtures=`. So anyone who is
      explicitly setting this will get a warning telling them to use
      `use_transactional_tests=` instead.
      
      I’m maintaining backwards compatibility—both forms will work.
      `use_transactional_tests` will check to see if
      `use_transactional_fixtures` is set and use that, otherwise it will use
      itself. But because `use_transactional_tests` is a class attribute
      (created with `class_attribute`) this requires a little bit of hoop
      jumping. The writer method that `class_attribute` generates defines a
      new reader method that return the value being set. Which means we can’t
      set the default of `true` using `use_transactional_tests=` as was done
      previously because that won’t take into account anyone using
      `use_transactional_fixtures`. Instead I defined the reader method
      manually and it checks `use_transactional_fixtures`. If it was set then
      it should be used, otherwise it should return the default, which is
      `true`. If someone uses `use_transactional_tests=` then it will
      overwrite the backwards-compatible method with whatever they set.
      09658635
  13. 01 3月, 2015 1 次提交
  14. 15 1月, 2015 1 次提交
    • V
      Fixes #18492 · 4ae59ebe
      Vipul A M 提交于
      - Add check for not deleting previously created fixtures, to overcome sti fixtures from multiple files
      - Added fixtures and fixtures test to verify the same
      
      - Fixed wrong fixtures duplicating data insertion in same table
      4ae59ebe
  15. 06 1月, 2015 1 次提交
  16. 21 11月, 2014 1 次提交
  17. 14 11月, 2014 1 次提交
  18. 29 10月, 2014 1 次提交
    • J
      Rely on through table name in has_many fixtures · 8e16a00d
      Joshua Cody 提交于
      Rather than using the association's join_table method, which
      constructs a table name from conventions, this should rely on the
      through reflection's table_name to be resilient to tables that were
      not automatically named.
      8e16a00d
  19. 07 10月, 2014 1 次提交
  20. 23 9月, 2014 2 次提交
  21. 28 8月, 2014 1 次提交
  22. 18 7月, 2014 1 次提交
  23. 11 6月, 2014 1 次提交
  24. 02 4月, 2014 1 次提交
    • M
      Revise 'sqlite3:' URL handling for smoother upgrades · f846828d
      Matthew Draper 提交于
      Restore the 4.0 behaviour for 'sqlite3:///', but deprecate it. We'll
      change to the absolute-path interpretation in 4.2.
      
      The current "correct" spellings for in-memory, relative, and absolute
      URLs, respectively, are:
      
          sqlite3::memory:
          sqlite3:relative/path
          sqlite3:/full/path
      
      Substantially reverses/defers fbb79b51.
      Uncovered by @guilleiguaran while investigating #14495, though that
      sounds like a different issue.
      f846828d
  25. 16 3月, 2014 1 次提交
    • E
      Extend fixture label replacement to allow string interpolation · f47421f2
      Eric Steele 提交于
      Allows fixtures to use their $LABEL as part of a string instead
      of limiting use to the entire value.
      
          mark:
            first_name: $LABEL
            username: $LABEL1973
            email: $LABEL@$LABELmail.com
      
          users(:mark).first_name # => mark
          users(:mark).username   # => mark1973
          users(:mark).email      # => mark@markmail.com
      f47421f2
  26. 09 2月, 2014 1 次提交
  27. 08 1月, 2014 1 次提交
  28. 16 11月, 2013 1 次提交
  29. 07 10月, 2013 1 次提交
    • F
      Just change ENV and restore it afterwards. · afd0a8ab
      Federico Ravasio 提交于
      Stubbing ENV[] is not safe outside MRI. At some point after the
      stubbing has occurred a backtrace is printed to the ActiveSupport
      warning log: there Rubinius accesses ENV['RBX_NOCOLOR'] to determine
      if it should print the backtrace with colors or not, causing the
      stub to fail. Other implementations might access ENV in a different
      way too, we just can't predict it.
      The only thing we can do here is to actually set the ENV with what
      we want and restore it afterwards.
      afd0a8ab
  30. 10 9月, 2013 2 次提交
  31. 08 9月, 2013 1 次提交
  32. 07 9月, 2013 1 次提交
  33. 27 8月, 2013 1 次提交
    • W
      Add config to method calls in fixtures. · 6223e206
      wangjohn 提交于
      Allows you to change your configuration for calls to
      `table_name_prefix`, `table_name_suffix`, and `pluralize_table_names`.
      The default configuration is still ActiveRecord::Base, but you are now
      able to change the configuration easily.
      6223e206
  34. 25 8月, 2013 1 次提交
    • W
      Removing instances of string class_names in fixtures. · bac384e8
      wangjohn 提交于
      Also, constantizing the default_fixture_model_name when it gets loaded
      in from the file. Later, when the class_name is passed to a new
      FixtureSet, a deprecation warning will occur if the class_name is a
      string.
      bac384e8
  35. 06 8月, 2013 1 次提交
  36. 02 7月, 2013 1 次提交
  37. 15 6月, 2013 1 次提交
    • Y
      fixture setup does not rely on `AR::Base.configurations`. · 6d10d64c
      Yves Senn 提交于
      As you can also configure your database connection using `ENV["DATABASE_URL"]`,
      the fixture setup can't reply on the `.configurations` Hash.
      
      As the fixtures are only loaded when ActiveRecord is actually used
      (`rails/test_help.rb`) it should be safe to drop the check for an existing configuration.
      6d10d64c
  38. 22 3月, 2013 1 次提交