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 3ab451e
Showing
3 changed files
with
66 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,59 @@ 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.create | ||
name: 'Articles' | ||
slug: 'articles' | ||
fields: [ | ||
fieldType: 'markdown' | ||
slug: 'body' | ||
name: 'body' | ||
] | ||
, (err, b) -> | ||
expect(err).to.not.exist | ||
bucket = b | ||
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 | ||
|
||
fields = bucket.get 'fields' | ||
fields[0].set 'slug', 'new-body' | ||
bucket.save (err, bucket) -> | ||
expect(err).to.not.exist | ||
|
||
Entry.find {bucket: bucket._id}, (err, entries) -> | ||
console.log 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