summaryrefslogtreecommitdiff
path: root/app/models/project_services/jira_service.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-16 15:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-16 15:06:26 +0000
commit84727c8209a4412e21111a07f99b0438b03232de (patch)
tree1fcfa02b01548c3cdc561186870a1c807f227f0b /app/models/project_services/jira_service.rb
parentd2798d607e11e0ebae83ae909404834388733428 (diff)
downloadgitlab-ce-84727c8209a4412e21111a07f99b0438b03232de.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/project_services/jira_service.rb')
-rw-r--r--app/models/project_services/jira_service.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index 0728c83005e..61ae78a0b95 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -17,7 +17,10 @@ class JiraService < IssueTrackerService
# Jira Cloud version is deprecating authentication via username and password.
# We should use username/password for Jira Server and email/api_token for Jira Cloud,
# for more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/49936.
- prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id
+
+ # TODO: we can probably just delegate as part of
+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ data_field :username, :password, :url, :api_url, :jira_issue_transition_id
before_update :reset_password
@@ -35,24 +38,34 @@ class JiraService < IssueTrackerService
end
def initialize_properties
- super do
- self.properties = {
- url: issues_tracker['url'],
- api_url: issues_tracker['api_url']
- }
- end
+ {}
+ end
+
+ def data_fields
+ jira_tracker_data || self.build_jira_tracker_data
end
def reset_password
- self.password = nil if reset_password?
+ data_fields.password = nil if reset_password?
+ end
+
+ def set_default_data
+ return unless issues_tracker.present?
+
+ self.title ||= issues_tracker['title']
+
+ return if url
+
+ data_fields.url ||= issues_tracker['url']
+ data_fields.api_url ||= issues_tracker['api_url']
end
def options
url = URI.parse(client_url)
{
- username: self.username,
- password: self.password,
+ username: username,
+ password: password,
site: URI.join(url, '/').to_s, # Intended to find the root
context_path: url.path,
auth_type: :basic,