discourse/spec/controllers/draft_controller_spec.rb
Sam 49ed382c2a FIX: return 429 when admin api key is limited on admin route
This also handles a general case where exceptions leak out prior to being handled by the application controller
2018-01-12 14:15:26 +11:00

24 lines
593 B
Ruby

require 'rails_helper'
describe DraftController do
it 'requires you to be logged in' do
post :update
expect(response.status).to eq(403)
end
it 'saves a draft on update' do
user = log_in
post :update, params: { draft_key: 'xyz', data: 'my data', sequence: 0 }, format: :json
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, params: { draft_key: 'xxx', sequence: 0 }, format: :json
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
end
end