Commit Graph

59028 Commits

Author SHA1 Message Date
Ryuta Kamizono
92c8f01580 Add an assertion to the tests that should be loaded the target.
These test cases tests exactly mutating loaded target.
2016-07-27 00:32:50 +09:00
Santiago Pastorino
c4b33a7796 Merge pull request #25929 from kamipo/load_target_is_public_method
`load_target` is a public method
2016-07-26 11:43:47 -03:00
Steven Harman
e4a4936244 Default to an empty collection if falsey given
This will ensure we attempt to render an empty collection, meaning we
don't actually render anything at all. Allowing `nil` or a falsey value
through results in calling `render_partial` rather than
`render_collection`, which isn't what we want.
2016-07-26 10:38:58 -04:00
Steven Harman
578096b971 Use Ruby >= 1.9 hash syntax as is the preference 2016-07-26 10:38:58 -04:00
Steven Harman
ae75930b59 Fix collection_from_options to allow Enumerators
An optimization was introduced in
27f4ffd11a
which tried to `#to_ary` the collection to prevent unnecessary queries
for ActiveRecord scopes/relations. If the given collection did not
respond to `#to_ary`, and empty collection was returned. That meant you
couldn't use collections built from `Enumerator` nor `Enumerable`.

With this change, `#collection_from_options` will attempt the
optimization, but fall back to passing along the given collection,
as-is.
2016-07-26 10:38:58 -04:00
Santiago Pastorino
c59715fa25 Merge pull request #25953 from kamipo/make_force_signal37_to_load_all_clients_of_firm_to_private
Make `force_signal37_to_load_all_clients_of_firm` to private
2016-07-26 11:30:43 -03:00
Santiago Pastorino
d6dfbe8396 Merge pull request #25936 from prathamesh-sonpatki/bump-arel
Bump Arel to fix few failing tests on Ruby 2.4 related to the Integer unification
2016-07-26 11:29:42 -03:00
Ryuta Kamizono
944c7b9818 Make force_signal37_to_load_all_clients_of_firm to private
This is not a test case.
2016-07-26 13:14:59 +09:00
Ryuta Kamizono
d31c2e2cf8 Extract type_casted_binds method
Because `type_cast` against `binds` always requires
`attr.value_for_database` and this pattern appears frequently.
2016-07-26 09:49:53 +09:00
Rafael França
245c64d428 Merge pull request #25950 from jules2689/master
Fix an exception where content-type is nil
2016-07-25 16:41:33 -03:00
Julian Nadeau
814ebb996d
Also yield in parameters for a nil content_mime_type 2016-07-25 11:32:49 -04:00
Sean Griffin
aa7a6047c2 Whoops, forgot the changelog entry for the previous commit 2016-07-25 11:13:01 -04:00
Sean Griffin
f0ddf87e4b Correct the behavior of virtual attributes on models loaded from the db
Previously we had primarily tested the behavior of these attributes by
calling `.new`, allowing this to slip through the cracks. There were a
few ways in which they were behaving incorrectly.

The biggest issue was that attempting to read the attribute would
through a `MissingAttribute` error. We've corrected this by returning
the default value when the attribute isn't backed by a database column.
This is super special cased, but I don't see a way to avoid this
conditional. I had considered handling this higher up in
`define_default_attribute`, but we don't have the relevant information
there as users can provide new defaults for database columns as well.

Once I corrected this, I had noticed that the attributes were always
being marked as changed. This is because the behavior of
`define_default_attribute` was treating them as assigned from
`Attribute::Null`.

Finally, with our new implementation, `LazyAttributeHash` could no
longer be marshalled, as it holds onto a proc. This has been corrected
as well. I've not handled YAML in that class, as we do additional work
higher up to avoid YAML dumping it at all.

Fixes #25787
Close #25841
2016-07-25 11:12:06 -04:00
Chetna Sharma
a9dabd6939 [ci skip] Add documentation for error using select with order 2016-07-25 18:40:31 +05:30
Xavier Noria
7ebef567ce systematic revision of =~ usage in AV
Where appropriate, prefer the more concise Regexp#match?,
String#include?, String#start_with?, or String#end_with?
2016-07-25 00:31:35 +02:00
Xavier Noria
11b463d8cb use \A and \z when you mean \A and \z
In Ruby ^ and $ mean start and end of *line*.

A regexp that validates an email should not check if
some line of the string looks like an email, and maybe
be surrounded by the entire Joyce's Ulysses. What the
regexp has to check is if the string itself looks like
an email.

This validator is used only in tests, the ^/$ anchors
implied no risk.
2016-07-24 21:42:19 +02:00
Xavier Noria
95b2a6abc7 adds missing requires 2016-07-24 21:29:29 +02:00
Xavier Noria
5a83f05424 systematic revision of =~ usage in AMo 2016-07-24 21:23:23 +02:00
Ryuta Kamizono
ceee776b5d Fix to CollectionProxy#load does load_target 2016-07-25 00:00:38 +09:00
Ryuta Kamizono
e703de17d8 Decouple statement cache from connection adapter
`StatementCache` is hard-coded in `cacheable_query` and be passed
`visitor` and `collector` from connection adapter. Simply it is
enough to pass a collected value.
2016-07-24 22:18:07 +09:00
प्रथमेश Sonpatki
56527bb737 Merge pull request #25928 from mechanicles/info-for-cache-fetch-block
Add proper description for `Rails.cache.fetch` [ci skip]
2016-07-24 10:13:41 +05:30
Santosh Wadghule
d4f1b8090a Proper description for Rails.cache.fetch [ci skip] 2016-07-24 09:37:44 +05:30
Prathamesh Sonpatki
1a50262b5b
Bump Arel to fix few failing tests on Ruby 2.4 related to the Integer unification
* Following tests were failing on Ruby edge 2.4 version -

- RelationTest#test_update_all_with_joins_and_offset_and_order:
- RelationTest#test_update_all_with_joins_and_offset:
- BasicsTest#test_no_limit_offset:
- CalculationsTest#test_offset_is_kept:
- ActiveRecord::CollectionCacheKeyTest#test_cache_key_for_queries_with_offset_which_return_0_rows:
- FinderTest#test_third_to_last:

* As Arel 7.1 supports Integer unification after https://github.com/rails/arel/pull/437 we can use it.
2016-07-24 09:17:45 +05:30
Xavier Noria
7714e83da0 removes spurious line 2016-07-24 00:50:24 +02:00
Xavier Noria
f9f39d5c42 give some love to this test file
It all started noticing some foo.method({ ... }) method calls
in passing. This is a whole pass modernizing this file.

While some string literals are edited where I touched code,
this pass does not uniformizes quotes. A ton are left untouched
on purposes. We have no defined style.
2016-07-23 23:15:26 +02:00
Xavier Noria
99cf755800 systematic revision of =~ usage in AR
Where appropriatei, prefer the more concise Regexp#match?,
String#include?, String#start_with?, or String#end_with?
2016-07-23 20:22:20 +02:00
Ryuta Kamizono
beb6b7add7 load_target is a public method
`send` is unnecessary.
2016-07-23 17:14:41 +09:00
Kasper Timm Hansen
1ca571cc47 Merge pull request #25908 from mechanicles/derives-from
Explain meaning of the code very well and Remove confusion. [ci skip]
2016-07-23 07:48:17 +02:00
Santosh Wadghule
8ad6260538 Explain meaning of the code very well and Remove confusion. [ci skip]
Code like `render(topics) => render("topics/topic")` adds confusion
for the readers. On first impression, that code feels like hash kind
of data, but it's not. So make it more clear and meaningful.
2016-07-23 09:56:35 +05:30
Rafael França
0020f1a4c9 Merge pull request #25914 from jmccartie/jm/not_in
Adds `not_in?` onto Object
2016-07-22 19:48:46 -03:00
Xavier Noria
92c60f87a6 revises a regexp
The exclamation mark is not a metacharacter.
2016-07-22 23:20:25 +02:00
Xavier Noria
cfc91c31aa systematic revision of =~ usage in AS
Where appropriate prefer the more concise Regexp#match?, String#include?,
String#start_with?, and String#end_with?
2016-07-22 23:13:49 +02:00
Xavier Noria
aea0e5cd70 adds require for Regexp#match? 2016-07-22 00:33:02 +02:00
Xavier Noria
21c6f810ac revises style 2016-07-22 00:31:09 +02:00
Xavier Noria
9256bbbbd7 the infamous typo only seen in GitHub's diff [ci skip] 2016-07-22 00:27:39 +02:00
Jon McCartie
4db6ac29f2 Adds not_in? onto Object 2016-07-21 17:23:33 -05:00
Xavier Noria
929a650080 performance boost for String#blank? in Ruby 2.4
Some casual benchmarks showed a 2x factor.

All credit goes to @nurse.
2016-07-22 00:16:24 +02:00
Xavier Noria
575dbeeefc define Range#match? if Ruby < 2.4
See the rationale in the documentation included in this patch.

We are going to gradually introduce this predicate in the code base.
2016-07-22 00:15:52 +02:00
Chris Arcand
31fbbb7fac
Fix 'defaults' option for root route
The merging of the 'defaults' option was moved up the stack in e852daa
This allows us to see where these options originate from the standard
HttpHelpers (get, post, patch, put, delete)

Unfortunately this move didn't incorporate the 'root' method, which has
always allowed the same 'defaults' option before.
2016-07-21 15:59:05 -05:00
Bart de Water
d4ea18a8cb
Allow MessageEncryptor to take advantage of authenticated encryption modes
AEAD modes like `aes-256-gcm` provide both confidentiality and data authenticity, eliminating the need to use MessageVerifier to check if the encrypted data has been tampered with.

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
2016-07-21 10:38:33 -07:00
Xavier Noria
d5f57dc227 Merge pull request #25911 from juno/fix-comment-indent
Fix incorrect indentation in method comment
2016-07-21 17:09:45 +02:00
Junya Ogura
60b6f546a6 Fix incorrect indentation in method comment [ci skip] 2016-07-21 23:42:45 +09:00
Iain Beeston
a11abf19ee Removed reference to callback_terminator.rb in docs
That file has been removed and replaced with new_framework_defaults.rb
2016-07-21 13:00:17 +01:00
Xavier Noria
58283b5acd explain the meaning of some RuboCop config options [ci skip]
For consistency mainly.

Also, some have a name that could make the reader think they
enforce the opposite of what they do, because the default is
not visible there.
2016-07-21 13:52:30 +02:00
Yves Senn
0800e5dcad Merge pull request #25907 from gsamokovarov/lock-web-console-for-5.0
Enforce minimal web-console version for Rails 5
2016-07-21 09:54:28 +02:00
Genadi Samokovarov
e072db7737 Enforce minimal web-console version for Rails 5
I dropped the version constraint in web-console with the idea it will be
easier to upgrade the console between Rails releases. However, issues
like #25899 started popping up.

I'm reintroducing the constraint, but this time, I don't set an upper
limit to the major version. This will keep the web-console in a version
that always works for the current Rails version and can be easily
upgraded to the last one with `bundle update`.

We may need to backport this for Rails 5.0.1.

Fixes #25899.
2016-07-21 10:46:12 +03:00
Kasper Timm Hansen
cf5bc0dd53 Merge pull request #25616 from ignatiusreza/callable_cache_key
Bring back support for callable cache key when rendering collection
2016-07-21 08:59:41 +02:00
Ignatius Reza
714c763dad Bring back support for callable cache_key on collection rendering 2016-07-21 08:42:56 +09:00
Rafael França
b334c19c07 Merge pull request #25902 from etiennebarrie/remove-tabs-before-commands
Remove tab chars before commands to be run
2016-07-20 18:46:58 -03:00
Étienne Barrié
34672e669d Remove tab chars before commands to be run 2016-07-20 17:01:28 -04:00