Improve JIRA event descriptions
This commit is contained in:
parent
9fd2d9ea24
commit
2ee197086a
8 changed files with 88 additions and 29 deletions
|
@ -1,27 +1,4 @@
|
|||
module ServicesHelper
|
||||
def service_event_description(event)
|
||||
case event
|
||||
when "push", "push_events"
|
||||
"Event will be triggered by a push to the repository"
|
||||
when "tag_push", "tag_push_events"
|
||||
"Event will be triggered when a new tag is pushed to the repository"
|
||||
when "note", "note_events"
|
||||
"Event will be triggered when someone adds a comment"
|
||||
when "issue", "issue_events"
|
||||
"Event will be triggered when an issue is created/updated/closed"
|
||||
when "confidential_issue", "confidential_issue_events"
|
||||
"Event will be triggered when a confidential issue is created/updated/closed"
|
||||
when "merge_request", "merge_request_events"
|
||||
"Event will be triggered when a merge request is created/updated/merged"
|
||||
when "pipeline", "pipeline_events"
|
||||
"Event will be triggered when a pipeline status changes"
|
||||
when "wiki_page", "wiki_page_events"
|
||||
"Event will be triggered when a wiki page is created/updated"
|
||||
when "commit", "commit_events"
|
||||
"Event will be triggered when a commit is created/updated"
|
||||
end
|
||||
end
|
||||
|
||||
def service_event_field_name(event)
|
||||
event = event.pluralize if %w[merge_request issue confidential_issue].include?(event)
|
||||
"#{event}_events"
|
||||
|
|
|
@ -14,9 +14,8 @@ class JiraService < IssueTrackerService
|
|||
|
||||
alias_method :project_url, :url
|
||||
|
||||
# This is confusing, but JiraService does not really support these events.
|
||||
# The values here are required to display correct options in the service
|
||||
# configuration screen.
|
||||
# When these are false GitLab does not create cross reference
|
||||
# comments on JIRA except when an issue gets transitioned.
|
||||
def self.supported_events
|
||||
%w(commit merge_request)
|
||||
end
|
||||
|
@ -318,4 +317,13 @@ class JiraService < IssueTrackerService
|
|||
|
||||
url_changed?
|
||||
end
|
||||
|
||||
def self.event_description(event)
|
||||
case event
|
||||
when "merge_request", "merge_request_events"
|
||||
"JIRA comments will be created when an issue gets referenced in a merge request."
|
||||
when "commit", "commit_events"
|
||||
"JIRA comments will be created when an issue gets referenced in a commit."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -304,6 +304,29 @@ class Service < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.event_description(event)
|
||||
case event
|
||||
when "push", "push_events"
|
||||
"Event will be triggered by a push to the repository"
|
||||
when "tag_push", "tag_push_events"
|
||||
"Event will be triggered when a new tag is pushed to the repository"
|
||||
when "note", "note_events"
|
||||
"Event will be triggered when someone adds a comment"
|
||||
when "issue", "issue_events"
|
||||
"Event will be triggered when an issue is created/updated/closed"
|
||||
when "confidential_issue", "confidential_issue_events"
|
||||
"Event will be triggered when a confidential issue is created/updated/closed"
|
||||
when "merge_request", "merge_request_events"
|
||||
"Event will be triggered when a merge request is created/updated/merged"
|
||||
when "pipeline", "pipeline_events"
|
||||
"Event will be triggered when a pipeline status changes"
|
||||
when "wiki_page", "wiki_page_events"
|
||||
"Event will be triggered when a wiki page is created/updated"
|
||||
when "commit", "commit_events"
|
||||
"Event will be triggered when a commit is created/updated"
|
||||
end
|
||||
end
|
||||
|
||||
def valid_recipients?
|
||||
activated? && !importing?
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
= form.text_field field[:name], class: "form-control", placeholder: field[:placeholder]
|
||||
|
||||
%p.light
|
||||
= service_event_description(event)
|
||||
= @service.class.event_description(event)
|
||||
|
||||
- @service.global_fields.each do |field|
|
||||
- type = field[:type]
|
||||
|
|
5
changelogs/unreleased/issue_25542.yml
Normal file
5
changelogs/unreleased/issue_25542.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Improve JIRA event descriptions
|
||||
merge_request:
|
||||
author:
|
||||
type: other
|
|
@ -735,7 +735,7 @@ module API
|
|||
required: false,
|
||||
name: event_name.to_sym,
|
||||
type: String,
|
||||
desc: ServicesHelper.service_event_description(event_name)
|
||||
desc: service.event_description(event_name)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -743,7 +743,7 @@ describe SystemNoteService do
|
|||
expect(cross_reference(type)).to eq("Events for #{type.pluralize.humanize.downcase} are disabled.")
|
||||
end
|
||||
|
||||
it "blocks cross reference when #{type.underscore}_events is true" do
|
||||
it "creates cross reference when #{type.underscore}_events is true" do
|
||||
jira_tracker.update("#{type}_events" => true)
|
||||
|
||||
expect(cross_reference(type)).to eq(success_message)
|
||||
|
|
46
spec/views/projects/services/_form.haml_spec.rb
Normal file
46
spec/views/projects/services/_form.haml_spec.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'projects/services/_form' do
|
||||
let(:project) { create(:redmine_project) }
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
before do
|
||||
assign(:project, project)
|
||||
|
||||
allow(controller).to receive(:current_user).and_return(user)
|
||||
|
||||
allow(view).to receive_messages(current_user: user,
|
||||
can?: true,
|
||||
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
|
||||
end
|
||||
|
||||
context 'commit_events and merge_request_events' do
|
||||
before do
|
||||
assign(:service, project.redmine_service)
|
||||
end
|
||||
|
||||
it 'display merge_request_events and commit_events descriptions' do
|
||||
allow(RedmineService).to receive(:supported_events).and_return(%w(commit merge_request))
|
||||
|
||||
render
|
||||
|
||||
expect(rendered).to have_content('Event will be triggered when a commit is created/updated')
|
||||
expect(rendered).to have_content('Event will be triggered when a merge request is created/updated/merged')
|
||||
end
|
||||
|
||||
context 'when service is JIRA' do
|
||||
let(:project) { create(:jira_project) }
|
||||
|
||||
before do
|
||||
assign(:service, project.jira_service)
|
||||
end
|
||||
|
||||
it 'display merge_request_events and commit_events descriptions' do
|
||||
render
|
||||
|
||||
expect(rendered).to have_content('JIRA comments will be created when an issue gets referenced in a commit.')
|
||||
expect(rendered).to have_content('JIRA comments will be created when an issue gets referenced in a merge request.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue