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
64
65
66
67
68
|
# File 'lib/you_track/client/requests/apply_issue_command.rb', line 16
def mock
issue = find(:issues, identity)
= "#{Cistern::Mock.random_numbers(2)}-#{Cistern::Mock.random_numbers(5)}"
if = params["comment"]
service.data[:comments][] = {
"id" => ,
"author" => service.username,
"deleted" => false,
"text" => ,
"shownForIssuer" => false,
"created" => ms_time,
"issueId" => identity,
}
end
if command = params["command"]
words = command.scan(/[^\s]+/) acceptable_commands = find(:project_custom_fields, issue["projectShortName"]).map { |cf| cf["name"] }
command_map = Hash.new { |h,k| h[k] = [] }
current_command = words.shift
words.each do |word|
unless acceptable_commands.include?(word)
command_map[current_command] << word
else
current_command = word
end
end
commands = command_map.inject({}) { |r,(k,v)| r.merge(k => v.join(" ")) }
commands.each do |field, value|
prototype = service.data[:custom_fields].fetch(field)
bundle_value = if bundle = service.data[:bundles][prototype["defaultBundle"]]
bundle["values"].find { |v| v["value"] == value }
else {}
end
if bundle_value["resolved"] == "true"
issue["resolved"] = ms_time(Time.now)
end
issue["custom_fields"].find { |name, _| name == field }[1] = value
end
end
service.response
end
|