discourse/spec/requests/draft_controller_spec.rb

24 lines
689 B
Ruby
Raw Normal View History

require 'rails_helper'
2013-02-06 03:16:51 +08:00
describe DraftController do
it 'requires you to be logged in' do
post "/draft"
expect(response.status).to eq(403)
2013-02-06 03:16:51 +08:00
end
it 'saves a draft on update' do
user = sign_in(Fabricate(:user))
post "/draft.json", params: { draft_key: 'xyz', data: 'my data', sequence: 0 }
expect(response.status).to eq(200)
2015-01-10 01:04:02 +08:00
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
2013-02-06 03:16:51 +08:00
end
2013-02-26 00:42:20 +08:00
it 'destroys drafts when required' do
user = sign_in(Fabricate(:user))
2013-02-06 03:16:51 +08:00
Draft.set(user, 'xxx', 0, 'hi')
delete "/draft.json", params: { draft_key: 'xxx', sequence: 0 }
expect(response.status).to eq(200)
2015-01-10 01:04:02 +08:00
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
2013-02-06 03:16:51 +08:00
end
end