Updated specs

This commit is contained in:
blackst0ne 2017-05-05 23:01:50 +11:00
parent cca09bbb18
commit 8c4c40d09b
6 changed files with 19 additions and 71 deletions

View file

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

View file

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

View file

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

View file

@ -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
{

View file

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

View file

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