1. 21 7月, 2015 1 次提交
  2. 20 7月, 2015 5 次提交
    • S
      Fix minor typo in test name · 17b84600
      Sean Griffin 提交于
      17b84600
    • R
      Fix state being carried over from previous transaction · 12b0b26d
      Roque Pinel 提交于
      This clears the transaction record state when the transaction finishes
      with a `:committed` status.
      
      Considering the following example where `name` is a required attribute.
      Before we had `new_record?` returning `true` for a persisted record:
      
      ```ruby
        author = Author.create! name: 'foo'
        author.name = nil
        author.save        # => false
        author.new_record? # => true
      ```
      12b0b26d
    • S
      Correctly ignore `mark_for_destruction` without `autosave` · c0ef95a1
      Sean Griffin 提交于
      As per the docs, `mark_for_destruction` should do nothing if `autosave`
      is not set to true. We normally persist associations on a record no
      matter what if the record is a new record, but we were always skipping
      records which were `marked_for_destruction?`.
      
      Fixes #20882
      c0ef95a1
    • S
      Fix the test that was broken by #16445 rather than deleting it · 8cd1d5a4
      Sean Griffin 提交于
      Since the counter cache was properly being updated, the model became
      stale. Simply reloading the model before attempting to destroy is
      sufficient for this case. I believe this is enough of an edge case to be
      a valid change to the tests, even though it represents a potential
      breaking change.
      8cd1d5a4
    • S
      Fix counter_cache for polymorphic associations · 0ed096dd
      Stefan Kanev 提交于
      Also removes a false positive test that depends on the fixed bug:
      
      At this time, counter_cache does not work with polymorphic relationships
      (which is a bug). The test was added to make sure that no
      StaleObjectError is raised when the car is destroyed. No such error is
      currently raised because the lock version is not incremented by
      appending a wheel to the car.
      
      Furthermore, `assert_difference` succeeds because `car.wheels.count`
      does not check the counter cache, but the collection size. The test will
      fail if it is replaced with `car.wheels_count || 0`.
      0ed096dd
  3. 18 7月, 2015 3 次提交
    • T
    • S
      Ensure cyclic associations w/ autosave don't cause duplicate errors · 7550f0a0
      Sean Griffin 提交于
      This code is so fucked. Things that cause this bug not to replicate:
      
      - Defining the validation before the association (we end up calling
        `uniq!` on the errors in the autosave validation)
      - Adding `accepts_nested_attributes_for` (I have no clue why. The only
        thing it does that should affect this is adds `autosave: true` to the
        inverse reflection, and doing that manually doesn't fix this).
      
      This solution is a hack, and I'm almost certain there's a better way to
      go about it, but this shouldn't cause a huge hit on validation times,
      and is the simplest way to get it done.
      
      Fixes #20874.
      7550f0a0
    • S
      Ensure that `ActionController::Parameters` can still be passed to AR · 68af6361
      Sean Griffin 提交于
      Since nested hashes are also instances of
      `ActionController::Parameters`, and we're explicitly looking to work
      with a hash for nested attributes, this caused breakage in several
      points.
      
      This is the minimum viable fix for the issue (and one that I'm not
      terribly fond of). I can't think of a better place to handle this at the
      moment. I'd prefer to use some sort of solution that doesn't special
      case AC::Parameters, but we can't use something like `to_h` or `to_a`
      since `Enumerable` adds both.
      
      While I've added a trivial test case for verifying this fix in
      isolation, we really need better integration coverage to prevent
      regressions like this in the future. We don't actually have a lot of
      great places for integration coverage at the moment, so I'm deferring it
      for now.
      
      Fixes #20922.
      68af6361
  4. 17 7月, 2015 1 次提交
    • P
      Silence deprecation warning from force reload · b5b89796
      Prem Sichanugrist 提交于
      We deprecate the support for passing an argument to force reload in
      6eae366d. That led to several
      deprecation warning when running Active Record test suite.
      
      This commit silence the warnings by properly calling `#reload` on the
      association proxy or on the association object instead. However, there
      are several places that `ActiveSupport::Deprecation.silence` are used as
      those tests actually tests the force reload functionality and will be
      removed once `master` is targeted next minor release (5.1).
      b5b89796
  5. 16 7月, 2015 1 次提交
    • P
      Deprecate force association reload by passing true · 6eae366d
      Prem Sichanugrist 提交于
      This is to simplify the association API, as you can call `reload` on the
      association proxy or the parent object to get the same result.
      
      For collection association, you can call `#reload` on association proxy
      to force a reload:
      
          @user.posts.reload   # Instead of @user.posts(true)
      
      For singular association, you can call `#reload` on the parent object to
      clear its association cache then call the association method:
      
          @user.reload.profile   # Instead of @user.profile(true)
      
      Passing a truthy argument to force association to reload will be removed
      in Rails 5.1.
      6eae366d
  6. 14 7月, 2015 1 次提交
    • J
      Replaced `ActiveSupport::Concurrency::Latch` with concurrent-ruby. · 284a9ba8
      Jerry D'Antonio 提交于
      The concurrent-ruby gem is a toolset containing many concurrency
      utilities. Many of these utilities include runtime-specific
      optimizations when possible. Rather than clutter the Rails codebase with
      concurrency utilities separate from the core task, such tools can be
      superseded by similar tools in the more specialized gem. This commit
      replaces `ActiveSupport::Concurrency::Latch` with
      `Concurrent::CountDownLatch`, which is functionally equivalent.
      284a9ba8
  7. 08 7月, 2015 1 次提交
    • R
      Fix regression caused by a01d164b · 1b4399df
      Rafael Mendonça França 提交于
      When preload is used in a default scope the preload_values were
      returning nested arrays and causing the preloader to fail because it
      doesn't know how to deal with nested arrays. So before calling preload!
      we need to splat the arguments.
      
      This is not needed to includes because it flatten its arguments.
      1b4399df
  8. 07 7月, 2015 1 次提交
  9. 03 7月, 2015 1 次提交
    • E
      Use default model enum in fixtures if not defined · eff3a317
      eileencodes 提交于
      After 908cfef6 was introduced fixtures that did not set an enum would
      return nil instead of the default enum value.
      
      The fixtures should assume the default if a different enum is not
      defined.
      
      The change checks first if the enum is defined in the fixture before
      setting it based on the fixture.
      eff3a317
  10. 01 7月, 2015 1 次提交
    • S
      Correct through associations using scopes · bc6ac860
      Sean Griffin 提交于
      The changes introduced to through associations in c80487eb were quite
      interesting. Changing `relation.merge!(scope)` to `relation =
      relation.merge(scope)` should in theory never cause any changes in
      behavior. The subtle breakage led to a surprising conclusion.
      
      The old code wasn't doing anything! Since `merge!` calls
      `instance_exec` when given a proc, and most scopes will look something
      like `has_many :foos, -> { where(foo: :bar) }`, if we're not capturing
      the return value, it's a no-op. However, removing the `merge` causes
      `unscope` to break.
      
      While we're merging in the rest of the chain elsewhere, we were never
      merging in `unscope` values, causing a breakage on associations where a
      default scope was being unscoped in an association scope (yuk!). This is
      subtly related to #20722, since it appears we were previously relying on
      this mutability.
      
      Fixes #20721.
      Fixes #20727.
      bc6ac860
  11. 27 6月, 2015 1 次提交
    • P
      Add reversible syntax for change_column_default · a4128725
      Prem Sichanugrist 提交于
      Passing `:from` and `:to` to `change_column_default` makes this command
      reversible as user has defined its previous state.
      
      So, instead of having the migration command as:
      
          change_column_default(:posts, :state, "draft")
      
      They can write it as:
      
          change_column_default(:posts, :state, from: nil, to: "draft")
      a4128725
  12. 25 6月, 2015 2 次提交
  13. 24 6月, 2015 1 次提交
  14. 22 6月, 2015 2 次提交
  15. 20 6月, 2015 2 次提交
  16. 17 6月, 2015 1 次提交
  17. 15 6月, 2015 1 次提交
    • Y
      make `remove_index :table, :column` reversible. · 0e928de3
      Yves Senn 提交于
      This used to raise a `IrreversibleMigration` error (since #10437).
      However since `remove_index :table, :column` is probably the most basic
      use-case we should make it reversible again.
      
      Conflicts:
      	activerecord/CHANGELOG.md
      0e928de3
  18. 14 6月, 2015 1 次提交
  19. 13 6月, 2015 2 次提交
  20. 12 6月, 2015 4 次提交
  21. 11 6月, 2015 1 次提交
  22. 05 6月, 2015 2 次提交
    • S
      Return a `Point` object from the PG Point type · 9f4a3fd7
      Sean Griffin 提交于
      This introduces a deprecation cycle to change the behavior of the
      default point type in the PostgreSQL adapter. The old behavior will
      continue to be available for the immediate future as `:legacy_point`.
      
      The current behavior of returning an `Array` causes several problems,
      the most significant of which is that we cannot differentiate between an
      array of points, and a point itself in the case of a column with the
      `point[]` type.
      
      The attributes API gives us a reasonable way to have a proper
      deprecation cycle for this change, so let's take advantage of it. If we
      like this change, we can also add proper support for the other geometric
      types (line, lseg, box, path, polygon, and circle), all of which are
      just aliases for string today.
      
      Fixes #20441
      9f4a3fd7
    • V
  23. 04 6月, 2015 1 次提交
    • G
      Apply Active Record suppression to all saves · ac002395
      George Claghorn 提交于
      It was not being applied to creates and updates attempted through the
      non-bang save methods. This means that, for example, creation of
      records for singular associations through the `create_*` methods was
      not appropriately ignored in .suppress blocks.
      ac002395
  24. 02 6月, 2015 2 次提交
  25. 01 6月, 2015 1 次提交
    • Y
      Map :bigint as NUMBER(19) sql_type by using `:limit => 19` for Oracle · a9e6e6e0
      Yasuo Honda 提交于
      since NUMBER(8) is not enough to store the maximum number of bigint.
      Oracle NUMBER(p,0) as handled as integer
      because there is no dedicated integer sql data type exist in Oracle database.
      
      Also NUMBER(p,s) precision can take up to 38. p means the number of digits, not the byte length.
      bigint type needs 19 digits as follows.
      
      	$ irb
      	2.2.2 :001 > limit = 8
      	 => 8
      	2.2.2 :002 > maxvalue_of_bigint = 1 << ( limit * 8 - 1)
      	 => 9223372036854775808
      	2.2.2 :003 > puts maxvalue_of_bigint.to_s.length
      	19
      	 => nil
      	2.2.2 :004 >
      a9e6e6e0