mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: Report edit conflicts when saving draft. (#6585)
This commit is contained in:

committed by
Régis Hanol

parent
d078808144
commit
34e4d82f1a
@ -13,6 +13,34 @@ describe DraftController do
|
||||
expect(Draft.get(user, 'xyz', 0)).to eq('my data')
|
||||
end
|
||||
|
||||
it 'checks for an conflict on update' do
|
||||
user = sign_in(Fabricate(:user))
|
||||
post = Fabricate(:post, user: user)
|
||||
|
||||
post "/draft.json", params: {
|
||||
username: user.username,
|
||||
draft_key: "topic",
|
||||
sequence: 0,
|
||||
data: "{}",
|
||||
post_id: post.id,
|
||||
original_text: post.raw
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)['conflict_user']).to eq(nil)
|
||||
|
||||
post "/draft.json", params: {
|
||||
username: user.username,
|
||||
draft_key: "topic",
|
||||
sequence: 0,
|
||||
data: "{}",
|
||||
post_id: post.id,
|
||||
original_text: "something else"
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)['conflict_user']['id']).to eq(post.last_editor.id)
|
||||
expect(JSON.parse(response.body)['conflict_user']).to include('avatar_template')
|
||||
end
|
||||
|
||||
it 'destroys drafts when required' do
|
||||
user = sign_in(Fabricate(:user))
|
||||
Draft.set(user, 'xxx', 0, 'hi')
|
||||
|
Reference in New Issue
Block a user