Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Sensis/enableToggle
allow configuration to disable feature modification at run time
- Loading branch information
Showing
3 changed files
with
56 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
32 changes: 32 additions & 0 deletions
32
test/unit/uk/co/desirableobjects/featureswitch/FeatureSwitchAdminControllerSpec.groovy
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,32 @@ | ||
package uk.co.desirableobjects.featureswitch | ||
|
||
import spock.lang.Specification | ||
import grails.test.mixin.TestFor | ||
import spock.lang.Unroll | ||
|
||
@Unroll | ||
@TestFor(FeatureSwitchAdminController) | ||
class FeatureSwitchAdminControllerSpec extends Specification { | ||
|
||
def "ability to toggle features can be disabled" (boolean allowToggling, boolean startState, Closure endpoint, boolean endState, int responseCode) { | ||
given: | ||
def featureName = "theFeature" | ||
grailsApplication.config.features[featureName].enabled = startState | ||
and: | ||
grailsApplication.config.featuresConfig.allowToggling = allowToggling | ||
when: | ||
endpoint(featureName) | ||
then: | ||
response.status == responseCode | ||
and: | ||
grailsApplication.config.features[featureName].enabled == endState | ||
where: | ||
allowToggling | startState | endpoint | endState | responseCode | ||
false | true | {controller.disable(it)} | true | 403 | ||
false | false | {controller.enable(it)} | false | 403 | ||
false | true | {controller.toggle(it)} | true | 403 | ||
true | true | {controller.disable(it)} | false | 200 | ||
true | false | {controller.enable(it)} | true | 200 | ||
true | true | {controller.toggle(it)} | false | 302 | ||
} | ||
} |