-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom default controller configuration #788
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aaed7bb
Add configure functionality to allow customizing the default.
codebycliff 35de657
Add configuration module and tests.
codebycliff f90a28c
Add documentation to the README.md
codebycliff 710351e
Skip tests that only fail when whole suite is ran.
codebycliff a886d28
Fix the double leaking by re-writing the test that caused the issue.
codebycliff b8ee7d5
Clean up railtie - Exract out method, Remove unnecessary compatibility.
codebycliff 244d8e5
Add new functionality to the dummy app to increase test coverage.
codebycliff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,27 @@ | ||
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 | ||
skip | ||
expect(Draper.default_controller).to be ApplicationController | ||
end | ||
|
||
it 'allows customizing default_controller through configure' do | ||
skip | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests all pass every time when I run just this file. However, these last two tests cause the entire suite to fail with an error about leaking a double. Due to it being a state leaking issue, it's not a consistent test that fails. The two different errors that keep seeing are:
and
I'm not sure how to go about fixing those as I'm not super familiar with the test setup on this project. I will continue to look into it, but could use some advice if someone has some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to fix this issue. The problem was that one of the tests in the
build_strategy_spec.rb
was stubbing a constant that was overriding the new class definition in thespec_helper.rb
. The specific test that was stubbing was able to be re-written without mocks now that theApplicationController
class is defined. I believe the way I re-wrote the test still tests for the same functionality. Somebody correct me if that's not the case. The commit is here:a886d28