Cache metadata in advance to avoid extra sql statements while testing.

Reason: If metadata is not cached extra sql statements
will be executed, which causes failures tests with assert_queries().
Make connection pool fair with respect to waiting threads.

The core of this fix is a threadsafe, fair Queue class.  It is
very similar to Queue in stdlib except that it supports waiting
with a timeout.

The issue this solves is that if several threads are contending for
database connections, an unfair queue makes is possible that a thread
will timeout even while other threads successfully acquire and release
connections.  A fair queue means the thread that has been waiting the
longest will get the next available connection.

This includes a few test fixes to avoid test ordering issues that
cropped up during development of this patch.
fix stylesheet template dir
Ensure that mass assignment options are preserved

There are two possible scenarios where the @mass_assignment_options
instance variable can become corrupted:

1. If the assign_attributes doesn't complete correctly, then
   subsequent calls to a nested attribute assignment method will use
   whatever options were passed to the previous assign_attributes call.

2. With nested assign_attributes calls, the inner call will overwrite
   the current options. This will only affect nested attributes as the
   attribute hash is sanitized before any methods are called.

To fix this we save the current options in a local variable and then
restore these options in an ensure block.
Merge pull request #6695 from kennyj/fix_6635

Fix #6635. We should call Scoping methods, before calling Array methods.
Minimal change to query generation of exists? that makes SQLServer and others happy that do not work without a column alias.
Conflicts:
	activerecord/lib/active_record/relation/finder_methods.rb
Add test to column alias in `exists?` SQL.

This behavior was added in be4ecdcc87984e9421ff5d5c90d33f475e0fbc01.

Closes #1139.

Fixes #2553, #1141, #1623 and #2062.
Remove bundle exec from the exception message
Fix that #exists? raises ThrowResult when called with an empty limited
reflection.

ActiveRecord::FinderMethods#construct_limited_ids_condition will raise
ThrowResult if the limited reflection comes back empty. The other callers
of #construct_limited_ids_condition handle this exception (more specifically,
the callers of construct_relation_for*), but #exists? didn't until now.
Merge pull request #6521 from Empact/throw-result

Fix that #exists? can blow up with ThrowResult exception
Address ORA-00911 errors because of the heading underscore.
Merge pull request #6698 from yahonda/address_ora_911_master

Address ORA-00911 errors because of the heading underscore.
fix warning in Ruby2.0.0

```
rails/activesupport/lib/active_support/multibyte/chars.rb:136: warning:
character class has duplicated range: /\b('?[\S])/
```
Merge pull request #6699 from takkanm/fix-character-class-duplicated-range-warning

fix warning in Ruby2.0.0
Added a testcase for #6690.
Merge pull request #6690 from suginoy/fix-templates-copy

Fix: 'rake rails:templates:copy' doesn't work
Proc always respond_to :binding
Merge pull request #6704 from amatsuda/lambda_respond_to_binding

Proc always respond_to :binding
both string and sumbol will be interpolated as string no need to convert to_s
Merge pull request #6705 from ganeshkumar/string_method_changes

both string and symbol will be interpolated as string no need to convert to_s