2013-02-06 03:16:51 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DraftController do
|
|
|
|
|
|
|
|
it 'requires you to be logged in' do
|
|
|
|
lambda { post :update }.should raise_error(Discourse::NotLoggedIn)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves a draft on update' do
|
|
|
|
user = log_in
|
|
|
|
post :update, draft_key: 'xyz', data: 'my data', sequence: 0
|
|
|
|
Draft.get(user, 'xyz', 0).should == 'my data'
|
|
|
|
end
|
|
|
|
|
2013-02-26 00:42:20 +08:00
|
|
|
it 'destroys drafts when required' do
|
2013-02-06 03:16:51 +08:00
|
|
|
user = log_in
|
|
|
|
Draft.set(user, 'xxx', 0, 'hi')
|
|
|
|
delete :destroy, draft_key: 'xxx', sequence: 0
|
2014-09-25 23:44:48 +08:00
|
|
|
Draft.get(user, 'xxx', 0).should == nil
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|