Commit Graph

60050 Commits

Author SHA1 Message Date
Rafael França
95ea51e97b Merge pull request #26969 from y-yagi/remove_unused_requires
remove unused require
2016-11-05 13:21:42 -04:00
Jon Moss
b76a89c1eb Merge pull request #26971 from damireh/patch-1
Use local variable instead of instance variable [ci skip]
2016-11-05 11:00:30 -04:00
Daniel Amireh
b49e601e3a Use local variable instead of instance variable [ci skip]
Update render yield docs to use `search` local variable instead of `@q` instance variable
2016-11-05 14:19:28 +01:00
Akira Matsuda
a3478f1685 Tweaking some test data due to sprintf behavior change in 2.4
2.3: sprintf('%0.1f', 5.55)  #=> "5.5"
2.4: sprintf('%0.1f', 5.55)  #=> "5.6"

see: 6ed8c79ddb and
295f60b94d
2016-11-05 16:19:17 +09:00
Akira Matsuda
5e758de1a5 Show what was the error when assertion has failed
this test case fails with ruby 2.4, so we want to see what's actually happening
2016-11-05 15:54:22 +09:00
Akira Matsuda
51e991f0b2 Less method invocation 2016-11-05 15:35:40 +09:00
yuuji.yaginuma
9d700ad625 remove unused require
YAML and ERB were removed at 971d510
2016-11-05 14:24:05 +09:00
Aaron Patterson
a432e6dba4 Merge pull request #26967 from headius/bad_threading_test
Use different name for main and thread connection variable.
2016-11-04 12:03:53 -07:00
Charles Oliver Nutter
2646c1021a Use different name for main and thread connection variable.
Under JRuby, the updates of the one shared variable interleaved,
causing threads to pick up each others' connections. I'm amazed
this worked on MRI.
2016-11-04 14:00:02 -05:00
Guillermo Iguaran
af34d2f290 Merge pull request #26965 from rothhound/update_sqlite3
Update sqlite3
2016-11-04 11:25:18 -05:00
Gianfranco Montoya
13441a77a6 Update sqlite3 2016-11-04 11:12:28 -05:00
Arthur Nogueira Neves
db8b40b7f5 Merge pull request #26536 from y-yagi/change_increment_and_decrement_to_public_api
change `MemCacheStore#increment` and `MemCacheStore#decrement` to public API [ci skip]
2016-11-04 10:27:55 -04:00
Sean Griffin
98faa2a6a1 Don't assign default attributes until after loading schema
If the call to `.define_attribute_methods` actually ends up loading the
schema (*very* hard to do, as it requires the object being created
without `allocate` having been called, but it can be done by manually
calling `initialize` from inside `marshal_load` if you're crazy), the
value of `_default_attributes` will change from that call.
2016-11-03 13:57:13 -04:00
Arthur Nogueira Neves
a8482138a4 Merge pull request #26455 from kamipo/move_test_quoting_classes
Move `test_quoting_classes` into `test/cases/quoting_test.rb`
2016-11-03 12:22:56 -04:00
Arthur Nogueira Neves
264566a1b5 Merge pull request #24202 from Sen-Zhang/fix_datetime_error
fix datatime error
2016-11-03 12:19:01 -04:00
Daniel E. Garcia Shulman
032ab94332 Fixes TypeError Exception when cache counter value equals nil (#26940)
* Fixes TypeError when cache counter value equals nil

* Test case for counter cache on unloaded has_many association
2016-11-02 15:45:54 -04:00
Akira Matsuda
7b0b119c50 Use tr instead of gsub 2016-11-02 16:59:53 +09:00
Guillermo Iguaran
da23e125f8 Merge pull request #26951 from y-yagi/fix_ruby_warning
remove warning from railtie
2016-11-01 23:26:08 -05:00
yuuji.yaginuma
34530f5bd5 remove warning from railtie
This removes the following warnings.

```ruby
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @load_console not initialized
rails/railties/lib/rails/railtie.rb:186: warning: instance variable @rake_tasks not initialized
```
2016-11-02 11:08:03 +09:00
Sen-Zhang
9bf4583241 fix datatime error 2016-11-01 18:17:26 -07:00
Arthur Neves
9ebb3558f4
Make register_block_for private 2016-11-01 19:24:10 -04:00
Sean Griffin
7bb28a0df2 Merge pull request #26950 from bouk/exclude-dbmigrate
Don't put db:migrate and db:setup in binfiles if activerecord is excluded
2016-11-01 15:10:24 -04:00
Bouke van der Bijl
de08be6af6
Don't put db:migrate and db:setup in binfiles if activerecord is excluded 2016-11-01 14:29:29 -04:00
Sean Griffin
4e8f1ba242 Merge pull request #26451 from kamipo/remove_target_uniq_size
Remove unnecessary `target.uniq.size` in `CollectionAssociation#size`
2016-11-01 14:20:17 -04:00
Sean Griffin
8632efd8db Merge pull request #26453 from kamipo/remove_unused_internal_dependent_option
Remove unused internal `:dependent` option in `CollectionAssociation#delete`
2016-11-01 14:19:08 -04:00
Sean Griffin
c7adc610f0 Allow autosave: true to be used with inverse of
With the changes in #25337, double save bugs are pretty much impossible,
so we can just lift this restriction with pretty much no change. There
were a handful of cases where we were relying on specific quirks in
tests that had to be updated. The change to has_one associations was due
to a particularly interesting test where an autosaved has_one
association was replaced with a new child, where the child failed to
save but the test wanted to check that the parent id persisted to `nil`.

I think this is almost certainly the wrong behavior, and I may change
that behavior later. But ultimately the root cause was because we never
remove the parent in memory when nullifying the child. This makes #23197
no longer needed, but it is what we'll do to fix some issues on 5.0

Close #23197
2016-11-01 13:28:56 -04:00
Sean Griffin
29b3b5dd8e Merge pull request #25337 from sgrif/sg-changes-in-callbacks
Deprecate the behavior of AR::Dirty inside of after_(create|update|save) callbacks
2016-11-01 13:17:58 -04:00
Sean Griffin
16ae3db5a5 Deprecate the behavior of AR::Dirty inside of after_(create|update|save) callbacks
We pretty frequently get bug reports that "dirty is broken inside of
after callbacks". Intuitively they are correct. You'd expect
`Model.after_save { puts changed? }; model.save` to do the same thing as
`model.save; puts model.changed?`, but it does not.

However, changing this goes much farther than just making the behavior
more intuitive. There are a _ton_ of places inside of AR that can be
drastically simplified with this change. Specifically, autosave
associations, timestamps, touch, counter cache, and just about anything
else in AR that works with callbacks have code to try to avoid "double
save" bugs which we will be able to flat out remove with this change.

We introduce two new sets of methods, both with names that are meant to
be more explicit than dirty. The first set maintains the old behavior,
and their names are meant to center that they are about changes that
occurred during the save that just happened. They are equivalent to
`previous_changes` when called outside of after callbacks, or once the
deprecation cycle moves.

The second set is the new behavior. Their names imply that they are
talking about changes from the database representation. The fact that
this is what we really care about became clear when looking at
`BelongsTo.touch_record` when tests were failing. I'm unsure that this
set of methods should be in the public API. Outside of after callbacks,
they are equivalent to the existing methods on dirty.

Dirty itself is not deprecated, nor are the methods inside of it. They
will only emit the warning when called inside of after callbacks. The
scope of this breakage is pretty large, but the migration path is
simple. Given how much this can improve our codebase, and considering
that it makes our API more intuitive, I think it's worth doing.
2016-11-01 13:16:33 -04:00
Arthur Neves
4a8edc0d82
Merge PR #26052 2016-11-01 12:37:23 -04:00
Rafael Fidelis
8360d9944b
Added register_block method to register rake_tasks, generators, console & runner blocks
fixing @generators var initialization

pre initializing variables values

Changing from var init to symbol to instance var get/set
2016-11-01 12:34:38 -04:00
Kasper Timm Hansen
6b5ad4979e Merge pull request #26943 from colleenmcguckin/testing_typo
fix typo in Rails Test Runner section
2016-10-31 20:24:21 +01:00
colleenmcguckin
700623936e
fix typo in Rails Test Runner section 2016-10-31 12:18:20 -07:00
Andrew White
8931916f4a Ensure duration parsing is consistent across DST changes
Previously `ActiveSupport::Duration.parse` used `Time.current` and
`Time#advance` to calculate the number of seconds in the duration
from an arbitrary collection of parts. However as `advance` tries to
be consistent across DST boundaries this meant that either the
duration was shorter or longer depending on the time of year.

This was fixed by using an absolute reference point in UTC which
isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000
was chosen for no other reason that it seemed appropriate.

Additionally, duration parsing should now be marginally faster as we
are no longer creating instances of `ActiveSupport::TimeWithZone`
every time we parse a duration string.

Fixes #26941.
2016-10-31 17:25:43 +00:00
Guillermo Iguaran
3c9eb704e8 Merge pull request #26838 from Cohen-Carlisle/activerecord-slice-array-args
allow ActiveRecord::Core#slice to use array arg
2016-10-31 10:31:00 -05:00
Cohen Carlisle
1d6b62026b allow ActiveRecord::Core#slice to use array arg 2016-10-31 11:14:45 -04:00
Arthur Nogueira Neves
7056273845 Merge pull request #23094 from yui-knk/fix_ar_test_comment
Fix the order of `create_table` to match a comment about `:inverse_of…
2016-10-31 10:54:26 -04:00
प्रथमेश Sonpatki
e39e7112bd Merge pull request #26938 from riseshia/patch-1
Remove `Rack::Runtime from console log [ci skip]
2016-10-31 14:32:28 +05:30
Shia
e7bb3cd4ae Remove `Rack::Runtime from console log [ci skip] 2016-10-31 17:53:52 +09:00
Andrew White
7305ac20b4 Merge pull request #26935 from y-yagi/fix_ruby_warning
remove warning from big integer test
2016-10-31 07:01:55 +00:00
Guillermo Iguaran
516344d01f Merge pull request #26936 from caramelcat/add-missing-space
Add missing space in Migrations guide [ci skip]
2016-10-30 22:56:00 -05:00
Benny
32d0d971eb Add missing space in Migrations guide [ci skip] 2016-10-31 11:32:29 +08:00
yui-knk
4360ecf7df Remove a confusing comment
These comment sometimes explain a face which does not match
the face.
2016-10-31 10:27:01 +09:00
yui-knk
7808a90990 Fix the order of create_table to match a comment about :inverse_of options
In ActiveRecord test :men, :faces, :interests and :zines tables are
used for `:inverse_of` test cases, not `:wheels`.
2016-10-31 10:26:09 +09:00
yuuji.yaginuma
c33c03e80c remove warning from big integer test
This removes the following warnings.

```
activemodel/test/cases/type/big_integer_test.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```
2016-10-31 09:10:51 +09:00
Jon Moss
1f63d09ad7 Merge pull request #26932 from y-yagi/update_doc_about_assets_digest
update doc about assets digest class [ci skip]
2016-10-29 21:05:57 -04:00
yuuji.yaginuma
8ee7d5e1fc update doc about assets digest class [ci skip]
The default digest class changed to SHA256 in sprockets 3.0.
Ref: https://github.com/sstephenson/sprockets/pull/647
2016-10-30 09:34:27 +09:00
Ryuta Kamizono
b6ddaa4266 Remove unnecessary target.uniq.size in CollectionAssociation#size
If `association_scope` have `distinct_value`, same record cannot exist
in `target`.

https://github.com/rails/rails/blob/v5.0.0/activerecord/lib/active_record/associations/collection_association.rb#L419-L424

```ruby
      def add_to_target(record, skip_callbacks = false, &block)
        if association_scope.distinct_value
          index = @target.index(record)
        end
        replace_on_target(record, index, skip_callbacks, &block)
      end
```
2016-10-29 17:53:33 +09:00
Ryuta Kamizono
f7f66e2ba9 Move test_quoting_classes into test/cases/quoting_test.rb 2016-10-29 16:39:24 +09:00
Ryuta Kamizono
5f9051c341 Remove unused internal :dependent option in CollectionAssociation#delete
The internal `:dependent` option was introduced at #10604.
But currently unused.
2016-10-29 16:38:29 +09:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00