Fix preview of commit tagging

This commit is contained in:
Peter Leitzen 2018-08-10 17:51:34 +02:00
parent 82337dd684
commit ea9c7bee4b
4 changed files with 25 additions and 4 deletions

View file

@ -24,8 +24,6 @@ module QuickActions
end end
def commit(type_id) def commit(type_id)
return nil unless type_id
project.commit(type_id) project.commit(type_id)
end end
end end

View file

@ -32,5 +32,15 @@ describe 'Commit > User uses quick actions', :js do
expect(page).to have_content tag_message expect(page).to have_content tag_message
expect(page).to have_content truncated_commit_sha expect(page).to have_content truncated_commit_sha
end end
describe 'preview', :js do
it 'removes quick action from note and explains it' do
preview_note("/tag #{tag_name} #{tag_message}")
expect(page).not_to have_content '/tag'
expect(page).to have_content %{Tags this commit to #{tag_name} with "#{tag_message}"}
expect(page).to have_content tag_name
end
end
end end
end end

View file

@ -57,13 +57,19 @@ describe QuickActions::TargetService do
context 'for commit' do context 'for commit' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:target) { project.commit } let(:target) { project.commit.parent }
let(:target_id) { target.sha } let(:target_id) { target.sha }
let(:type) { 'Commit' } let(:type) { 'Commit' }
it_behaves_like 'find target' it_behaves_like 'find target'
it_behaves_like 'no target', type_id: 'invalid_sha' it_behaves_like 'no target', type_id: 'invalid_sha'
it_behaves_like 'no target', type_id: nil
context 'with nil target_id' do
let(:target) { project.commit }
let(:target_id) { nil }
it_behaves_like 'find target'
end
end end
context 'for unknown type' do context 'for unknown type' do

View file

@ -20,6 +20,13 @@ module Spec
end end
end end
end end
def preview_note(text)
page.within('.js-main-target-form') do
fill_in('note[note]', with: text)
click_on('Preview')
end
end
end end
end end
end end