issue_tracker.rb
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class IssueTracker
include Mongoid::Document
include Mongoid::Timestamps
include HashHelper
include Rails.application.routes.url_helpers
default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
default_url_options[:port] = ActionMailer::Base.default_url_options[:port]
embedded_in :app, :inverse_of => :issue_tracker
field :project_id, :type => String
field :alt_project_id, :type => String # Specify an alternative project id. e.g. for viewing files
field :api_token, :type => String
field :account, :type => String
field :username, :type => String
field :password, :type => String
field :ticket_properties, :type => String
field :subdomain, :type => String
field :milestone_id, :type => String
# Is there any better way to enhance the props? Putting them into the subclass leads to
# an error while rendering the form fields -.-
field :base_url, :type => String
field :context_path, :type => String
field :issue_type, :type => String
field :issue_component, :type => String
field :issue_priority, :type => String
validate :check_params
# Subclasses are responsible for overwriting this method.
def check_params; true; end
def issue_title(problem)
"[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}"
end
# Allows us to set the issue tracker class from a single form.
def type; self._type; end
def type=(t); self._type=t; end
def url; nil; end
# Retrieve tracker label from either class or instance.
Label = ''
def self.label; self::Label; end
def label; self.class.label; end
def configured?
project_id.present?
end
##
# Update default_url_option with valid data from the request information
#
# @param [ Request ] a request with host, port and protocol
#
def self.update_url_options(request)
IssueTracker.default_url_options[:host] = request.host
IssueTracker.default_url_options[:port] = request.port
IssueTracker.default_url_options[:protocol] = request.scheme
end
end