2015-10-11 04:41:23 -05:00
|
|
|
require 'rails_helper'
|
2013-02-05 13:16:51 -06:00
|
|
|
|
|
|
|
describe DraftController do
|
|
|
|
|
|
|
|
it 'requires you to be logged in' do
|
2018-01-11 21:15:10 -06:00
|
|
|
post :update
|
|
|
|
expect(response.status).to eq(403)
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves a draft on update' do
|
|
|
|
user = log_in
|
2017-08-30 23:06:56 -05:00
|
|
|
post :update, params: { draft_key: 'xyz', data: 'my data', sequence: 0 }, format: :json
|
2015-01-09 11:04:02 -06:00
|
|
|
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2013-02-25 10:42:20 -06:00
|
|
|
it 'destroys drafts when required' do
|
2013-02-05 13:16:51 -06:00
|
|
|
user = log_in
|
|
|
|
Draft.set(user, 'xxx', 0, 'hi')
|
2017-08-30 23:06:56 -05:00
|
|
|
delete :destroy, params: { draft_key: 'xxx', sequence: 0 }, format: :json
|
2015-01-09 11:04:02 -06:00
|
|
|
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
2013-02-25 10:42:20 -06:00
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|