-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom default controller configuration (#788)
* Add configure functionality to allow customizing the default. * Add configuration module and tests. * Add documentation to the README.md * Skip tests that only fail when whole suite is ran. * Fix the double leaking by re-writing the test that caused the issue. * Clean up railtie - Exract out method, Remove unnecessary compatibility. * Add new functionality to the dummy app to increase test coverage.
- Loading branch information
Cliff Braton
committed
Mar 31, 2017
1 parent
2e6f741
commit ff36bd8
Showing
13 changed files
with
85 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Draper | ||
module Configuration | ||
def configure | ||
yield self | ||
end | ||
|
||
def default_controller | ||
@@default_controller ||= ApplicationController | ||
end | ||
|
||
def default_controller=(controller) | ||
@@default_controller = controller | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
module Draper | ||
RSpec.describe Configuration do | ||
it 'yields Draper on configure' do | ||
Draper.configure { |config| expect(config).to be Draper } | ||
end | ||
|
||
it 'defaults default_controller to ApplicationController' do | ||
expect(Draper.default_controller).to be ApplicationController | ||
end | ||
|
||
it 'allows customizing default_controller through configure' do | ||
default = Draper.default_controller | ||
|
||
Draper.configure do |config| | ||
config.default_controller = CustomController | ||
end | ||
|
||
expect(Draper.default_controller).to be CustomController | ||
|
||
Draper.default_controller = default | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class BaseController < ActionController::Base | ||
include LocalizedUrls | ||
protect_from_forgery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Draper.configure do |config| | ||
config.default_controller = BaseController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters