Commit Graph

17779 Commits

Author SHA1 Message Date
Kazuhiro Sera
dcdbcdf81c Fix a wrong correction 2018-08-08 22:09:04 +09:00
Kazuhiro Sera
52919f3d13 Fix the obvious typos detected by github.com/client9/misspell 2018-08-08 21:55:46 +09:00
Richard Schneeman
a2b9768792
Merge pull request #33454 from azbshiri/extend-affects-nested-attributes
Call build when extend with nested attributes defined
2018-08-04 19:05:02 -05:00
Richard Schneeman
3bcdd09ed4
Merge pull request #33511 from albertoalmagro/change-references-from-rake-to-rails-command
Change references from Rake task to Rails command
2018-08-04 19:00:29 -05:00
Ryuta Kamizono
2088b10b1f retrieve_connection_pool return a pool, not a connection 2018-08-03 06:43:03 +09:00
Alireza Bashiri
dc16cdd89a Call build when extend with nested attributes defined
What?
From now on when `accepts_nested_attributes_for` defined and `extend` option
added the overwritten `build` method being called.

[Alireza Bashiri, Martins Polakovs]
2018-08-02 08:27:03 +04:30
Britni Alexander
7157067eb2 don't establish connection test_database since it gets established in load_schema 2018-08-01 19:41:07 -05:00
Alberto Almagro
67265a3ab0 [ci skip] Change references from Rake task to Rails command
This commit follows the path we started at commit #ea4f0e2
and continued at PR #33229.
2018-08-01 22:44:53 +02:00
Britni Alexander
e6173c98e8 use load_schema instead of migrate for parallel testing 2018-07-31 21:24:29 -04:00
Ryuta Kamizono
25760a4921 Revert "Merge pull request #24131 from brchristian/limit_and_primary_key"
This reverts commit d162188dd662a7d9f62ba8431474f50bc35e3e93, reversing
changes made to 3576782888c307e3e192c44e332b957cd1174128.

Reason: #24131 conflicts the #5153's default order contract, it means
that existing apps would be broken by that change.

We don't want to break existing apps without a deprecation cycle.
2018-08-01 05:32:43 +09:00
Ryuta Kamizono
673cf4f13b Add test case for the #5153's default order contract 2018-08-01 05:30:02 +09:00
Ryuta Kamizono
c83e30da27 Avoid extra scoping when using Relation#update
Since 9ac7dd4, class level `update`, `destroy`, and `delete` were placed
in the `Persistence` module as class methods.

But `Relation#update` without passing ids which was introduced at #11898
is not a class method, and it was caused the extra scoping regression
#33470.

I moved the relation method back into the `Relation` to fix the
regression.

Fixes #33470.
2018-07-31 08:31:46 +09:00
George Claghorn
59c3ed1b3f MySQL: Raise ActiveRecord::InvalidForeignKey for foreign-key constraint violations on delete 2018-07-30 09:12:55 -04:00
Ryuta Kamizono
66da5ea128 Extract Relation#bind_attribute for internal use
To make it easier to construct boundable predicate.
2018-07-30 00:57:44 +09:00
Ryuta Kamizono
975fa15b47 Extract Relation#update_counters for internal use
The target object for counter cache is not always determined by the
primary key value on the model. I'd like to extract `update_couters`
onto the `Relation` for the internal use.
2018-07-30 00:03:16 +09:00
Bart de Water
27c6c07116 Fix TypeError: no implicit conversion of Arel::Attributes::Attribute into String 2018-07-28 19:17:15 -04:00
Bart de Water
5b81bb1567 Fix test failures due to Performance/RegexpMatch correction
`5 =~ /\d/` returns nil, but Integer doesn't have a `match?` method.
2018-07-28 18:56:22 -04:00
Bart de Water
eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Kasper Timm Hansen
8741052ba2
Don't expose configuration for a test.
Clean up some concepts in the code while we're here.
2018-07-28 16:17:56 +02:00
lsylvester
845cbb4bb2 Avoid logging ActiveRecord::LogSubscriber as the query source when the source is ignored (#33455) 2018-07-28 15:50:03 +02:00
Yannick Schutz
36f28fd818 PostgreSQL 10 new relkind for partitioned tables (#31336)
* PostgreSQL 10 new relkind for partitioned tables

Starting with PostgreSQL 10, we can now have partitioned tables natively

* Add comment

* Remove extra space

* Add test for partition table in postgreSQL10

* Select 'p' for "BASE TABLE" and add a test case
to support PostgreSQL 10 partition tables

* Address RuboCop offense

* Addressed incorrect `postgresql_version`

Fixes #33008.

[Yannick Schutz & Yasuo Honda & Ryuta Kamizono]
2018-07-27 10:09:00 +09:00
bogdanvlviv
09ec075f1e
Remove Rubocop's comments from Rails code base
PR#32381 added Rubocop's comments to some tests files in order to
exclude `Performance/RedundantMerge`.

Turn off `Performance` cops for tests files via `Exclude`
in `.rubocop.yml`.

Context https://github.com/rails/rails/pull/32381#discussion_r205212331
2018-07-26 23:37:31 +03:00
Richard Schneeman
91fd679710
Merge pull request #32381 from q-centrix/update-codeclimate-configs
Turn on performance based cops
2018-07-25 16:00:33 -05:00
Ryuta Kamizono
c02f3578c1 Normalize time value not to be affected by summer time
Follow up of #33358 for SQLite3.
2018-07-25 09:46:39 +09:00
Matthew Draper
ec387c6dd9
Merge pull request #33229 from albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails
Prefer rails command over bin/rails
2018-07-25 04:10:29 +09:30
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Dillon Welch
d108288c2f
Turn on performance based cops
Use attr_reader/attr_writer instead of methods

method is 12% slower

Use flat_map over map.flatten(1)

flatten is 66% slower

Use hash[]= instead of hash.merge! with single arguments

merge! is 166% slower

See https://github.com/rails/rails/pull/32337 for more conversation
2018-07-23 15:37:06 -07:00
Ryuta Kamizono
a4398e412c Merge pull request #30919 from seanlinsley/17622-before_save_strict_arguments
Add strict argument checking to ActiveRecord callbacks
2018-07-23 04:19:37 +09:00
Sean Linsley
dfb0e4b3dc add strict argument checking to ActiveRecord callbacks
This ends up adding it to all save-related callbacks defined in `ActiveRecord::DefineCallbacks`, including e.g. `after_create`. Which should be fine: they didn't support `:on` in the first place.
2018-07-22 12:51:47 -05:00
George Claghorn
97321956e6
Merge pull request #33415 from orhantoy/feature/docs-consistent-hash-syntax
[ci skip] Use consistent hash syntax in AR docs
2018-07-22 10:42:27 -04:00
Orhan Toy
68e209adfa [ci skip] Tidy up formatting of examples
The consecutive verbatim blocks were being merged making the output look weird.
2018-07-22 15:25:21 +02:00
Orhan Toy
57309c752e [ci skip] Use consistent hash syntax in AR docs
The examples with `.where` uses hash w/ symbol keys so it would be more consistent to also do this with `.new`.
Also from my experience the hash w/ symbol keys is more widely used with `where/new/create` etc. in ActiveRecord.
2018-07-22 14:18:47 +02:00
utilum
82e42c1bd8 Replace permissive Mocha expectations
Step 6 in #33162

When using Mocha like this:

`ActiveRecord::Base.expects(:establish_connection).with(some_args)`,

the expectations created look something like this:

```
@expectations=
          [#<Expectation:0x561350d968e0 expected exactly once, not yet invoked: ActiveRecord::Base.establish_connection("adapter" => "mysql2", "database" => nil) >,
           #<Expectation:0x561350dab8f8 allowed any number of times, not yet invoked: ActiveRecord::Base.establish_connection(any_parameters) >,
           #<Expectation:0x561350dc30c0 allowed any number of times, not yet invoked: ActiveRecord::Base.connection(any_parameters) >]
```

Minitest mocking (and the way we use it in `MethodCallAssertions`)
expressly refuses to facilitate such permissiive expectations, insisting
that all calls be specified in the actual expected order.

This patch replaces such calls to `Mocha#expects` with
`ActiveSupport::Testing::MethodCallAssertions` and specifies all
expected calls in the epxected order.
2018-07-22 08:38:56 +03:00
utilum
d899375058 Replace Mocha#stubs with assert_called_with
A correct, but not obvious use of `ActiveSupport::Testing::MethodCallAssertions`, which might also have been part of #33337 or #33391.
2018-07-22 08:38:11 +03:00
utilum
a94d6ae81f Fix Mocha replacement that slipped out of #33337 2018-07-22 08:38:11 +03:00
Brian Christian
06d506f0d0 CHANGELOG entry 2018-07-19 21:37:48 -07:00
Brian Christian
022eadddba don't impose primary key order if limit() is defined 2018-07-19 21:35:43 -07:00
Brian Christian
83f755ff66 tests for use of primary_key with limit 2018-07-19 21:32:54 -07:00
Eileen M. Uchitelle
01429a665c
Merge pull request #33394 from kamipo/avoid_extra_scoping
Avoid extra scoping in delegating to klass methods in the `scope` block
2018-07-19 08:23:39 -04:00
Ryuta Kamizono
04d5e08c13
Merge pull request #33391 from utilum/method_call_assertions_instead_of_mocha
Use MethodCallAssertions instead of Mocha#expects
2018-07-19 19:21:30 +09:00
Ryuta Kamizono
1173c7cad3 Avoid extra scoping in delegating to klass methods in the scope block
Since #29301, delegating to klass methods in the `scope` block would
cause extra scoping by the receiver itself. The extra scoping would
always override intermediate scoping like `unscoped` and caused the
regression #33387. To keep the original scoping behavior, should avoid
the extra scoping in the `scope` block.

Fixes #33387.
2018-07-19 18:55:29 +09:00
Ryuta Kamizono
9fc728cf09 Fix insert_fixtures_set to be restored original connection flags
#33363 has two regressions. First one is that `insert_fixtures_set` is
failed if flags is an array. Second one is that connection flags are not
restored if `set_server_option` is not supported.
2018-07-19 11:35:57 +09:00
utilum
d0743d0263 Use MethodCallAssertions instead of Mocha#expects
Many calls to `Mocha#expects` preceded the introduction of
`ActiveSupport::Testing::MethodCallAssertions` in 53f64c0fb,
and many are simple to replace with `MethodCallAssertions`.

This patch makes all these simple replacements.

Step 5 in #33162
2018-07-19 03:31:42 +03:00
Ryuta Kamizono
08813dd62a Revert "Short circuit the scoping delegation for relation.all"
This reverts commit eb807384c81a6e086b17a576755e992e6c4c685e.

If the current scope is affected by the `unscoped` block, `all` won't be
the same with `spawn`.
2018-07-19 07:54:31 +09:00
Rafael França
371e375294
Merge pull request #33363 from ahorek/transaction_bug
use set_server_option if possible
2018-07-18 16:53:52 -04:00
Rafael França
daee94da99
Merge pull request #33358 from azbshiri/summer-time
Normalize the date component to 2000-01-01 automatically
2018-07-18 15:31:50 -04:00
Alireza Bashiri
35ca222cd3 Test DST both in local and utc timezone
Also?
Updated failing test.
2018-07-17 08:44:15 +04:30
Sean Prashad
e8747cbb6e Implement change() to convert to "2001-01-01" first
(cherry picked from commit da34d4766c33a042aeb92778a492fa810ec23001)
2018-07-17 08:41:54 +04:30
utilum
7afdc6c1a2 Replace some more Mocha#stub calls with Minitest
Missed these in preparing #33337
2018-07-17 01:38:56 +03:00
utilum
2af162c462 Remove unnecessary Mocha stub
Should have been removed in #33309.
2018-07-17 01:37:25 +03:00