Commit Graph

54030 Commits

Author SHA1 Message Date
Vijay Dev
b217354dbb Merge branch 'master' of github.com:rails/docrails 2015-10-31 17:01:41 +00:00
Arun Agrawal
e913834e92 Merge pull request #22140 from jwworth/pull-request/fix-double-word
Fix double word 'be' [ci skip]
2015-10-31 17:55:11 +01:00
Jake Worth
1c44d96867 Fix double word 'be' [ci skip] 2015-10-31 11:52:39 -05:00
Arun Agrawal
53ac41e48b Merge pull request #22136 from y-yagi/fix_changelog_format
minor formatting changes [ci skip]
2015-10-31 07:07:15 +01:00
yuuji.yaginuma
a9402862a1 minor formatting changes [ci skip]
* add newline for display the fenced code block
* add "#" in the comments section
2015-10-31 14:52:24 +09:00
Aaron Patterson
e76c38ef10 split process from mailer instantiation
this allows us to construct mailer objects without possibly disastrous
side-effects.
2015-10-30 14:53:19 -07:00
Sean Griffin
d2315d0c3b Merge pull request #22125 from k0kubun/left_joins
Alias left_joins to left_outer_joins
2015-10-30 14:05:11 -06:00
Rafael Mendonça França
d52baa8514 Add tasks to automatize CHANGELOG headers 2015-10-30 18:03:18 -02:00
Rafael Mendonça França
08225104d1 ✂️ 2015-10-30 17:50:53 -02:00
Sean Griffin
eb6cdcab39 Merge pull request #21251 from rodzyn/more_param_parser_tests
Add test for parsing application/vnd.api+json
2015-10-30 13:44:04 -06:00
Rafael França
35caf46e86 Merge pull request #22128 from Sirupsen/config-for-env
rails/application: allow passing an env to config_for
2015-10-30 17:02:15 -02:00
Simon Eskildsen
e58c96766f rails/application: allow passing an env to config_for 2015-10-30 18:57:54 +00:00
Aaron Patterson
cb848c8dd7 don't sleep in tests
we should be using a countdown latch instead of rolling our own
busy-loop.
2015-10-30 10:30:21 -07:00
Sean Griffin
61205422ba Merge pull request #22122 from samphilipd/sam/manual_locking_on_schema_migrations
Make migrations concurrent safe (using advisory locks)
2015-10-30 11:05:40 -06:00
Sam Davies
2c2a875546 Use advisory locks to prevent concurrent migrations
- 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.
2015-10-30 14:04:16 -03:00
Sean Griffin
3cd49570c5 Fix test failures caused by #12071
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
2015-10-30 10:53:37 -06:00
Takashi Kokubun
d3411ad361 Alias left_joins to left_outer_joins 2015-10-31 01:37:35 +09:00
Sean Griffin
6c61ae816a Merge pull request #11872 from AvnerCohen/log_namespace
When testing cache issues, it is useful to log the actual key, including namespace
2015-10-30 09:44:54 -06:00
Sean Griffin
e038975c29 Merge pull request #12071 from Crunch09/outer_joins
added ActiveRecord::Relation#outer_joins
2015-10-30 09:42:02 -06:00
Rafael Mendonça França
67417f1821 Add version constraint to database gem in generated application
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.
2015-10-29 22:09:23 -02:00
Aaron Patterson
8941831733 Revert "ActionController::Base#process() now only takes an action name"
This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
2015-10-29 16:18:27 -07:00
Sean Griffin
21a386bb07 Ensure has_and_belongs_to_many works with belongs_to_required_by_default
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.
2015-10-29 16:53:49 -06:00
Aaron Patterson
9f93a5efbb ActionController::Base#process() now only takes an action name
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.
2015-10-29 15:40:18 -07:00
Aaron Patterson
82328a563f switch to JSON.dump to avoid infinite recursion 2015-10-29 14:42:52 -07:00
Sean Griffin
7f41321cbd Add a changelog entry for #13008 2015-10-29 15:29:37 -06:00
Sean Griffin
6a6dbb4c51 Merge pull request #13008 from ktheory/sanitize_order
Support SQL sanitization in AR::QueryMethods#order
2015-10-29 15:29:06 -06:00
eileencodes
42eb37ab51 use dispatch instead of process to run requests though
`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
2015-10-29 14:24:25 -07:00
eileencodes
b329fbb5f2 Remove unnecessary method 2015-10-29 14:12:19 -07:00
Sean Griffin
83e00c642b Merge pull request #19511 from larskanis/replace_const_conn_params
PostgreSQL, Replace static connection param list by libpq's dynamic list
2015-10-29 15:05:30 -06:00
Andrew White
a25c2cbbec Merge pull request #22121 from gocardless/patch-2
Set standard_conforming_strings with SET
2015-10-29 20:59:53 +00:00
Harry Marr
6a9323bca4 Don't disable errors when turning standard_conforming_strings on 2015-10-29 20:30:48 +00:00
Andrew White
97b3603fb6 Merge pull request #22119 from philr/time_with_zone_documentation
ActiveSupport::TimeWithZone documentation
2015-10-29 20:18:47 +00:00
Sean Griffin
a59a4fbdb0 Never pass nil to order
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...)
2015-10-29 13:43:23 -06:00
Yves Senn
38061a7bec Merge pull request #22106 from jamis/fix_default_fixture_class_names
default value for FixtureSet.fixture_class_names ought to be a Class
2015-10-29 19:37:33 +01:00
Phil Ross
028b4e3ce3 Fix the example given in the documentation for TimeWithZone#-
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`.
2015-10-29 17:51:21 +00:00
Phil Ross
4ab9e38e09 Add documentation for TimeWithZone #ago and #advance. 2015-10-29 17:51:21 +00:00
Jamis Buck
0c843640b4 FixtureSet.fixture_class_names should have no default value
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.
2015-10-29 11:23:58 -06:00
Andrew White
c087cfc671 Add CHANGELOG entry for #22101 [ci skip] 2015-10-29 17:21:49 +00:00
Sean Griffin
3fc2b77e7a Merge pull request #16252 from leckylao/actionview-date-helpers-selected-value-to-accept-hash-like-default
making date_helper selected value to accept Hash like the default option
2015-10-29 11:15:34 -06:00
Sean Griffin
f2ae4af9e1 Fix style issues with #16252 2015-10-29 11:15:19 -06:00
Lecky Lao
462698b2c7 making selected value to accept Hash like the default option. E.g. selected: {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
2015-10-29 11:02:31 -06:00
Yves Senn
857a34a416 Revert "Revert "Merge pull request #22026 from 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.
2015-10-29 17:47:47 +01:00
Andrew White
3ad796eccc Merge pull request #22101 from gocardless/ar-pgbouncer-fix
Avoid disabling postgres errors
2015-10-29 16:44:18 +00:00
Sean Griffin
5243946017 Revert "Merge pull request #22026 from akihiro17/fix-preload-association"
This reverts commit 6dc6a0b17cfaf7cb6aa2b1c163b6ca141b538a8e, reversing
changes made to ec94f00ba3cf250eb54fc5b7a5e3ed4b90164f34.

This pull request broke the build.
2015-10-29 10:16:17 -06:00
Rafael França
7b2d2a6a0e Merge pull request #22118 from cllns/fix-spacing-in-layout-template
Properly indent '<head>' and '<body>' within '<html>'
2015-10-29 14:08:24 -02:00
Sean Griffin
35085c9540 Deprecate HWIDA.new_from_hash_copying_default
This method was already niche, and is now redundant with `.new`
2015-10-29 10:01:33 -06:00
Sean Collins
4570e10f8d Properly indent '<head>' and '<body>' within '<html>' 2015-10-29 10:01:12 -06:00
Sean Griffin
ddb886ef13 Merge pull request #16357 from gchan/hwia-respects-to-hash-default
`HashWithIndifferentAccess.new` respects the default value or proc on
objects that respond to `#to_hash`
2015-10-29 09:54:55 -06:00
Sean Griffin
90dbfdcba2 Merge pull request #19501 from ccutrer/dry_sti_subclass_finding2
DRY up STI subclass logic
2015-10-29 09:43:12 -06:00
Sean Griffin
b8832c1b54 Fix a stylistic nitpick in #19501
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.
2015-10-29 09:42:24 -06:00