From 323596f68efe95b479a0dc29832b8033a1eddef0 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Sat, 29 Apr 2017 10:54:37 +1100 Subject: Add system note on description change of issue/merge request --- spec/services/system_note_service_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 75d7caf2508..5e85c3c1621 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -292,6 +292,20 @@ describe SystemNoteService, services: true do end end + describe '.change_description' do + subject { described_class.change_description(noteable, project, author) } + + context 'when noteable responds to `description`' do + it_behaves_like 'a system note' do + let(:action) { 'description' } + end + + it 'sets the note text' do + expect(subject.note).to eq 'changed the description' + end + end + end + describe '.change_issue_confidentiality' do subject { described_class.change_issue_confidentiality(noteable, project, author) } -- cgit v1.2.1 From 35160a97f2dc781209515af4cdce6ff33e039cc9 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 3 May 2017 17:54:00 +1100 Subject: Add specs for issue and note changes --- spec/features/issues_spec.rb | 22 ++++++++++++++++++++++ spec/services/notes/update_service_spec.rb | 7 +++++++ 2 files changed, 29 insertions(+) (limited to 'spec') 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) } -- cgit v1.2.1 From c2b869a119f7400d748a8a97e4abc3137bc7c51d Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 3 May 2017 18:07:53 +1100 Subject: Add specs for merge requests --- spec/features/merge_requests/edit_mr_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec') diff --git a/spec/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb index cb3bc392903..b0855af9524 100644 --- a/spec/features/merge_requests/edit_mr_spec.rb +++ b/spec/features/merge_requests/edit_mr_spec.rb @@ -67,5 +67,23 @@ feature 'Edit Merge Request', feature: true do def get_textarea_height page.evaluate_script('document.getElementById("merge_request_description").offsetHeight') end + + describe '"edited by" message', js: true do + context 'when merge request is updated' do + it 'shows "edited by" mesage on title update' do + fill_in 'merge_request_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 'merge_request_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 -- cgit v1.2.1 From 62be3355b1cc74e085a7a046e7aca05f59a1f97a Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 3 May 2017 22:11:19 +1100 Subject: Add alias_attributes for notes --- spec/services/notes/update_service_spec.rb | 7 ------- 1 file changed, 7 deletions(-) (limited to 'spec') diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index 8c3e4607f3e..905e2f46bde 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -20,13 +20,6 @@ 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) } -- cgit v1.2.1 From b2e578803dce182bd8d871fa7bcac573e05c4b95 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Thu, 4 May 2017 12:36:12 +1100 Subject: Add feature spec for system notes --- spec/features/issuables/system_notes_spec.rb | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 spec/features/issuables/system_notes_spec.rb (limited to 'spec') diff --git a/spec/features/issuables/system_notes_spec.rb b/spec/features/issuables/system_notes_spec.rb new file mode 100644 index 00000000000..e12d81e76cb --- /dev/null +++ b/spec/features/issuables/system_notes_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'issuable system notes', feature: true do + let(:issue) { create(:issue, project: project, author: user) } + let(:merge_request) { create(:merge_request, :simple, source_project: project) } + let(:project) { create(:project, :public) } + let(:user) { create(:user) } + + before do + project.add_user(user, :master) + login_as(user) + end + + [:issue, :merge_request].each do |issuable_type| + context "when #{issuable_type}" do + before do + issuable = issuable_type == :issue ? issue : merge_request + + visit(edit_polymorphic_path([project.namespace.becomes(Namespace), project, issuable])) + end + + it 'adds system note "description changed"' do + fill_in("#{issuable_type}_description", with: 'hello world') + click_button('Save changes') + + expect(page).to have_content("#{user.name} #{user.to_reference} changed the description") + end + end + end +end -- cgit v1.2.1 From cca09bbb1864bf300157d4d9c5500b83acf9f5c7 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 5 May 2017 16:39:26 +1100 Subject: Update Import/Export files --- spec/lib/gitlab/import_export/all_models.yml | 3 +++ spec/lib/gitlab/import_export/safe_model_attributes.yml | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 0abf89d060c..9ae294ae8d1 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -9,6 +9,7 @@ issues: - notes - label_links - labels +- last_edited_by - todos - user_agent_detail - moved_to @@ -26,6 +27,7 @@ notes: - noteable - author - updated_by +- last_edited_by - resolved_by - todos - events @@ -71,6 +73,7 @@ merge_requests: - notes - label_links - labels +- last_edited_by - todos - target_project - source_project diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index ebfaab4eacd..5fdc30207c3 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -23,6 +23,8 @@ Issue: - weight - time_estimate - relative_position +- last_edited_at +- last_edited_by_id Event: - id - target_type @@ -154,6 +156,8 @@ MergeRequest: - approvals_before_merge - rebase_commit_sha - time_estimate +- last_edited_at +- last_edited_by_id MergeRequestDiff: - id - state -- cgit v1.2.1 From 8c4c40d09b6947f4ac652dd76cc422fea2a6443d Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 5 May 2017 23:01:50 +1100 Subject: Updated specs --- spec/features/issuables/system_notes_spec.rb | 30 ---------------------- spec/features/issues_spec.rb | 22 ---------------- spec/features/merge_requests/edit_mr_spec.rb | 18 ------------- spec/services/issues/update_service_spec.rb | 11 ++++++++ .../services/merge_requests/update_service_spec.rb | 7 +++++ spec/services/system_note_service_spec.rb | 2 +- 6 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 spec/features/issuables/system_notes_spec.rb (limited to 'spec') diff --git a/spec/features/issuables/system_notes_spec.rb b/spec/features/issuables/system_notes_spec.rb deleted file mode 100644 index e12d81e76cb..00000000000 --- a/spec/features/issuables/system_notes_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'spec_helper' - -describe 'issuable system notes', feature: true do - let(:issue) { create(:issue, project: project, author: user) } - let(:merge_request) { create(:merge_request, :simple, source_project: project) } - let(:project) { create(:project, :public) } - let(:user) { create(:user) } - - before do - project.add_user(user, :master) - login_as(user) - end - - [:issue, :merge_request].each do |issuable_type| - context "when #{issuable_type}" do - before do - issuable = issuable_type == :issue ? issue : merge_request - - visit(edit_polymorphic_path([project.namespace.becomes(Namespace), project, issuable])) - end - - it 'adds system note "description changed"' do - fill_in("#{issuable_type}_description", with: 'hello world') - click_button('Save changes') - - expect(page).to have_content("#{user.name} #{user.to_reference} changed the description") - end - end - end -end diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 93b7880b96f..81cc8513454 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -714,26 +714,4 @@ 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/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb index b0855af9524..cb3bc392903 100644 --- a/spec/features/merge_requests/edit_mr_spec.rb +++ b/spec/features/merge_requests/edit_mr_spec.rb @@ -67,23 +67,5 @@ feature 'Edit Merge Request', feature: true do def get_textarea_height page.evaluate_script('document.getElementById("merge_request_description").offsetHeight') end - - describe '"edited by" message', js: true do - context 'when merge request is updated' do - it 'shows "edited by" mesage on title update' do - fill_in 'merge_request_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 'merge_request_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 diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 5b324f3c706..ee01b3871f3 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -132,6 +132,17 @@ describe Issues::UpdateService, services: true do end end + context 'when description changed' do + it 'creates system note about description change' do + update_issue(description: 'Changed description') + + note = find_note('changed the description') + + expect(note).not_to be_nil + expect(note.note).to eq('changed the description') + end + end + context 'when issue turns confidential' do let(:opts) do { diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index f2ca1e6fcbd..98fc41f2ac0 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -102,6 +102,13 @@ describe MergeRequests::UpdateService, services: true do expect(note.note).to eq 'changed title from **{-Old-} title** to **{+New+} title**' end + it 'creates system note about description change' do + note = find_note('changed the description') + + expect(note).not_to be_nil + expect(note.note).to eq('changed the description') + end + it 'creates system note about branch change' do note = find_note('changed target') diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 5e85c3c1621..5775874ebe0 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -301,7 +301,7 @@ describe SystemNoteService, services: true do end it 'sets the note text' do - expect(subject.note).to eq 'changed the description' + expect(subject.note).to eq('changed the description') end end end -- cgit v1.2.1