aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #21251 from rodzyn/more_param_parser_testsSean Griffin2015-10-301-0/+14
|\ | | | | Add test for parsing application/vnd.api+json
| * Add test for parsing application/vnd.api+jsonMarcin Olichwirowicz2015-08-211-0/+14
| |
* | Merge pull request #22128 from Sirupsen/config-for-envRafael França2015-10-303-2/+22
|\ \ | | | | | | rails/application: allow passing an env to config_for
| * | rails/application: allow passing an env to config_forSimon Eskildsen2015-10-303-2/+22
|/ /
* | don't sleep in testsAaron Patterson2015-10-301-10/+6
| | | | | | | | | | we should be using a countdown latch instead of rolling our own busy-loop.
* | Merge pull request #22122 from ↵Sean Griffin2015-10-308-23/+322
|\ \ | | | | | | | | | | | | samphilipd/sam/manual_locking_on_schema_migrations Make migrations concurrent safe (using advisory locks)
| * | Use advisory locks to prevent concurrent migrationsSam Davies2015-10-308-23/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Addresses issue #22092 - Works on Postgres and MySQL - Uses advisory locks because of two important properties: 1. The can be obtained outside of the context of a transaction 2. They are automatically released when the session ends, so if a migration process crashed for whatever reason the lock is not left open perpetually - Adds get_advisory_lock and release_advisory_lock methods to database adapters - Attempting to run a migration while another one is in process will raise a ConcurrentMigrationError instead of attempting to run in parallel with undefined behavior. This could be rescued and the migration could exit cleanly instead. Perhaps as a configuration option? Technical Notes ============== The Migrator uses generate_migrator_advisory_lock_key to build the key for the lock. In order to be compatible across multiple adapters there are some constraints on this key. - Postgres limits us to 64 bit signed integers - MySQL advisory locks are server-wide so we have to scope to the database - To fulfil these requirements we use a Migrator salt (a randomly chosen signed integer with max length of 31 bits) that identifies the Rails migration process as the owner of the lock. We multiply this salt with a CRC32 unsigned integer hash of the database name to get a signed 64 bit integer that can also be converted to a string to act as a lock key in MySQL databases. - It is important for subsequent versions of the Migrator to use the same salt, otherwise different versions of the Migrator will not see each other's locks.
* | | Fix test failures caused by #12071Sean Griffin2015-10-301-10/+10
| | | | | | | | | | | | | | | | | | This assumes only one query was ever executed, but it appears to sometimes be loading schema information. We can just look at the array of queries, rather than the "first" one that was run
* | | Merge pull request #11872 from AvnerCohen/log_namespaceSean Griffin2015-10-302-1/+14
|\ \ \ | | | | | | | | When testing cache issues, it is useful to log the actual key, including namespace
| * | | When logging Cache key, in debug mode, also log namespace, to create the ↵Avner Cohen2015-06-232-1/+14
| | | | | | | | | | | | | | | | full key that actually used by the underline cache implementation
* | | | Merge pull request #12071 from Crunch09/outer_joinsSean Griffin2015-10-307-16/+176
|\ \ \ \ | | | | | | | | | | | | | | | added ActiveRecord::Relation#outer_joins
| * | | | added ActiveRecord::Relation#left_outer_joinsFlorian Thomas2015-05-197-16/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: User.left_outer_joins(:posts) => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" = "users"."id"
* | | | | Add version constraint to database gem in generated applicationRafael Mendonça França2015-10-294-17/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We are using the same version constraint in the database adapters so when a new version of the adapter that doesn't work with the version of rails is released we don't break new applications.
* | | | | Revert "ActionController::Base#process() now only takes an action name"Aaron Patterson2015-10-293-6/+22
| | | | | | | | | | | | | | | | | | | | This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
* | | | | Ensure `has_and_belongs_to_many` works with `belongs_to_required_by_default`Sean Griffin2015-10-293-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, if `ActiveRecord::Base.belongs_to_required_by_default` is set to `true`, then creating a record through `has_and_belongs_to_many` fails with the cryptic error message `Left side must exist`. This is because `inverse_of` isn't working properly in this case, presumably since we're doing trickery with anonymous classes in the middle. Rather than following this rabbit hole to try and get `inverse_of` to work in a case that we know is not publicly supported, we can just turn off this validation to match the behavior of 4.2 and earlier.
* | | | | ActionController::Base#process() now only takes an action nameAaron Patterson2015-10-293-22/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rather than an action name and *args. The *args were not being used in regular applications outside tests. This causes a backwards compatibility issue, but reduces array allocations for most users.
* | | | | switch to JSON.dump to avoid infinite recursionAaron Patterson2015-10-291-1/+1
| | | | |
* | | | | Add a changelog entry for #13008Sean Griffin2015-10-291-0/+4
| | | | |
* | | | | Merge pull request #13008 from ktheory/sanitize_orderSean Griffin2015-10-292-0/+12
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Support SQL sanitization in AR::QueryMethods#order
| * | | | | Support SQL sanitization in AR::QueryMethods#orderAaron Suggs2013-11-222-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for sanitizing arrays in SQL ORDER clauses. This is useful when using MySQL `ORDER BY FIELD()` to return records in a predetermined way. ```ruby Tag.order(['field(id, ?', [1,3,2]].to_sql # => SELECT "tags".* FROM "tags" ORDER BY field(id, 1,3,2) ``` Prior to this, developers must be careful to sanitize `#order` arguments themselves.
* | | | | | use `dispatch` instead of `process` to run requests thougheileencodes2015-10-292-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `dispatch` sets the request and response on the controller for us automatically, so the test harness doesn't need to know the internals of how request / response is set. Conflicts: actionpack/lib/action_controller/test_case.rb
* | | | | | Remove unnecessary methodeileencodes2015-10-291-3/+0
| | | | | |
* | | | | | Merge pull request #19511 from larskanis/replace_const_conn_paramsSean Griffin2015-10-291-7/+2
|\ \ \ \ \ \ | | | | | | | | | | | | | | PostgreSQL, Replace static connection param list by libpq's dynamic list
| * | | | | | PostgreSQL, Replace static connection param list by the one built into libpq.Lars Kanis2015-03-251-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the connection adapter future-proof regarding to new parameters. To maintain backward compatibility, :requiressl is added by hand. It is deprecated by PostgreSQL since 2003, but still accepted by libpq.
* | | | | | | Merge pull request #22121 from gocardless/patch-2Andrew White2015-10-292-12/+10
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Set standard_conforming_strings with SET
| * | | | | | | Don't disable errors when turning standard_conforming_strings onHarry Marr2015-10-292-12/+10
| | | | | | | |
* | | | | | | | Merge pull request #22119 from philr/time_with_zone_documentationAndrew White2015-10-291-4/+42
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | ActiveSupport::TimeWithZone documentation
| * | | | | | | Fix the example given in the documentation for TimeWithZone#-Phil Ross2015-10-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The stated value of `now` would actually give the same result for `now - 24.hours` and `now - 1.day`. Use an alternative value for `now` that demonstrates the difference between subtracting `24.hours` and `1.day`.
| * | | | | | | Add documentation for TimeWithZone #ago and #advance.Phil Ross2015-10-291-0/+38
| | | | | | | |
* | | | | | | | Never pass `nil` to `order`Sean Griffin2015-10-295-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is part of a refactoring to make it easier to allow `order` to use sanitize like just about everything else on relation. The deleted test doesn't give any reasoning as to why passing `nil` to `order` needs to be supported, and it's rather nonsensical. I can almost see allowing an empty string being passed (though I'm tempted to just disallow it...)
* | | | | | | | Merge pull request #22106 from jamis/fix_default_fixture_class_namesYves Senn2015-10-292-3/+15
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | default value for FixtureSet.fixture_class_names ought to be a Class
| * | | | | | | FixtureSet.fixture_class_names should have no default valueJamis Buck2015-10-292-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Look at `TestFixtures.set_fixture_class`. As documented, it accepts a mapping of fixture identifiers (string or symbol) to Classes (the model classes that implement the named fixture). Look now at the initialization of `TestFixtures.fixture_class_names`. It defines a Hash, which will return a string by default (where the string is the estimated class name of the given fixture identifier). Now look at TestFixtures.load_fixtures. It calls `FixtureSet.create_fixtures`, passing in the mapping of `fixture_class_names`. Following this on to `FixtureSet.create_fixtures`, this instantiates a `FixtureSet::ClassCache`, passing in the map of class names. `ClassCache`, in turn, calls `insert_class` for each value in the cache. (Recall that `set_fixture_class` puts Class objects in there, while the default proc for the mapping puts String objects.) Look finally at `insert_class`. If the value is present, it checks to see if the value is a subclass of `AR::Base`. Fair enough...but wait! What if the value is a String? You get an exception, because a String instance cannot be compared with a Class. Judging from the implementation, it seems like the expected behavior here is for `fixture_class_names` to have no default proc. Look-ups are supposed to happen via `ClassCache`, with `fixture_class_names` existing solely as a repository for explicitly-registered class mappings. That is what this change does.
* | | | | | | | Add CHANGELOG entry for #22101 [ci skip]Andrew White2015-10-291-0/+10
| | | | | | | |
* | | | | | | | Merge pull request #16252 from ↵Sean Griffin2015-10-293-1/+30
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | leckylao/actionview-date-helpers-selected-value-to-accept-hash-like-default making date_helper selected value to accept Hash like the default option
| * | | | | | | | Fix style issues with #16252Sean Griffin2015-10-292-12/+9
| | | | | | | | |
| * | | | | | | | making selected value to accept Hash like the default option. E.g. selected: ↵Lecky Lao2015-10-293-1/+33
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | {day: params[:day].to_i, month: params[:month].to_id} Adds in test test_date_select_with_selected_in_hash and change log fixes typo in CHANGELOG
* | | | | | | | Revert "Revert "Merge pull request #22026 from ↵Yves Senn2015-10-293-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | akihiro17/fix-preload-association"" This reverts commit 5243946017d09afff4d70d273b0fcdfd41a4b22a. This fixes an issue with the build where tests would fail on mysql and postgresql due to different ordering.
* | | | | | | | Merge pull request #22101 from gocardless/ar-pgbouncer-fixAndrew White2015-10-291-4/+5
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Avoid disabling postgres errors
| * | | | | | | | Check standard_conforming_strings is not readonlyHarry Marr2015-10-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Postgres 8.1 the standard_conforming_strings setting was read-only, meaning you got an error if you tried to update it. By filtering on `context = 'user'` we only try to update the setting if it's user-writable[1]. [1]: http://www.postgresql.org/docs/9.4/static/view-pg-settings.html
| * | | | | | | | Avoid disabling postgres errorsHarry Marr2015-10-281-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The standard_conforming_strings setting doesn't exist on all versions of Postgres, but if it does exist, Rails turns it on. Previously this was done by effectively disabling errors on the Postgres connection, issuing a SET to turn the setting on, then re-enabling errors on the connection. However, if you're running pgbouncer in transaction-pooling mode, you can't guarantee that successive calls to `#execute` will be sent to the same pgbouncer-postgres connection, so you can end up disabling errors on a different postgres connection, and never re-enabling them. Future queries on that connection that result in errors (e.g. violating unique constraints) will leave the connection in a bad state where successive queries will fail. This commit sets standard_conforming_strings by issuing an UPDATE to pg_settings, which will update the setting if it exists, and do nothing if it doesn't (rather than erroring out like SET would), which means we can remove the error-disabling code. It's also worth noting that Postgres has allowed standard_conforming_strings to be updated since 8.2 (which is the oldest version Rails supports), so technically we probably don't even need to be defensive here.
* | | | | | | | | Revert "Merge pull request #22026 from akihiro17/fix-preload-association"Sean Griffin2015-10-293-28/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 6dc6a0b17cfaf7cb6aa2b1c163b6ca141b538a8e, reversing changes made to ec94f00ba3cf250eb54fc5b7a5e3ed4b90164f34. This pull request broke the build.
* | | | | | | | | Merge pull request #22118 from cllns/fix-spacing-in-layout-templateRafael França2015-10-291-16/+17
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Properly indent '<head>' and '<body>' within '<html>'
| * | | | | | | | | Properly indent '<head>' and '<body>' within '<html>'Sean Collins2015-10-291-16/+17
| | | | | | | | | |
* | | | | | | | | | Deprecate `HWIDA.new_from_hash_copying_default`Sean Griffin2015-10-292-1/+6
|/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | This method was already niche, and is now redundant with `.new`
* | | | | | | | | Merge pull request #16357 from gchan/hwia-respects-to-hash-defaultSean Griffin2015-10-294-8/+32
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `HashWithIndifferentAccess.new` respects the default value or proc on objects that respond to `#to_hash`
| * | | | | | | | | `HashWithIndifferentAccess.new` respects the default value or proc on ↵Gordon Chan2014-07-314-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects that respond to `#to_hash`. Builds on the work of #12550 where `.new` will convert the object (that respond to `#to_hash`) to a hash and add that hash's keys and values to itself. This change will also make `.new` respect the default value or proc of objects that respond to `#to_hash`. In other words, this `.new` behaves exactly like `.new_from_hash_copying_default`. `.new_from_hash_copying_default` now simply invokes `.new` and any references to `.new_from_hash_copying_default` are replaced with `.new`. Added tests confirm behavior.
* | | | | | | | | | Merge pull request #19501 from ccutrer/dry_sti_subclass_finding2Sean Griffin2015-10-296-23/+30
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DRY up STI subclass logic
| * | | | | | | | | | Fix a stylistic nitpick in #19501Sean Griffin2015-10-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to use `String#+` or create all the intermediate strings to break a string into multiple lines. We can just write a c-style multiline string literal. This is by no means a hotpath, but this is clearer to me anyway.
| * | | | | | | | | | Fix test failures caused by #19501Sean Griffin2015-10-293-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first one is quite straightforward. We want to give the proper error message in the case where a top level constant exists, but we're looking for a nested one. We just need to port over the change to use `subclass.name` into these changes. The second set of failures, which are only present in the mysql adapter tests, are stranger to me. The failure occurs because we were previously comparing `subclass.name == self.name` instead of `subclass == self`. However, I don't think that we need to support creating anonymous classes which share a table with a class that uses STI, overrides `name` to return the same name as athe class that we have no other relationship with, when not assigned to a constant so it could never be used anyway... The commits around why that exist give no context, and I think they're just poorly written tests (WTF does `test_schema` mean anyway, and why does calling `.first` on some anonymous class test it?). We'll just disable STI on that class.
| * | | | | | | | | | Fix merge conflicts from #19501Sean Griffin2015-10-294-23/+28
| |\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm making this commit separately because this has failing tests and style nitpicks that I'd like to make as individual commits, to make the changes I'm making explicit. We still want a single merge commit at the end, however.