diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2017-05-03 17:54:00 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2017-05-04 12:58:41 +1100 |
commit | 35160a97f2dc781209515af4cdce6ff33e039cc9 (patch) | |
tree | 2683f751ea31bb6d023e325b963162bdcd1ab168 | |
parent | d9f48e45a124530211e0a65d25f5d41db5842c62 (diff) | |
download | gitlab-ce-35160a97f2dc781209515af4cdce6ff33e039cc9.tar.gz |
Add specs for issue and note changes
-rw-r--r-- | app/services/issuable_base_service.rb | 4 | ||||
-rw-r--r-- | spec/features/issues_spec.rb | 22 | ||||
-rw-r--r-- | spec/services/notes/update_service_spec.rb | 7 |
3 files changed, 31 insertions, 2 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index e77799e548c..d0805fd6eb4 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -216,12 +216,12 @@ class IssuableBaseService < BaseService params[:label_ids] = label_ids if labels_changing?(issuable.label_ids, label_ids) if issuable.changed? || params.present? + issuable.assign_attributes(params.merge(updated_by: current_user)) + if has_title_or_description_changed?(issuable) issuable.assign_attributes(last_edited_at: Time.now, last_edited_by: current_user) end - issuable.assign_attributes(params.merge(updated_by: current_user)) - before_update(issuable) if issuable.with_transaction_returning_status { issuable.save } diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 81cc8513454..93b7880b96f 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -714,4 +714,26 @@ describe 'Issues', feature: true do expect(page).to have_text("updated title") 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 diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index 905e2f46bde..8c3e4607f3e 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -20,6 +20,13 @@ describe Notes::UpdateService, services: true do @note.reload 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 let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) } |