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.
add convenience methods for checking migrations

if a rails project needs to be migrated ActiveRecord::Migrator.needs_migration? will be true or false if the current version matches the last version. 
change AMS::JSON.include_root_in_json default value to false

Changes:

* Update `include_root_in_json` default value to false for default value
  to false for `ActiveModel::Serializers::JSON`.
* Remove unnecessary change to include_root_in_json option in
  wrap_parameters template.
* Update `as_json` documentation.
* Fix JSONSerialization tests.

Problem:

It's confusing that AM serializers behave differently from AR,
even when AR objects include AM serializers module.

    class User < ActiveRecord::Base; end

    class Person
      include ActiveModel::Model
      include ActiveModel::AttributeMethods
      include ActiveModel::Serializers::JSON

      attr_accessor :name, :age

      def attributes
        instance_values
      end
    end

    user.as_json
    => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true}
    # root is not included

    person.as_json
    => {"person"=>{"name"=>"Francesco", "age"=>22}}
    # root is included

    ActiveRecord::Base.include_root_in_json
    => false

    Person.include_root_in_json
    => true

    # different default values for include_root_in_json

Proposal:

Change the default value of AM serializers to false, update
the misleading documentation and remove unnecessary change
to false of include_root_in_json option with AR objects.

    class User < ActiveRecord::Base; end

    class Person
      include ActiveModel::Model
      include ActiveModel::AttributeMethods
      include ActiveModel::Serializers::JSON

      attr_accessor :name, :age

      def attributes
        instance_values
      end
    end

    user.as_json
    => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true}
    # root is not included

    person.as_json
    => {"name"=>"Francesco", "age"=>22}
    # root is not included

    ActiveRecord::Base.include_root_in_json
    => false

    Person.include_root_in_json
    => false

    # same behaviour, more consistent

Fixes #6578.
Fixed the application_controller require_dependency path generated by the app generator
Merge pull request #6643 from fredwu/fix_require_dependency

Fixed the application_controller require_dependency path generated by the app generator
Make method name consistent with existing methods
fix meaningless test case

Module#instance_methods returns an Array of Symbols in Ruby >= 1.9
So this was not actually testing anything
Merge pull request #6644 from amatsuda/fix_meaningless_test_case

fix meaningless test case
stop `to_s`ing method names

Module#methods are Symbols in Ruby >= 1.9
Symbol responds_to :upcase & :downcase in Ruby >= 1.9
no need to to_s here. Both String and Symbol can be interpolated into String
MiniTest::Spec shipped with Ruby >= 1.9.3 always responds_to __name__
Merge pull request #6647 from amatsuda/192_minitest_method_name

MiniTest::Spec shipped with Ruby >= 1.9.3 always responds_to __name__
reduce number of Strings
Merge pull request #6645 from amatsuda/reduce_string_instance

Reduce number of String instance
+ ActiveRecord::Base#destroy!
Merge pull request #6629 from marcandre/destroy

Add ActiveRecord::Base#destroy!
Compact array of values added to PermissionSet instance
Skip two tests with polymorphic if current adapter is Oracle Adapter.
because Oracle Adapter does not support foreign keys if :polymorphic => true is used.