Skip to content

Commit

Permalink
Lint/test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
camsaul committed Aug 19, 2019
1 parent c6516d6 commit 3bcc9d9
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions test/toucan/test_models/category.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@
:in maybe-lowercase-string
:out maybe-lowercase-string)

(models/defmodel Category :categories)
(declare assert-parent-category-exists
delete-child-categories
add-category-to-moderation-queue!
add-category-to-updated-queue!)

(models/defmodel Category :categories
models/IModel
(types [_]
{:name :lowercase-string})
(pre-insert [this]
(assert-parent-category-exists this))
(post-insert [this]
(add-category-to-moderation-queue! this))
(pre-update [this]
(assert-parent-category-exists this))
(post-update [this]
(add-category-to-updated-queue! this))
(pre-delete [this]
(delete-child-categories this)))

(defn- assert-parent-category-exists [{:keys [parent-category-id], :as category}]
(when parent-category-id
Expand All @@ -45,18 +63,3 @@

(defn add-category-to-updated-queue! [{:keys [id]}]
(swap! categories-recently-updated conj id))

(extend-protocol models/IModel
CategoryInstance
(types [_]
{:name :lowercase-string})
(pre-insert [this]
(assert-parent-category-exists this))
(post-insert [this]
(add-category-to-moderation-queue! this))
(pre-update [this]
(assert-parent-category-exists this))
(post-update [this]
(add-category-to-updated-queue! this))
(pre-delete [this]
(delete-child-categories this)))

0 comments on commit 3bcc9d9

Please sign in to comment.