PageRenderTime 204ms CodeModel.GetById 81ms app.highlight 8ms RepoModel.GetById 112ms app.codeStats 0ms

/test/unit/general/ImagenControllerTests.groovy

http://github.com/jdmr/mateo
Groovy | 159 lines | 87 code | 65 blank | 7 comment | 31 complexity | f106e5f0d1df5624e1237c1d78d3d4df MD5 | raw file
  1package general
  2
  3
  4
  5import org.junit.*
  6import grails.test.mixin.*
  7
  8
  9@TestFor(ImagenController)
 10@Mock(Imagen)
 11class ImagenControllerTests {
 12
 13
 14    @Test
 15    void testIndex() {
 16        controller.index()
 17        assert "/imagen/list" == response.redirectedUrl
 18    }
 19
 20    @Test
 21    void testList() {
 22
 23        def model = controller.list()
 24
 25        assert model.imagenInstanceList.size() == 0
 26        assert model.imagenInstanceTotal == 0
 27
 28    }
 29
 30    @Test
 31    void testCreate() {
 32       def model = controller.create()
 33
 34       assert model.imagenInstance != null
 35
 36
 37    }
 38
 39    @Test
 40    void testSave() {
 41        controller.save()
 42
 43        assert model.imagenInstance != null
 44        assert view == '/imagen/create'
 45
 46        // TODO: Populate valid properties
 47
 48        controller.save()
 49
 50        assert response.redirectedUrl == '/imagen/show/1'
 51        assert controller.flash.message != null
 52        assert Imagen.count() == 1
 53    }
 54
 55
 56    @Test
 57    void testShow() {
 58        controller.show()
 59
 60        assert flash.message != null
 61        assert response.redirectedUrl == '/imagen/list'
 62
 63
 64        def imagen = new Imagen()
 65
 66        // TODO: populate domain properties
 67
 68        assert imagen.save() != null
 69
 70        params.id = imagen.id
 71
 72        def model = controller.show()
 73
 74        assert model.imagenInstance == imagen
 75    }
 76
 77    @Test
 78    void testEdit() {
 79        controller.edit()
 80
 81        assert flash.message != null
 82        assert response.redirectedUrl == '/imagen/list'
 83
 84
 85        def imagen = new Imagen()
 86
 87        // TODO: populate valid domain properties
 88
 89        assert imagen.save() != null
 90
 91        params.id = imagen.id
 92
 93        def model = controller.edit()
 94
 95        assert model.imagenInstance == imagen
 96    }
 97
 98    @Test
 99    void testUpdate() {
100
101        controller.update()
102
103        assert flash.message != null
104        assert response.redirectedUrl == '/imagen/list'
105
106        response.reset()
107
108
109        def imagen = new Imagen()
110
111        // TODO: populate valid domain properties
112
113        assert imagen.save() != null
114
115        // test invalid parameters in update
116        params.id = imagen.id
117
118        controller.update()
119
120        assert view == "/imagen/edit"
121        assert model.imagenInstance != null
122
123        imagen.clearErrors()
124
125        // TODO: populate valid domain form parameter
126        controller.update()
127
128        assert response.redirectedUrl == "/imagen/show/$imagen.id"
129        assert flash.message != null
130    }
131
132    @Test
133    void testDelete() {
134        controller.delete()
135
136        assert flash.message != null
137        assert response.redirectedUrl == '/imagen/list'
138
139        response.reset()
140
141        def imagen = new Imagen()
142
143        // TODO: populate valid domain properties
144        assert imagen.save() != null
145        assert Imagen.count() == 1
146
147        params.id = imagen.id
148
149        controller.delete()
150
151        assert Imagen.count() == 0
152        assert Imagen.get(imagen.id) == null
153        assert response.redirectedUrl == '/imagen/list'
154
155
156    }
157
158
159}