Grails
  1. Grails
  2. GRAILS-7025

Make mockConfig return the mocked config

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.5
    • Fix Version/s: 1.4-M1
    • Component/s: Testing
    • Labels:
      None

      Description

      GrailsUnitTestCase provides a mockConfig(String config) method
      This works for code that access the config by calling ConfigurationHolder.config, but not code that calls grailsApplication.config.

      If mockConfig could return the ConfigObject it creates, then it would be easier to add the mocked config to grailsApplication:

      def config = mockConfig('foo.bar = 200')
      controller.metaClass.grailsApplication = [config: config]
      

      See thread http://grails.1312388.n4.nabble.com/Unit-Testing-controller-that-accesses-grailsApplication-config-tt3075213.html

        Activity

        Hide
        Ronny Løvtangen added a comment -
        Show
        Ronny Løvtangen added a comment - Pull request: https://github.com/grails/grails-core/pull/34
        Show
        Graeme Rocher added a comment - Applied: https://github.com/grails/grails-core/commit/6a54b211cfec4fea9a840330ee8828c5a6ec84bb Thanks

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Ronny Løvtangen
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development