-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reading configuration from environment for boolean values (#735)
* Fix reading configuration from environment for boolean values * Improve description of change Co-authored-by: Michael Bianco <[email protected]>
- Loading branch information
1 parent
5ddc78b
commit bfbc753
Showing
3 changed files
with
73 additions
and
8 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,41 @@ | ||
# vim:fileencoding=utf-8 | ||
require_relative 'test_helper' | ||
|
||
context 'Configuration' do | ||
%w(VERBOSE QUIET DYNAMIC_SCHEDULE).each do |setting| | ||
method = setting.downcase.to_sym | ||
method = :dynamic if setting == 'DYNAMIC_SCHEDULE' | ||
|
||
test "enabling #{method} from environment" do | ||
configuration.environment = { setting => 'true' } | ||
|
||
assert configuration.send(method) | ||
end | ||
|
||
test "disabling #{method} from environment" do | ||
configuration.environment = { setting => 'false' } | ||
|
||
assert !configuration.send(method) | ||
end | ||
end | ||
|
||
test 'env set from Rails.env' do | ||
Rails.expects(:env).returns('development') | ||
|
||
assert_equal 'development', configuration.env | ||
end | ||
|
||
test 'env set from environment' do | ||
configuration.environment = { 'RAILS_ENV' => 'development' } | ||
|
||
assert_equal 'development', configuration.env | ||
end | ||
|
||
private | ||
|
||
def configuration | ||
@configuration ||= Module.new do | ||
extend Resque::Scheduler::Configuration | ||
end | ||
end | ||
end |