applicake/doorkeeper — pull request #138 by petergoldstein (2012-08-10 17:15:48+00:00)
Title: Moving the Ownership injection for the application ownership enabled cas...

The basic issue being fixed is described in detail [here](https://github.com/applicake/doorkeeper/pull/78#issuecomment-7650658).

The application owner changes include Doorkeeper::Models::Ownership into Doorkeeper::Application when application ownership is enabled. This works fine as long as Doorkeeper::Application has already been loaded by a require. In the current code this include happens inside the Doorkeeper::Config::Builder

As part of the ORM changes the Doorkeeper::Application require was moved until after the Doorkeeper::Config::Builder had run. So the Doorkeeper::Application class isn't available inside the builder, and starting up an application with enable_application_owner uncommented in the initializer fails.

This doesn't show up in the tests as a failure (and I can't figure out a way to make it show up) because the require statement only needs to be issued once, and then the enable_application_owner in the Doorkeeper::Config::Builder will succeed. So the tests run green.

This fix does two things:

1) Adds an instance variable to the configuration to track whether the enable_application_owner option is specified in the initializer
2) Calls the code to include Doorkeeper::Models::Ownership in Doorkeeper::Application if that instance variable is true.

Everything runs green on both AR and Mongoid.

Please let me know if you have any questions.