File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/test/groovy/ru/mystamps/web/service Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import ru.mystamps.web.entity.User
28
28
import ru.mystamps.web.model.AddCategoryForm
29
29
import ru.mystamps.web.service.dto.SelectEntityDto
30
30
import ru.mystamps.web.tests.DateUtils
31
+ import ru.mystamps.web.util.SlugUtils
31
32
32
33
class CategoryServiceImplTest extends Specification {
33
34
@@ -118,6 +119,31 @@ class CategoryServiceImplTest extends Specification {
118
119
}) >> TestObjects . createCategory()
119
120
}
120
121
122
+ def " add() should throw exception when name can't be converted to slug" () {
123
+ given :
124
+ form. setName(null )
125
+ when :
126
+ service. add(form, user)
127
+ then :
128
+ thrown IllegalArgumentException
129
+ }
130
+
131
+ def " add() should pass slug to dao" () {
132
+ given :
133
+ String name = " -foo123 test_"
134
+ and :
135
+ String slug = SlugUtils . slugify(name)
136
+ and :
137
+ form. setName(name)
138
+ when :
139
+ service. add(form, user)
140
+ then :
141
+ 1 * categoryDao. save({ Category category ->
142
+ assert category?. slug == slug
143
+ return true
144
+ }) >> TestObjects . createCategory()
145
+ }
146
+
121
147
def " add() should assign created at to current date" () {
122
148
when :
123
149
service. add(form, user)
You can’t perform that action at this time.
0 commit comments