ludo-roart 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +45 -0
- data/README.rdoc +89 -0
- data/Rakefile +35 -0
- data/lib/roart.rb +52 -0
- data/lib/roart/callbacks.rb +25 -0
- data/lib/roart/connection.rb +65 -0
- data/lib/roart/connection_adapter.rb +21 -0
- data/lib/roart/connection_adapters/mechanize_adapter.rb +32 -0
- data/lib/roart/core/content_formatter.rb +12 -0
- data/lib/roart/core/hash.rb +22 -0
- data/lib/roart/errors.rb +13 -0
- data/lib/roart/history.rb +115 -0
- data/lib/roart/roart.rb +35 -0
- data/lib/roart/ticket.rb +461 -0
- data/lib/roart/ticket_page.rb +78 -0
- data/lib/roart/validations.rb +230 -0
- data/roart.gemspec +39 -0
- data/spec/roart/callbacks_spec.rb +49 -0
- data/spec/roart/connection_adapter_spec.rb +11 -0
- data/spec/roart/connection_spec.rb +54 -0
- data/spec/roart/core/hash_spec.rb +22 -0
- data/spec/roart/history_spec.rb +60 -0
- data/spec/roart/roart_spec.rb +11 -0
- data/spec/roart/ticket_page_spec.rb +93 -0
- data/spec/roart/ticket_spec.rb +553 -0
- data/spec/roart/validation_spec.rb +152 -0
- data/spec/roart_spec.rb +8 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/test_data/full_history.txt +126 -0
- data/spec/test_data/search_ticket.txt +13 -0
- data/spec/test_data/single_history.txt +26 -0
- data/spec/test_data/ticket.txt +31 -0
- metadata +151 -0
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "validations" do
|
4
|
+
|
5
|
+
describe "field length" do
|
6
|
+
|
7
|
+
it "show validate too short" do
|
8
|
+
class ShortTicket < Roart::Ticket; validates_length_of(:subject, :min => 6); end
|
9
|
+
ticket = inst_ticket(ShortTicket)
|
10
|
+
ticket.subject = "short"
|
11
|
+
ticket.valid?.should be_false
|
12
|
+
ticket.subject = "longer subject"
|
13
|
+
ticket.valid?.should be_true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should validate too long" do
|
17
|
+
class LongTicket < Roart::Ticket; validates_length_of(:subject, :max => 6); end
|
18
|
+
ticket = inst_ticket(LongTicket)
|
19
|
+
ticket.subject = "too long"
|
20
|
+
ticket.valid?.should be_false
|
21
|
+
ticket.subject = "short"
|
22
|
+
ticket.valid?.should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should validate exact" do
|
26
|
+
class ExactTicket < Roart::Ticket; validates_length_of(:subject, :is => 5); end
|
27
|
+
ticket = inst_ticket(ExactTicket)
|
28
|
+
ticket.subject = "Not Five"
|
29
|
+
ticket.valid?.should be_false
|
30
|
+
ticket.subject = "Yes 5"
|
31
|
+
ticket.valid?.should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should validate range" do
|
35
|
+
class RangeTicket < Roart::Ticket; validates_length_of(:subject, :within => 7..12); end
|
36
|
+
ticket = inst_ticket(RangeTicket)
|
37
|
+
ticket.subject = 'short'
|
38
|
+
ticket.valid?.should be_false
|
39
|
+
ticket.subject = 'waaaaay toooooo long'
|
40
|
+
ticket.valid?.should be_false
|
41
|
+
ticket.subject = 'just right'
|
42
|
+
ticket.valid?.should be_true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "format" do
|
48
|
+
|
49
|
+
it "should validate format" do
|
50
|
+
class FormatTicket < Roart::Ticket; validates_format_of(:subject, :format => /^lol$/); end
|
51
|
+
ticket = inst_ticket(FormatTicket)
|
52
|
+
ticket.subject = 'poop'
|
53
|
+
ticket.valid?.should be_false
|
54
|
+
ticket.subject = 'lol'
|
55
|
+
ticket.valid?.should be_true
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "presence" do
|
61
|
+
|
62
|
+
it "should validate presence of" do
|
63
|
+
class PresenceTicket < Roart::Ticket; validates_presence_of(:subject); end
|
64
|
+
ticket = inst_ticket(PresenceTicket)
|
65
|
+
ticket.subject = ""
|
66
|
+
ticket.valid?.should be_false
|
67
|
+
ticket.subject = "I'M HERE!"
|
68
|
+
ticket.valid?.should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should validate presence of" do
|
72
|
+
class PresenceTicket < Roart::Ticket; validates_presence_of(:subject); end
|
73
|
+
ticket = inst_ticket(PresenceTicket)
|
74
|
+
ticket.subject = nil
|
75
|
+
ticket.valid?.should be_false
|
76
|
+
ticket.subject = "I'M HERE!"
|
77
|
+
ticket.valid?.should be_true
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "numericality" do
|
83
|
+
|
84
|
+
it "should validate greater than" do
|
85
|
+
class GTTicket < Roart::Ticket; validates_numericality_of(:subject, :greater_than => 5); end
|
86
|
+
ticket = inst_ticket(GTTicket)
|
87
|
+
ticket.subject = 4
|
88
|
+
ticket.valid?.should be_false
|
89
|
+
ticket.subject = 6
|
90
|
+
ticket.valid?.should be_true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should validate less than" do
|
94
|
+
class LTTicket < Roart::Ticket; validates_numericality_of(:subject, :less_than => 5); end
|
95
|
+
ticket = inst_ticket(LTTicket)
|
96
|
+
ticket.subject = 6
|
97
|
+
ticket.valid?.should be_false
|
98
|
+
ticket.subject = 4
|
99
|
+
ticket.valid?.should be_true
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should validate integer" do
|
103
|
+
class IntTicket < Roart::Ticket; validates_numericality_of(:subject, :only_integer => true); end
|
104
|
+
ticket = inst_ticket(IntTicket)
|
105
|
+
ticket.subject = 6.3
|
106
|
+
ticket.valid?.should be_false
|
107
|
+
ticket.subject = 4
|
108
|
+
ticket.valid?.should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should validate integer" do
|
112
|
+
class EqualTicket < Roart::Ticket; validates_numericality_of(:subject, :equal_to => 4); end
|
113
|
+
ticket = inst_ticket(EqualTicket)
|
114
|
+
ticket.subject = 6.3
|
115
|
+
ticket.valid?.should be_false
|
116
|
+
ticket.subject = 4
|
117
|
+
ticket.valid?.should be_true
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should validate even" do
|
121
|
+
class EvenTicket < Roart::Ticket; validates_numericality_of(:subject, :even => true); end
|
122
|
+
ticket = inst_ticket(EvenTicket)
|
123
|
+
ticket.subject = 6.3
|
124
|
+
ticket.valid?.should be_false
|
125
|
+
ticket.subject = 5
|
126
|
+
ticket.valid?.should be_false
|
127
|
+
ticket.subject = 4
|
128
|
+
ticket.valid?.should be_true
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should validate two at once" do
|
132
|
+
class DoubleTeam < Roart::Ticket; validates_numericality_of(:subject, :even => true, :greater_than => 5); end
|
133
|
+
ticket = inst_ticket(DoubleTeam)
|
134
|
+
ticket.subject = 6.3
|
135
|
+
ticket.valid?.should be_false
|
136
|
+
ticket.subject = 9
|
137
|
+
ticket.valid?.should be_false
|
138
|
+
ticket.subject = 4
|
139
|
+
ticket.valid?.should be_false
|
140
|
+
ticket.subject = 8
|
141
|
+
ticket.valid?.should be_true
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
#helpers
|
149
|
+
|
150
|
+
def inst_ticket(klass)
|
151
|
+
klass.send(:instantiate,{:subject => 'A New Ticket', :queue => 'My Queue', :id => 1})
|
152
|
+
end
|
data/spec/roart_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'roart'
|
2
|
+
|
3
|
+
def dbtime(time)
|
4
|
+
time.strftime("%Y-%m-%d %H:%M:%S")
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_content_format(data)
|
8
|
+
fields = data.map { |key,value| "#{key.to_s.camelize}: #{value}" unless value.nil? }
|
9
|
+
fields.compact.sort.join("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
# == Mock Framework
|
14
|
+
#
|
15
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
16
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
17
|
+
#
|
18
|
+
# config.mock_with :mocha
|
19
|
+
# config.mock_with :flexmock
|
20
|
+
# config.mock_with :rr
|
21
|
+
end
|
22
|
+
|
23
|
+
# EOF
|
@@ -0,0 +1,126 @@
|
|
1
|
+
RT/3.6.6 200 Ok
|
2
|
+
|
3
|
+
# 5/5 (id/34725/total)
|
4
|
+
|
5
|
+
id: 34725
|
6
|
+
Ticket: 12345
|
7
|
+
TimeTaken: 0
|
8
|
+
Type: Create
|
9
|
+
Field:
|
10
|
+
OldValue:
|
11
|
+
NewValue:
|
12
|
+
Data:
|
13
|
+
Description: Ticket created by Dallas-stezuohc@LEESSUMMITHONDA.COM
|
14
|
+
|
15
|
+
Content: Now you can get big real fast at an affordable price
|
16
|
+
http://www.lameppe.com/
|
17
|
+
|
18
|
+
|
19
|
+
Creator: Dallas-stezuohc@LEESSUMMITHONDA.COM
|
20
|
+
Created: 2008-06-03 09:24:32
|
21
|
+
|
22
|
+
Attachments:
|
23
|
+
16377: untitled (77b)
|
24
|
+
16379: untitled (248b)
|
25
|
+
|
26
|
+
|
27
|
+
--
|
28
|
+
|
29
|
+
# 5/5 (id/34727/total)
|
30
|
+
|
31
|
+
id: 34727
|
32
|
+
Ticket: 12345
|
33
|
+
TimeTaken: 0
|
34
|
+
Type: EmailRecord
|
35
|
+
Field:
|
36
|
+
OldValue:
|
37
|
+
NewValue:
|
38
|
+
Data: <rt-3.6.6-50432-1212485073-937.12345-456-0@somewhere.com>
|
39
|
+
Description: Outgoing email recorded by RT_System
|
40
|
+
|
41
|
+
Content:
|
42
|
+
Greetings,
|
43
|
+
|
44
|
+
This message has been automatically generated in response to the creation of a trouble ticket at Somewhere Technical Support regarding:
|
45
|
+
"SUPPORT EMAIL: Somewhere- 2 pills a day and you will be good"
|
46
|
+
|
47
|
+
There is no need to reply to this message right now. Your ticket has been
|
48
|
+
assigned an ID of [RequestTracker #12345].
|
49
|
+
|
50
|
+
Please include the ID in the subject line, or "reply" to this message, for all future correspondence about this issue.
|
51
|
+
|
52
|
+
You can also call us 24 hours a day, 7 days a week.
|
53
|
+
|
54
|
+
We appreciate your business!
|
55
|
+
|
56
|
+
Sincerely,
|
57
|
+
|
58
|
+
Somewhere Technical Support Team
|
59
|
+
|
60
|
+
Thank you,
|
61
|
+
support@somewhere.com
|
62
|
+
1-800-468-3474
|
63
|
+
|
64
|
+
-------------------------------------------------------------------------
|
65
|
+
Now you can get big real fast at an affordable price
|
66
|
+
http://www.lameppe.com/
|
67
|
+
|
68
|
+
|
69
|
+
Creator: RT_System
|
70
|
+
Created: 2008-06-03 09:24:33
|
71
|
+
Attachments:
|
72
|
+
|
73
|
+
--
|
74
|
+
|
75
|
+
# 5/5 (id/34871/total)
|
76
|
+
|
77
|
+
id: 34871
|
78
|
+
Ticket: 12345
|
79
|
+
TimeTaken: 0
|
80
|
+
Type: Take
|
81
|
+
Field: Owner
|
82
|
+
OldValue: 10
|
83
|
+
NewValue: 527
|
84
|
+
Data:
|
85
|
+
Description: Taken by someone
|
86
|
+
Content: This transaction appears to have no content
|
87
|
+
Creator: someone
|
88
|
+
Created: 2008-06-03 10:39:16
|
89
|
+
Attachments:
|
90
|
+
|
91
|
+
--
|
92
|
+
|
93
|
+
# 5/5 (id/34883/total)
|
94
|
+
|
95
|
+
id: 34883
|
96
|
+
Ticket: 12345
|
97
|
+
TimeTaken: 0
|
98
|
+
Type: Comment
|
99
|
+
Field:
|
100
|
+
OldValue:
|
101
|
+
NewValue:
|
102
|
+
Data: No Subject
|
103
|
+
Description: Comments added by someone
|
104
|
+
Content: SPAM
|
105
|
+
Creator: someone
|
106
|
+
Created: 2008-06-03 10:39:49
|
107
|
+
Attachments:
|
108
|
+
|
109
|
+
--
|
110
|
+
|
111
|
+
# 5/5 (id/34885/total)
|
112
|
+
|
113
|
+
id: 34885
|
114
|
+
Ticket: 12345
|
115
|
+
TimeTaken: 0
|
116
|
+
Type: Status
|
117
|
+
Field: Status
|
118
|
+
OldValue: new
|
119
|
+
NewValue: deleted
|
120
|
+
Data:
|
121
|
+
Description: Ticket deleted by someone
|
122
|
+
Content: This transaction appears to have no content
|
123
|
+
Creator: someone
|
124
|
+
Created: 2008-06-03 10:39:50
|
125
|
+
Attachments:
|
126
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RT/3.6.6 200 Ok
|
2
|
+
|
3
|
+
# 5/5 (id/34725/total)
|
4
|
+
|
5
|
+
id: 34725
|
6
|
+
Ticket: 12345
|
7
|
+
TimeTaken: 0
|
8
|
+
Type: Create
|
9
|
+
Field:
|
10
|
+
OldValue:
|
11
|
+
NewValue:
|
12
|
+
Data:
|
13
|
+
Description: Ticket created by Dallas-stezuohc@LEESSUMMITHONDA.COM
|
14
|
+
|
15
|
+
Content: Now you can get big real fast at an affordable price
|
16
|
+
http://www.lameppe.com/
|
17
|
+
|
18
|
+
|
19
|
+
Creator: Dallas-stezuohc@LEESSUMMITHONDA.COM
|
20
|
+
Created: 2008-06-03 09:24:32
|
21
|
+
|
22
|
+
Attachments:
|
23
|
+
16377: untitled (77b)
|
24
|
+
16379: untitled (248b)
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RT/3.6.6 200 Ok
|
2
|
+
|
3
|
+
id: ticket/358171
|
4
|
+
Queue: MyQueue
|
5
|
+
Owner: some_guy
|
6
|
+
Creator: some_guy
|
7
|
+
Subject: MyQueue - some_guy - 1035328269 - DSL Modem Reset ESCALATED
|
8
|
+
Status: open
|
9
|
+
Priority: 1
|
10
|
+
InitialPriority: 1
|
11
|
+
FinalPriority: 10
|
12
|
+
Requestors: some_guy@MyQueue.net
|
13
|
+
Cc:
|
14
|
+
AdminCc:
|
15
|
+
Created: Sat Jan 16 14:40:38 2010
|
16
|
+
Starts: Not set
|
17
|
+
Started: Sat Jan 16 14:40:40 2010
|
18
|
+
Due: Mon Jan 18 20:40:38 2010
|
19
|
+
Resolved: Not set
|
20
|
+
Told: Not set
|
21
|
+
LastUpdated: Sat Jan 16 14:50:17 2010
|
22
|
+
TimeEstimated: 0
|
23
|
+
TimeWorked: 0
|
24
|
+
TimeLeft: 0
|
25
|
+
CF-BTN: 1035328269
|
26
|
+
CF-Call Back Status:
|
27
|
+
CF-Call Back Time:
|
28
|
+
CF-Contact Name: some_guy
|
29
|
+
CF-Contact Phone:
|
30
|
+
CF-CMSID:
|
31
|
+
CF-IssueCategory: DSL - Modem/Router Config
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ludo-roart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 11
|
10
|
+
version: 0.1.11
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- PJ Davis
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-15 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: mechanize
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: activesupport
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 2.0.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bones
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 25
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 5
|
65
|
+
- 1
|
66
|
+
version: 2.5.1
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
description: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.
|
70
|
+
email: pj.davis@gmail.com
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files:
|
76
|
+
- History.txt
|
77
|
+
- README.rdoc
|
78
|
+
- spec/test_data/full_history.txt
|
79
|
+
- spec/test_data/search_ticket.txt
|
80
|
+
- spec/test_data/single_history.txt
|
81
|
+
- spec/test_data/ticket.txt
|
82
|
+
files:
|
83
|
+
- History.txt
|
84
|
+
- README.rdoc
|
85
|
+
- Rakefile
|
86
|
+
- lib/roart.rb
|
87
|
+
- lib/roart/callbacks.rb
|
88
|
+
- lib/roart/connection.rb
|
89
|
+
- lib/roart/connection_adapter.rb
|
90
|
+
- lib/roart/connection_adapters/mechanize_adapter.rb
|
91
|
+
- lib/roart/core/hash.rb
|
92
|
+
- lib/roart/core/content_formatter.rb
|
93
|
+
- lib/roart/errors.rb
|
94
|
+
- lib/roart/history.rb
|
95
|
+
- lib/roart/roart.rb
|
96
|
+
- lib/roart/ticket.rb
|
97
|
+
- lib/roart/ticket_page.rb
|
98
|
+
- lib/roart/validations.rb
|
99
|
+
- roart.gemspec
|
100
|
+
- spec/roart/callbacks_spec.rb
|
101
|
+
- spec/roart/connection_adapter_spec.rb
|
102
|
+
- spec/roart/connection_spec.rb
|
103
|
+
- spec/roart/core/hash_spec.rb
|
104
|
+
- spec/roart/history_spec.rb
|
105
|
+
- spec/roart/roart_spec.rb
|
106
|
+
- spec/roart/ticket_page_spec.rb
|
107
|
+
- spec/roart/ticket_spec.rb
|
108
|
+
- spec/roart/validation_spec.rb
|
109
|
+
- spec/roart_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/test_data/full_history.txt
|
112
|
+
- spec/test_data/search_ticket.txt
|
113
|
+
- spec/test_data/single_history.txt
|
114
|
+
- spec/test_data/ticket.txt
|
115
|
+
has_rdoc: true
|
116
|
+
homepage: http://github.com/pjdavis/roart
|
117
|
+
licenses: []
|
118
|
+
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options:
|
121
|
+
- --main
|
122
|
+
- README.rdoc
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
version: "0"
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project: roart
|
146
|
+
rubygems_version: 1.5.2
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord
|
150
|
+
test_files: []
|
151
|
+
|