mantis_ruby 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/mantis_ruby.rb +151 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f0503ed8b0ed58cc50e58959dab44b762ae9b48
4
+ data.tar.gz: bcb4579217664d02ba5934fdb0c4bbf07f91b379
5
+ SHA512:
6
+ metadata.gz: 1ec9ba1bcfdd93f54db749abd1c4403cad53f87098aa3855173eaff486141976a40caa753ce1033fdb4da01d3679ed4f6ecf5e89cd6c5f4eb508eb1f686a8983
7
+ data.tar.gz: 68bc19b38c7101592e556589c18a752fceadfbca762f536375dca44f8eb35ce6d715fbd235729a412f5c6a8ea01f7b60879d56a2e83606a289005d3a74be027f
@@ -0,0 +1,151 @@
1
+ require 'httpclient'
2
+ require 'savon'
3
+
4
+ class MantisRuby
5
+ def self.hi
6
+ puts "Hello world!"
7
+ end
8
+
9
+ def initialize(username,password,wsdl)
10
+ @username=username
11
+ @password=password
12
+ @wsdl=wsdl
13
+ puts connect_to_tracker
14
+ end
15
+
16
+ def connect_to_tracker
17
+ @client = Savon.client(wsdl: "#{self.wsdl}/api/soap/mantisconnect.php?wsdl" )
18
+ end
19
+
20
+ def check_version
21
+ client=connect_to_tracker
22
+ @response=client.call(:mc_version)
23
+ end
24
+
25
+ def projects_get_user_accessible
26
+ client=connect_to_tracker
27
+ @response=client.call(:mc_projects_get_user_accessible,message: {username: self.client_id,
28
+ password: self.client_key})
29
+ JSON.parse(@response.to_json)["mc_projects_get_user_accessible_response"]["return"]
30
+ end
31
+
32
+ def push_all_bugs
33
+ client=connect_to_tracker
34
+ # self.is_busy = true
35
+ # self.save
36
+ get_cycle_bugs.each do |bug|
37
+ puts "Bug"
38
+ push_bug(bug)
39
+ set_attachment(bug)
40
+ set_priority(bug)
41
+ end
42
+ # self.is_busy = false
43
+ # self.save
44
+ end
45
+
46
+ def push_bug(bug)
47
+ client=connect_to_tracker
48
+ @response = client.call(:mc_issue_add, message: {username: self.client_id,
49
+ password: self.client_key,
50
+ issue: {status: bug.status,
51
+ summary: bug.title,
52
+ description: ("#{bug.description} \r\n ---------------- \r\n Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}"),
53
+ "steps_to_reproduce" => "#{bug.description}",
54
+ "additional_information" => "Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}",
55
+ category: "General" ,
56
+ "add_note"=> ((bug.enterprisecyclecomponent.nil?) ? "" : bug.enterprisecyclecomponent.name ),
57
+ resolution: bug.screenresolution,
58
+ severity: ((bug.btype=="Feature") ? "10" : ((bug.btype=="Technical") ? "60" : ((bug.btype=="GUI") ? "40" : ((bug.btype=="Functional") ? "60" : "50") ))),
59
+ reproducibility: ((bug.freq == "Every Time") ? "10" : ((bug.freq == "Frequently") ? "10" : ((bug.freq == "Rarely") ? "50" : ((bug.freq == "Once") ? "30" : "N/A" )))),
60
+ priority: ((bug.priority==1) ? "50" : ((bug.priority==2) ? "40" : ((bug.priority==3) ? "30" : ((bug.priority==4) ? "20" : "10" ) ))),
61
+ project: {id: self.project_id,
62
+ name: self.project_name
63
+ }
64
+ }
65
+ }
66
+ )
67
+ return_id=JSON.parse(@response.to_json)["mc_issue_add_response"]["return"]
68
+ @response
69
+ end
70
+
71
+ def update_bug(bug_id)
72
+ client=connect_to_tracker
73
+ @response = client.call(:mc_issue_update, message: {username: self.client_id,
74
+ password: self.client_key,
75
+ "issueId" => map_bug_id,
76
+ issue: {status: bug.status,
77
+ summary: bug.title,
78
+ description: ("#{bug.description} \r\n ---------------- \r\n Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}"),
79
+ "steps_to_reproduce" => "#{bug.description}",
80
+ "additional_information" => "Actual Result: \r\n #{bug.actual} \r\n ---------------- \r\n Expected Result:\r\n #{bug.expected} \r\n ---------------- \r\n Screen Resolution:\r\n #{bug.screenresolution}",
81
+ category: "General" ,
82
+ "add_note"=> ((bug.enterprisecyclecomponent.nil?) ? "" : bug.enterprisecyclecomponent.name ),
83
+ resolution: bug.screenresolution,
84
+ severity: ((bug.btype=="Feature") ? "10" : ((bug.btype=="Technical") ? "60" : ((bug.btype=="GUI") ? "40" : ((bug.btype=="Functional") ? "60" : "50") ))),
85
+ reproducibility: ((bug.freq == "Every Time") ? "10" : ((bug.freq == "Frequently") ? "10" : ((bug.freq == "Rarely") ? "50" : ((bug.freq == "Once") ? "30" : "N/A" )))),
86
+ priority: ((bug.priority==1) ? "50" : ((bug.priority==2) ? "40" : ((bug.priority==3) ? "30" : ((bug.priority==4) ? "20" : "10" ) ))),
87
+ project: {id: self.project_id,
88
+ name: self.project_name}}})
89
+ set_attachment(bug)
90
+ set_priority(bug)
91
+ @response
92
+ end
93
+
94
+ def set_note(bug) ########Working
95
+ client=connect_to_tracker
96
+ @response = client.call(:mc_issue_note_add,
97
+ message: {username: self.client_id,
98
+ password: self.client_key,
99
+ "issue_id"=>map_bug_id,
100
+ note: {text: bug.enterprisecyclecomponent.name }
101
+ }
102
+ )
103
+ end
104
+
105
+ def set_tag(bug)
106
+ client=connect_to_tracker
107
+ @response = client.call(:mc_issue_set_tags,
108
+ message: {username: self.client_id,
109
+ password: self.client_key,
110
+ "issue_id"=>map_bug_id,
111
+ tags: [""] ##Array of tags
112
+ }
113
+ )
114
+ return_id=JSON.parse(@response.to_json)
115
+ puts return_id
116
+ @response
117
+ end
118
+
119
+ def set_priority(bug) ########Working
120
+ client=connect_to_tracker
121
+ @response = client.call(:mc_issue_note_add,
122
+ message: {username: self.client_id,
123
+ password: self.client_key,
124
+ "issue_id"=>map_bug_id,
125
+ note: {text: bug.enterprisecyclecomponent.name }
126
+ }
127
+ )
128
+ end
129
+
130
+ def set_attachment(bug)
131
+ client=connect_to_tracker
132
+ begin
133
+ file_name="bug_#{Time.now.to_i}.#{bug.ext}"
134
+ file_location = bug.cdn_url("enterprisebug_#{bug.id}_#{bug.created_at.to_i}.#{bug.ext}")
135
+ sf = open(file_location, 'rb') { |io| io.read }
136
+ sfile=Base64::encode64(sf)
137
+ @response = client.call(:mc_issue_attachment_add,
138
+ message: {username: self.client_id,
139
+ password: self.client_key,
140
+ "issue_id"=> map_bug_id,
141
+ name: file_name,
142
+ "file_type" => bug.content_type,
143
+ "content"=> sfile
144
+ }
145
+ )
146
+ rescue Exception => e
147
+ puts "File not submitted : #{e}"
148
+ end
149
+ end
150
+
151
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mantis_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dimo Mohit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gem to integrate Mantis Testing tool with Ruby apps
14
+ email: mohitdutta@live.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/mantis_ruby.rb
20
+ homepage: http://rubygems.org/gems/mantis_ruby
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.5
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Mantis Testing tool with Ruby
44
+ test_files: []
45
+ has_rdoc: