Commit 2ee19708 authored by Felipe Artur's avatar Felipe Artur

Improve JIRA event descriptions

parent 9fd2d9ea
module ServicesHelper 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) def service_event_field_name(event)
event = event.pluralize if %w[merge_request issue confidential_issue].include?(event) event = event.pluralize if %w[merge_request issue confidential_issue].include?(event)
"#{event}_events" "#{event}_events"
......
...@@ -14,9 +14,8 @@ class JiraService < IssueTrackerService ...@@ -14,9 +14,8 @@ class JiraService < IssueTrackerService
alias_method :project_url, :url alias_method :project_url, :url
# This is confusing, but JiraService does not really support these events. # When these are false GitLab does not create cross reference
# The values here are required to display correct options in the service # comments on JIRA except when an issue gets transitioned.
# configuration screen.
def self.supported_events def self.supported_events
%w(commit merge_request) %w(commit merge_request)
end end
...@@ -318,4 +317,13 @@ class JiraService < IssueTrackerService ...@@ -318,4 +317,13 @@ class JiraService < IssueTrackerService
url_changed? url_changed?
end 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 end
...@@ -304,6 +304,29 @@ class Service < ActiveRecord::Base ...@@ -304,6 +304,29 @@ class Service < ActiveRecord::Base
end end
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? def valid_recipients?
activated? && !importing? activated? && !importing?
end end
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
= form.text_field field[:name], class: "form-control", placeholder: field[:placeholder] = form.text_field field[:name], class: "form-control", placeholder: field[:placeholder]
%p.light %p.light
= service_event_description(event) = @service.class.event_description(event)
- @service.global_fields.each do |field| - @service.global_fields.each do |field|
- type = field[:type] - type = field[:type]
......
---
title: Improve JIRA event descriptions
merge_request:
author:
type: other
...@@ -735,7 +735,7 @@ module API ...@@ -735,7 +735,7 @@ module API
required: false, required: false,
name: event_name.to_sym, name: event_name.to_sym,
type: String, type: String,
desc: ServicesHelper.service_event_description(event_name) desc: service.event_description(event_name)
} }
end end
end end
......
...@@ -743,7 +743,7 @@ describe SystemNoteService do ...@@ -743,7 +743,7 @@ describe SystemNoteService do
expect(cross_reference(type)).to eq("Events for #{type.pluralize.humanize.downcase} are disabled.") expect(cross_reference(type)).to eq("Events for #{type.pluralize.humanize.downcase} are disabled.")
end 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) jira_tracker.update("#{type}_events" => true)
expect(cross_reference(type)).to eq(success_message) expect(cross_reference(type)).to eq(success_message)
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment