2013-02-05 14:16:51 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DraftController do
|
|
|
|
|
|
|
|
it 'requires you to be logged in' do
|
2015-01-09 12:04:02 -05:00
|
|
|
expect { post :update }.to raise_error(Discourse::NotLoggedIn)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves a draft on update' do
|
|
|
|
user = log_in
|
|
|
|
post :update, draft_key: 'xyz', data: 'my data', sequence: 0
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
2013-02-25 11:42:20 -05:00
|
|
|
it 'destroys drafts when required' do
|
2013-02-05 14:16:51 -05:00
|
|
|
user = log_in
|
|
|
|
Draft.set(user, 'xxx', 0, 'hi')
|
|
|
|
delete :destroy, draft_key: 'xxx', sequence: 0
|
2015-01-09 12:04:02 -05:00
|
|
|
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|