summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Leitzen <pl@neopoly.de>2018-08-10 17:51:34 +0200
committerPeter Leitzen <pl@neopoly.de>2018-08-10 17:51:34 +0200
commitea9c7bee4b167e85e192cc40720d2c4cc07540ab (patch)
tree0707a83b1408eaa69acfc03bb1248319d0a4051b
parent82337dd684d88ec38285d51cfb1180b1a1057b95 (diff)
downloadgitlab-ce-ea9c7bee4b167e85e192cc40720d2c4cc07540ab.tar.gz
Fix preview of commit tagging
-rw-r--r--app/services/quick_actions/target_service.rb2
-rw-r--r--spec/features/commits/user_uses_slash_commands_spec.rb10
-rw-r--r--spec/services/quick_actions/target_service_spec.rb10
-rw-r--r--spec/support/helpers/features/notes_helpers.rb7
4 files changed, 25 insertions, 4 deletions
diff --git a/app/services/quick_actions/target_service.rb b/app/services/quick_actions/target_service.rb
index b29b141a309..d8ba52c6e50 100644
--- a/app/services/quick_actions/target_service.rb
+++ b/app/services/quick_actions/target_service.rb
@@ -24,8 +24,6 @@ module QuickActions
end
def commit(type_id)
- return nil unless type_id
-
project.commit(type_id)
end
end
diff --git a/spec/features/commits/user_uses_slash_commands_spec.rb b/spec/features/commits/user_uses_slash_commands_spec.rb
index f356155be61..d8359766509 100644
--- a/spec/features/commits/user_uses_slash_commands_spec.rb
+++ b/spec/features/commits/user_uses_slash_commands_spec.rb
@@ -32,5 +32,15 @@ describe 'Commit > User uses quick actions', :js do
expect(page).to have_content tag_message
expect(page).to have_content truncated_commit_sha
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
diff --git a/spec/services/quick_actions/target_service_spec.rb b/spec/services/quick_actions/target_service_spec.rb
index 36de5269dea..abe07ae90ba 100644
--- a/spec/services/quick_actions/target_service_spec.rb
+++ b/spec/services/quick_actions/target_service_spec.rb
@@ -57,13 +57,19 @@ describe QuickActions::TargetService do
context 'for commit' do
let(:project) { create(:project, :repository) }
- let(:target) { project.commit }
+ let(:target) { project.commit.parent }
let(:target_id) { target.sha }
let(:type) { 'Commit' }
it_behaves_like 'find target'
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
context 'for unknown type' do
diff --git a/spec/support/helpers/features/notes_helpers.rb b/spec/support/helpers/features/notes_helpers.rb
index 2b9f8b30c60..89517fde6e2 100644
--- a/spec/support/helpers/features/notes_helpers.rb
+++ b/spec/support/helpers/features/notes_helpers.rb
@@ -20,6 +20,13 @@ module Spec
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