This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/spec/controllers/draft_controller_spec.rb
2016-03-31 17:40:54 -04:00

22 lines
550 B
Ruby

require 'rails_helper'
describe DraftController do
it 'requires you to be logged in' do
expect { post :update }.to 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
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
end
it 'destroys drafts when required' do
user = log_in
Draft.set(user, 'xxx', 0, 'hi')
delete :destroy, draft_key: 'xxx', sequence: 0
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
end
end