This repository has been archived by the owner on Jun 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote test for slug renaming in Buckets
- Loading branch information
Ruben Vereecken
committed
Dec 18, 2014
1 parent
ff38a15
commit c90f657
Showing
3 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,62 @@ describe 'Model#Bucket', -> | |
expect(bucket.singular).to.equal 'Article' | ||
done() | ||
|
||
describe 'Update', -> | ||
Entry = require '../../../server/models/entry' | ||
|
||
before reset.db | ||
|
||
user = null | ||
before (done) -> | ||
User.create {name: 'Bucketer', email: '[email protected]', password: 'S3cr3ts'}, (err, u) -> | ||
expect(err).to.not.exist | ||
user = u | ||
done() | ||
|
||
bucket = null | ||
beforeEach (done) -> | ||
bucket = new Bucket | ||
name: 'Articles' | ||
slug: 'articles' | ||
#fields: [ | ||
# fieldType: 'markdown' | ||
# slug: 'body' | ||
# name: 'body' | ||
#] | ||
bucket.fields.push | ||
fieldType: 'markdown' | ||
slug: 'body' | ||
name: 'body' | ||
bucket.save (err, b) -> | ||
expect(err).to.not.exist | ||
done() | ||
|
||
afterEach (done) -> Bucket.remove {}, -> done() | ||
|
||
it 'updates entry fields when slug changes', (done) -> | ||
Entry.create | ||
title: 'Some Entry' | ||
bucket: bucket._id | ||
author: user._id | ||
content: body: 'Bodyslam' | ||
, (err, entry) -> | ||
expect(err).to.not.exist | ||
expect(entry.get 'content.body').to.exist | ||
|
||
Bucket.findById bucket._id, (err, bucket) -> | ||
field = bucket.get('fields')[0] | ||
field.set 'slug', 'new-body' | ||
|
||
bucket.save (err, field) -> | ||
expect(err).to.not.exist | ||
Entry.find {bucket: bucket._id}, (err, entries) -> | ||
expect(err).to.not.exist | ||
expect(entries.length).to.not.equal 0 | ||
for entry in entries | ||
expect(entry.get 'content.body').to.not.exist | ||
expect(entry.get 'content.new-body').to.exist | ||
done() | ||
|
||
describe '#getMembers', -> | ||
u = null | ||
b = null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters