FEATURE: Report edit conflicts when saving draft. (#6585)

This commit is contained in:
Bianca Nenciu
2018-11-14 13:56:25 +02:00
committed by Régis Hanol
parent d078808144
commit 34e4d82f1a
6 changed files with 69 additions and 11 deletions

View File

@ -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')