mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 12:27:30 +08:00
REFACTOR: draft controller specs to requests (#5942)
This commit is contained in:
parent
f5178ded56
commit
600ff85ecd
|
@ -1,23 +1,23 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe DraftController do
|
describe DraftController do
|
||||||
|
|
||||||
it 'requires you to be logged in' do
|
it 'requires you to be logged in' do
|
||||||
post :update
|
post "/draft"
|
||||||
expect(response.status).to eq(403)
|
expect(response.status).to eq(403)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'saves a draft on update' do
|
it 'saves a draft on update' do
|
||||||
user = log_in
|
user = sign_in(Fabricate(:user))
|
||||||
post :update, params: { draft_key: 'xyz', data: 'my data', sequence: 0 }, format: :json
|
post "/draft.json", params: { draft_key: 'xyz', data: 'my data', sequence: 0 }
|
||||||
|
expect(response.status).to eq(200)
|
||||||
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
|
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'destroys drafts when required' do
|
it 'destroys drafts when required' do
|
||||||
user = log_in
|
user = sign_in(Fabricate(:user))
|
||||||
Draft.set(user, 'xxx', 0, 'hi')
|
Draft.set(user, 'xxx', 0, 'hi')
|
||||||
delete :destroy, params: { draft_key: 'xxx', sequence: 0 }, format: :json
|
delete "/draft.json", params: { draft_key: 'xxx', sequence: 0 }
|
||||||
|
expect(response.status).to eq(200)
|
||||||
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
|
expect(Draft.get(user, 'xxx', 0)).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user