Grails
  1. Grails
  2. GRAILS-6437

controller.modelAndView.view broken in unit/integration tests

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.3.2
    • Fix Version/s: 1.3.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows 7

      Description

      In a controller unit test with controller.modelAndView.view no longer appears to be set.

      In a controller that simply returns a view:

      ModelAndViewController.groovy
      class ModelAndViewController {
          def testAction = {
              render( view: 'testAction' )
          }
      }
      

      And has either a unit test or integration test:

      ModelAndViewControllerTest.groovy
          void testMultipleUserSelect() {
              controller.testAction()
      
              assertEquals 'testAction', controller.modelAndView.view
          }
      

      The test works in 1.2 but fails in 1.3.2 because controller.modelAndView.view returns null.

        Activity

        Hide
        Shawn Flahave added a comment -

        Same problem here, but I use modelAndView.viewName. Either way, its not being set and my tests fail as a result.

        Show
        Shawn Flahave added a comment - Same problem here, but I use modelAndView.viewName. Either way, its not being set and my tests fail as a result.
        Hide
        Patrick B Haggood added a comment -

        Is there yet a workaround for this bug?

        Show
        Patrick B Haggood added a comment - Is there yet a workaround for this bug?
        Hide
        Jeff Scott Brown added a comment -

        I think modelAndView.viewName should work, not modelAndView.view. Does it?

        Show
        Jeff Scott Brown added a comment - I think modelAndView.viewName should work, not modelAndView.view. Does it?
        Hide
        Jeff Scott Brown added a comment -

        There was a time when the "view" property resolved to the view name, which was the wrong thing. This was changed in January of 2010. The "viewName" property now resolves to the view name.

        Show
        Jeff Scott Brown added a comment - There was a time when the "view" property resolved to the view name, which was the wrong thing. This was changed in January of 2010. The "viewName" property now resolves to the view name.
        Show
        sudhir added a comment - Still some bug exist in 1.3.7 See this thread http://grails.1312388.n4.nabble.com/Integration-tests-modelAndView-viewName-returns-wrong-controller-name-td4036147.html

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Michael Cameron
          • Votes:
            6 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development