axtro-roart 0.1.8

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.
@@ -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
@@ -0,0 +1,8 @@
1
+
2
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
3
+
4
+ describe Roart do
5
+
6
+ end
7
+
8
+ # EOF
@@ -0,0 +1,27 @@
1
+
2
+ dir = File.dirname(__FILE__)
3
+
4
+ $:.unshift(File.join(dir, '/../lib/'))
5
+ require dir + '/../lib/roart'
6
+
7
+ def dbtime(time)
8
+ time.strftime("%Y-%m-%d %H:%M:%S")
9
+ end
10
+
11
+ def to_content_format(data)
12
+ fields = data.map { |key,value| "#{key.to_s.camelize}: #{value}" unless value.nil? }
13
+ fields.compact.sort.join("\n")
14
+ end
15
+
16
+ Spec::Runner.configure do |config|
17
+ # == Mock Framework
18
+ #
19
+ # RSpec uses it's own mocking framework by default. If you prefer to
20
+ # use mocha, flexmock or RR, uncomment the appropriate line:
21
+ #
22
+ # config.mock_with :mocha
23
+ # config.mock_with :flexmock
24
+ # config.mock_with :rr
25
+ end
26
+
27
+ # 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,13 @@
1
+ RT/3.6.6 200 Ok
2
+
3
+ id: ticket/3033
4
+ Queue: Canada Express
5
+ Subject: Canada Express
6
+ Status: new
7
+
8
+ --
9
+
10
+ id: ticket/2354
11
+ Queue: Canada Express
12
+ Subject: Canada Express
13
+ Status: open
@@ -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,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: axtro-roart
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 8
10
+ version: 0.1.8
11
+ platform: ruby
12
+ authors:
13
+ - PJ Davis
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-05-23 00:00:00 +02: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: bones
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 25
46
+ segments:
47
+ - 2
48
+ - 5
49
+ - 1
50
+ version: 2.5.1
51
+ type: :development
52
+ version_requirements: *id002
53
+ description: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.
54
+ email: pj.davis@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - History.txt
61
+ - README.rdoc
62
+ - spec/test_data/full_history.txt
63
+ - spec/test_data/search_ticket.txt
64
+ - spec/test_data/single_history.txt
65
+ - spec/test_data/ticket.txt
66
+ files:
67
+ - History.txt
68
+ - README.rdoc
69
+ - Rakefile
70
+ - lib/roart.rb
71
+ - lib/roart/callbacks.rb
72
+ - lib/roart/connection.rb
73
+ - lib/roart/connection_adapter.rb
74
+ - lib/roart/connection_adapters/mechanize_adapter.rb
75
+ - lib/roart/core/array.rb
76
+ - lib/roart/core/hash.rb
77
+ - lib/roart/core/hash/indifferent_access.rb
78
+ - lib/roart/core/string.rb
79
+ - lib/roart/errors.rb
80
+ - lib/roart/history.rb
81
+ - lib/roart/roart.rb
82
+ - lib/roart/ticket.rb
83
+ - lib/roart/ticket_page.rb
84
+ - lib/roart/validations.rb
85
+ - roart.gemspec
86
+ - spec/roart/callbacks_spec.rb
87
+ - spec/roart/connection_adapter_spec.rb
88
+ - spec/roart/connection_spec.rb
89
+ - spec/roart/core/array_spec.rb
90
+ - spec/roart/core/hash_spec.rb
91
+ - spec/roart/core/string_spec.rb
92
+ - spec/roart/history_spec.rb
93
+ - spec/roart/roart_spec.rb
94
+ - spec/roart/ticket_page_spec.rb
95
+ - spec/roart/ticket_spec.rb
96
+ - spec/roart/validation_spec.rb
97
+ - spec/roart_spec.rb
98
+ - spec/spec_helper.rb
99
+ - spec/test_data/full_history.txt
100
+ - spec/test_data/search_ticket.txt
101
+ - spec/test_data/single_history.txt
102
+ - spec/test_data/ticket.txt
103
+ has_rdoc: true
104
+ homepage: http://github.com/hennk/roart
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options:
109
+ - --main
110
+ - README.rdoc
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ requirements: []
132
+
133
+ rubyforge_project: roart
134
+ rubygems_version: 1.3.7
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord
138
+ test_files: []
139
+