Commit Graph

73305 Commits

Author SHA1 Message Date
eileencodes
5df84533d5 Fix database loading when ERB is single line ternary
*sigh* this seems like the never ending bug. I don't love or even like
this fix but it does _work_.

Rafael suggested using `dummy_key: dummy_value` but unfortunately
that doesn't work. So we're left with checking whethere there might be
ternary type things in the content and then assuming that we want to
replace the line with a key value pair.

Technically fixes https://github.com/rails/rails/issues/36088
2019-05-10 16:28:08 -04:00
Eileen M. Uchitelle
d155f61b64 Merge pull request #36196 from st0012/fix-29947
Hide malformed parameters from error page

Accidentally merged this to 6-0-stable so forward porting it to master
here instead.
2019-05-07 15:14:14 -04:00
Ryuta Kamizono
68dc8c4500
Merge pull request #36203 from st0012/fix-command-in-contributing-guide
Update directory name in example commands [ci skip]
2019-05-08 01:54:09 +09:00
st0012
23e6ad547c Update directory name in sample commands 2019-05-08 00:25:23 +08:00
Akira Matsuda
00654b5ddd Typo in the release note
[ci skip]
2019-05-08 00:53:16 +09:00
Ryuta Kamizono
f10ad55ac4
Merge pull request #36202 from yahonda/log_transaction
Remove ignored_sql from SQLCounter by adding "TRANSACTION" to log name
2019-05-08 00:46:34 +09:00
Yasuo Honda
6a32e8aa72 Remove ignored_sql from SQLCounter by adding "TRANSACTION" to log name
This commit adds "TRANSACTION" to savepoint and commit, rollback statements
because none of savepoint statements were removed by #36153 since they are not "SCHEMA" statements.

Although, only savepoint statements can be labeled as "TRANSACTION"
I think all of transaction related method should add this label.

Follow up #36153
2019-05-08 00:21:31 +09:00
Vipul A M
4511d4bf7c
Merge pull request #36201 from soartec-lab/fix_typo_dot_position
Fixed typo of dot position [skip ci]
2019-05-07 09:41:32 -04:00
soartec-lab
1901c181d6 Fixed typo of dot position [skip ci] 2019-05-07 22:30:37 +09:00
Akira Matsuda
cecbc2340a Properly give defaults for DatabaseSelector options
The initializer receives `nil` for these options when no cofigurations were given:
https://github.com/rails/rails/blob/v6.0.0.rc1/activerecord/lib/active_record/railtie.rb#L91-L97
2019-05-07 08:46:13 +09:00
Ryuta Kamizono
01f8abd7b2
Merge pull request #36190 from kamipo/should_attempt_tx_callbacks_to_all_records
Should attempt `committed!`/`rolledback!` to all enrolled records in the transaction
2019-05-07 02:43:15 +09:00
Ryuta Kamizono
f0e2582aa0
Merge pull request #36191 from st0012/remove-useless-method
Remove unnecessary find_partial method
2019-05-07 02:41:57 +09:00
st0012
405b4c7f1e Remove useless find_partial method 2019-05-07 01:21:07 +08:00
Ryuta Kamizono
718a32ca74 Should attempt committed!/rolledback! to all enrolled records in the transaction
Currently, `committed!`/`rolledback!` will only be attempted for the
first enrolled record in the transaction, that will cause some
problematic behaviors.

The first one problem, `clear_transaction_record_state` won't be called
even if the transaction is finalized except the first enrolled record.
This means that de-duplicated records in the transaction won't refer
latest state (e.g. won't happen rolling back record state).

The second one problem, the enrolled order is not always the same as the
order in which the actions actually happened, the first enrolled record
may succeed no actions (e.g. `destroy` has already succeeded on another
record during `before_destroy`), it will lose to fire any transactional
callbacks.

To avoid both problems, we should attempt `committed!`/`rolledback!` to
all enrolled records in the transaction.
2019-05-07 02:19:57 +09:00
Ryuta Kamizono
020856c328 Remove useless GC.start in test/template/render_test.rb
The `GC.start` was added at b29e893, but the finalizer has been removed
at 7d0ce78 in #35036.
2019-05-06 23:30:07 +09:00
Ryuta Kamizono
f0f7d342ff
Merge pull request #36189 from st0012/fix-36154
Clear Resolvers' cache after RenderTestCases tests
2019-05-06 23:23:56 +09:00
st0012
34a33f8b0c Clear Resolvers' cache after running RenderTestCases' test cases
The templates rendered in RenderTestCases tests will be cached by the
resolvers unexpectedly. And this will break other tests when executed in
certain order. (See https://github.com/rails/rails/issues/36154 for more
detail)

So to fix this issue, we just need to clear the caches on all resolvers.
2019-05-06 22:08:48 +08:00
yuuji.yaginuma
85a8bc644b Make generated test work even when using virtual attributes
The virtual attributes(`attachment` and `rich_text`) can't set value
with `fill_in`. So avoid using it. Once #35885 is merged, will be
modified to use it.

Also, add checking attachment attached or not for avoiding
`DelegationError` when attachment didn't attach.
2019-05-05 09:55:37 +09:00
yuuji.yaginuma
ac1ba44f8d Fix test case name to fit file name
This fixes the following warnings.

```
/rails/activemodel/test/cases/nested_error_test.rb:9: warning: method redefined; discarding old test_initialize
/rails/activemodel/test/cases/error_test.rb:29: warning: previous definition of test_initialize was here
```
2019-05-04 17:49:25 +09:00
Ryuta Kamizono
9b680e52f1
Merge pull request #36172 from tgxworld/recover_pluck_perf
Recover perf for `pluck` by reverting 9c9c950d02af83742a5f76302d0faa9…
2019-05-04 01:19:13 +09:00
Guo Xiang Tan
25f1e0e3ea Recover perf for pluck by reverting 9c9c950d02af83742a5f76302d0faa99508f242c.
This reverts commit 9c9c950d02af83742a5f76302d0faa99508f242c.
2019-05-03 22:36:23 +08:00
Ryuta Kamizono
9b0e632def
Merge pull request #36168 from yahonda/remove_redundant_test_too_many_binds_testcase
Remove redundant `test_too_many_binds`
2019-05-03 09:43:04 +09:00
Yasuo Honda
36483cdb48 Remove redundant test_too_many_binds
with `ActiveRecord::BindParameterTest#test_too_many_binds`

sqlite adapter has its own `bind_params_length`, `ActiveRecord::BindParameterTest#test_too_many_binds` respects it.

* Modified `ActiveRecord::BindParameterTest#test_too_many_binds` to show `bind_params_length` value

```
$ git diff
diff --git a/activerecord/test/cases/bind_parameter_test.rb b/activerecord/test/cases/bind_parameter_test.rb
index 85685d1d00..83cd07f1d7 100644
--- a/activerecord/test/cases/bind_parameter_test.rb
+++ b/activerecord/test/cases/bind_parameter_test.rb
@@ -108,6 +108,7 @@ def test_statement_cache_with_sql_string_literal

       def test_too_many_binds
         bind_params_length = @connection.send(:bind_params_length)
+        p bind_params_length

         topics = Topic.where(id: (1 .. bind_params_length).to_a << 2**63)
         assert_equal Topic.count, topics.count
$
```

* Executed modified `ActiveRecord::BindParameterTest#test_too_many_binds`

```
$ bin/test test/cases/bind_parameter_test.rb -n test_too_many_binds
Using sqlite3
Run options: -n test_too_many_binds --seed 47321

999
.

Finished in 0.075249s, 13.2892 runs/s, 26.5784 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
$
```
2019-05-03 00:21:00 +00:00
Yuji Yaginuma
8305d305a1
Merge pull request #36167 from alecclarke/update-file-extension-used-in-guide
[ci skip] Correct the stylesheet name used in the guide.
2019-05-03 08:58:32 +09:00
Alec Clarke
4c3231ebb6 [ci skip] Correct the stylesheet name used in the guide.
In the Action Text guides, `app/assets/stylesheets/actiontext.css`
is specified as the file used to style the Action Text editor and
content but the actual file generated from `rails action_text:install`
is `app/assets/stylesheets/actiontext.scss`.

This change simply corrects the file extension shown in the guide.
2019-05-02 19:32:52 -04:00
Alex Kitchens
1ce5153a09
Merge pull request #36166 from alexcameron89/add_action_cable_rn
Add Action Cable Release Notes
2019-05-02 10:44:39 -05:00
Alex Kitchens
ed902c0071 Add Action Cable Release Notes [ci skip]
Co-Authored-By: प्रथमेश Sonpatki <csonpatki@gmail.com>
2019-05-02 10:08:56 -05:00
Xavier Noria
b343beba03
Merge pull request #36131 from Shopify/fix-association-extension-module-namespace
Namespace association extension modules under the owner model
2019-05-02 06:45:56 -05:00
Jean Boussier
cce26c36ca Namespace association extension modules under the owner model 2019-05-02 13:25:18 +02:00
प्रथमेश Sonpatki
730a7a1b79
Merge pull request #36152 from prathamesh-sonpatki/active-support-notes
Active Support release notes [ci skip]
2019-05-02 09:34:23 +05:30
Connor Shea
6b86bbea1f
Update guides/source/6_0_release_notes.md
Co-Authored-By: prathamesh-sonpatki <csonpatki@gmail.com>
2019-05-02 09:19:07 +05:30
Prathamesh Sonpatki
00edb8c911
Added release notes for Active Support [ci skip] 2019-05-02 09:02:33 +05:30
Ryuta Kamizono
f60a0b43f9
Merge pull request #36159 from sharang-d/update-getting-started
Update asset compression text [ci skip]
2019-05-02 06:44:01 +09:00
Sharang Dashputre
ec3314f6af Update asset compression text [ci skip] 2019-05-02 02:53:09 +05:30
Rob Trame
f4fd7d1d20 Make scope arity check consistent (#36134)
* Make scope arity check consistent

* Add test for arity change

[Rob Trame + Rafael Mendonça França]
2019-05-01 15:53:35 -05:00
Rafael França
f8243f81ff
Merge pull request #36149 from alexcameron89/add_active_storage_rn
Add Release Notes for Active Storage
2019-05-01 15:48:44 -05:00
Rafael França
a0434ce37f
Merge pull request #35337 from abhaynikam/35265-remove-unused-argument-layout-from-rendered-template
Removed unused layout attribute from RenderedTemplate
2019-05-01 15:45:06 -05:00
Rafael França
51a481fa74
Merge pull request #36155 from prathamesh-sonpatki/am-release-notes
Active Model release notes [ci skip]
2019-05-01 15:37:43 -05:00
Rafael França
b8f88b9610
Merge pull request #34642 from azimux/improve-hwia-initialize-by-skipping-to_h-if-already-a-hash
HashWithIndifferentAccess#initialize performance improvement
2019-05-01 15:36:49 -05:00
Rafael França
cc760e9106
Merge pull request #36157 from prathamesh-sonpatki/getting-started-updates
Updates to getting started per Rails 6.0 changes [ci skip]
2019-05-01 15:31:40 -05:00
Prathamesh Sonpatki
370237ce90
Updates to getting started per Rails 6.0 changes [ci skip] 2019-05-01 20:47:41 +05:30
Prathamesh Sonpatki
21e0c88fc6
Active Model release notes [ci skip] 2019-05-01 20:20:53 +05:30
Alex Kitchens
47aee9af25 Add Release Notes for Active Storage [ci skip]
Co-authored-by: Abhay Nikam <nikam.abhay1@gmail.com>
2019-05-01 09:25:52 -05:00
Ryuta Kamizono
d09a7c1366
Merge pull request #36153 from yahonda/use_schema_to_ignore
Remove database specific sql statements from SQLCounter
2019-05-01 22:41:35 +09:00
Yasuo Honda
6030110f56 Remove database specific sql statements from SQLCounter
Every database executes different type of sql statement to get metadata then `ActiveRecord::TestCase` ignores these database specific sql statements to make `assert_queries` or `assert_no_queries` work consistently.

Connection adapter already labels these statement by setting "SCHEMA" argument, this pull request makes use of "SCHEMA" argument to ignore metadata queries.

Here are the details of these changes:

* PostgresqlConnectionTest

Each of PostgresqlConnectionTest modified just executes corresponding methods

fef174f5c5/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb (L182-L195)

```ruby
        # Returns the current database encoding format.
        def encoding
          query_value("SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = current_database()", "SCHEMA")
        end

        # Returns the current database collation.
        def collation
          query_value("SELECT datcollate FROM pg_database WHERE datname = current_database()", "SCHEMA")
        end

        # Returns the current database ctype.
        def ctype
          query_value("SELECT datctype FROM pg_database WHERE datname = current_database()", "SCHEMA")
        end
```

* BulkAlterTableMigrationsTest

mysql2 adapter executes `SHOW KEYS FROM ...` to see if there is an index already created as below. I think the main concerns of these tests are how each database adapter creates or drops indexes then ignoring  `SHOW KEYS FROM` statement makes sense.

fef174f5c5/activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb (L11)

```ruby
          execute_and_free("SHOW KEYS FROM #{quote_table_name(table_name)}", "SCHEMA") do |result|
```

* Temporary change not included in this commit to show which statements executed

```diff
$ git diff
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 8e8ed494d9..df05f9bd16 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -854,7 +854,7 @@ def test_adding_indexes

       classname = ActiveRecord::Base.connection.class.name[/[^:]*$/]
       expected_query_count = {
-        "Mysql2Adapter"     => 3, # Adding an index fires a query every time to check if an index already exists or not
+        "Mysql2Adapter"     => 1, # Adding an index fires a query every time to check if an index already exists or not
         "PostgreSQLAdapter" => 2,
       }.fetch(classname) {
         raise "need an expected query count for #{classname}"
@@ -886,7 +886,7 @@ def test_removing_index

       classname = ActiveRecord::Base.connection.class.name[/[^:]*$/]
       expected_query_count = {
-        "Mysql2Adapter"     => 3, # Adding an index fires a query every time to check if an index already exists or not
+        "Mysql2Adapter"     => 1, # Adding an index fires a query every time to check if an index already exists or not
         "PostgreSQLAdapter" => 2,
       }.fetch(classname) {
         raise "need an expected query count for #{classname}"
$
```

* Executed these modified tests

```ruby
$ ARCONN=mysql2 bin/test test/cases/migration_test.rb -n /index/
Using mysql2
Run options: -n /index/ --seed 8462

F

Failure:
BulkAlterTableMigrationsTest#test_adding_indexes [/home/yahonda/git/rails/activerecord/test/cases/migration_test.rb:863]:
3 instead of 1 queries were executed.
Queries:
SHOW KEYS FROM `delete_me`
SHOW KEYS FROM `delete_me`
ALTER TABLE `delete_me` ADD UNIQUE INDEX `awesome_username_index`  (`username`), ADD  INDEX `index_delete_me_on_name_and_age`  (`name`, `age`).
Expected: 1
  Actual: 3

bin/test test/cases/migration_test.rb:848

F

Failure:
BulkAlterTableMigrationsTest#test_removing_index [/home/yahonda/git/rails/activerecord/test/cases/migration_test.rb:895]:
3 instead of 1 queries were executed.
Queries:
SHOW KEYS FROM `delete_me`
SHOW KEYS FROM `delete_me`
ALTER TABLE `delete_me` DROP INDEX `index_delete_me_on_name`, ADD UNIQUE INDEX `new_name_index`  (`name`).
Expected: 1
  Actual: 3

bin/test test/cases/migration_test.rb:879

..

Finished in 0.379245s, 10.5473 runs/s, 7.9105 assertions/s.
4 runs, 3 assertions, 2 failures, 0 errors, 0 skips
$
```

* ActiveRecord::ConnectionAdapters::Savepoints

Left `self.ignored_sql` to ignore savepoint related statements because these SQL statements are not related "SCHEMA"

```
self.ignored_sql = [/^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/]
```

fef174f5c5/activerecord/lib/active_record/connection_adapters/abstract/savepoints.rb (L10-L20)

```ruby
      def create_savepoint(name = current_savepoint_name)
        execute("SAVEPOINT #{name}")
      end

      def exec_rollback_to_savepoint(name = current_savepoint_name)
        execute("ROLLBACK TO SAVEPOINT #{name}")
      end

      def release_savepoint(name = current_savepoint_name)
        execute("RELEASE SAVEPOINT #{name}")
      end
```
2019-05-01 13:30:11 +00:00
Akira Matsuda
fef174f5c5 @controller may not be defined here, and if so, it causes a Ruby warning
e.g. via test-unit-rails' `run_setup`
2019-05-01 13:33:38 +09:00
Aaron Patterson
0c152f2eb4
Merge pull request #36150 from rails/error-any-delegation
any? should be delegated to the errors list
2019-04-30 15:25:49 -07:00
Eileen M. Uchitelle
84572fe267
Merge pull request #36148 from ksolo/update-event-duration-in-notifications
Revert changes to monotonic times
2019-04-30 16:58:30 -05:00
Aaron Patterson
2ada222f1e
any? should be delegated to the errors list
Otherwise we get deprecation warnings in the generated scaffold template files
2019-04-30 16:54:40 -05:00
Kevin Solorio
b9a9131fdb revert changes to monotonic times
The change to monotonic times causes failures for applications
where the subscribed block is expecting Time objects as described
in this issue: https://github.com/rails/rails/issues/36145

The original PR (https://github.com/rails/rails/pull/35984) was
concerned with errors on the cpu_time. Test was edited to reflect
changes to initializer using 0 values instead of nil
2019-04-30 14:32:03 -07:00