BigW Consortium Gitlab

Commit 35160a97 by blackst0ne

Add specs for issue and note changes

parent d9f48e45
...@@ -216,12 +216,12 @@ class IssuableBaseService < BaseService ...@@ -216,12 +216,12 @@ class IssuableBaseService < BaseService
params[:label_ids] = label_ids if labels_changing?(issuable.label_ids, label_ids) params[:label_ids] = label_ids if labels_changing?(issuable.label_ids, label_ids)
if issuable.changed? || params.present? if issuable.changed? || params.present?
issuable.assign_attributes(params.merge(updated_by: current_user))
if has_title_or_description_changed?(issuable) if has_title_or_description_changed?(issuable)
issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user) issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user)
end end
issuable.assign_attributes(params.merge(updated_by: current_user))
before_update(issuable) before_update(issuable)
if issuable.with_transaction_returning_status { issuable.save } if issuable.with_transaction_returning_status { issuable.save }
......
...@@ -714,4 +714,26 @@ describe 'Issues', feature: true do ...@@ -714,4 +714,26 @@ describe 'Issues', feature: true do
expect(page).to have_text("updated title") expect(page).to have_text("updated title")
end end
end end
describe '"edited by" message', js: true do
let(:issue) { create(:issue, project: project, author: @user) }
context 'when issue is updated' do
before { visit edit_namespace_project_issue_path(project.namespace, project, issue) }
it 'shows "edited by" mesage on title update' do
fill_in 'issue_title', with: 'hello world'
click_button 'Save changes'
expect(page).to have_content("Edited less than a minute ago by #{@user.name}")
end
it 'shows "edited by" mesage on description update' do
fill_in 'issue_description', with: 'hello world'
click_button 'Save changes'
expect(page).to have_content("Edited less than a minute ago by #{@user.name}")
end
end
end
end end
...@@ -20,6 +20,13 @@ describe Notes::UpdateService, services: true do ...@@ -20,6 +20,13 @@ describe Notes::UpdateService, services: true do
@note.reload @note.reload
end end
it 'updates last_edited_at and last_edited_by attributes' do
update_note({ note: 'Hello world!' })
expect(@note.last_edited_at).not_to be_nil
expect(@note.last_edited_by).not_to be_nil
end
context 'todos' do context 'todos' do
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) } let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment