mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: only send originalText when we need to
This commit is contained in:
@ -8,9 +8,15 @@ describe DraftController do
|
||||
|
||||
it 'saves a draft on update' do
|
||||
user = sign_in(Fabricate(:user))
|
||||
post "/draft.json", params: { draft_key: 'xyz', data: 'my data', sequence: 0 }
|
||||
|
||||
post "/draft.json", params: {
|
||||
draft_key: 'xyz',
|
||||
data: { my: "data" }.to_json,
|
||||
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(%q({"my":"data"}))
|
||||
end
|
||||
|
||||
it 'checks for an conflict on update' do
|
||||
@ -21,9 +27,10 @@ describe DraftController do
|
||||
username: user.username,
|
||||
draft_key: "topic",
|
||||
sequence: 0,
|
||||
data: "{}",
|
||||
post_id: post.id,
|
||||
original_text: post.raw
|
||||
data: {
|
||||
postId: post.id,
|
||||
originalText: post.raw
|
||||
}.to_json
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)['conflict_user']).to eq(nil)
|
||||
@ -32,13 +39,16 @@ describe DraftController do
|
||||
username: user.username,
|
||||
draft_key: "topic",
|
||||
sequence: 0,
|
||||
data: "{}",
|
||||
post_id: post.id,
|
||||
original_text: "something else"
|
||||
data: {
|
||||
postId: post.id,
|
||||
originalText: "something else"
|
||||
}.to_json
|
||||
}
|
||||
|
||||
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')
|
||||
json = JSON.parse(response.body)
|
||||
|
||||
expect(json['conflict_user']['id']).to eq(post.last_editor.id)
|
||||
expect(json['conflict_user']).to include('avatar_template')
|
||||
end
|
||||
|
||||
it 'destroys drafts when required' do
|
||||
|
Reference in New Issue
Block a user