Class: ZendeskRails::Testing::Ticket
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Resource
all, clear!, #method_missing
Constructor Details
#initialize(attributes) ⇒ Ticket
Returns a new instance of Ticket.
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/zendesk_rails/testing.rb', line 39
def initialize(attributes)
attributes.reverse_merge!(
created_at: Time.now,
updated_at: Time.now,
priority: 'low',
status: 'new',
comments: []
)
super(attributes)
end
|
Class Method Details
.create(client_or_opts = {}, opts = nil) ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/zendesk_rails/testing.rb', line 78
def create(client_or_opts = {}, opts = nil)
opts ||= client_or_opts
id = (all.map(&:id).max || 0) + 1
opts.merge!(id: id, description: opts[:comment][:value])
ticket = new opts.slice(:subject, :requester, :description, :id)
@all.unshift ticket
ticket
end
|
.find(opts = {}) ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/zendesk_rails/testing.rb', line 87
def find(opts = {})
all.find do |ticket|
opts.map do |key, value|
ticket.send(key) == value || ticket.send(key).to_s == value
end.all?
end
end
|
Instance Method Details
58
59
60
61
62
63
|
# File 'lib/zendesk_rails/testing.rb', line 58
def
@attributes.slice(:created_at, :updated_at).merge(
html_body: description,
author: { name: requester[:name] }
)
end
|
70
71
72
73
74
75
|
# File 'lib/zendesk_rails/testing.rb', line 70
def (opts)
@attributes[:comments].unshift(
html_body: opts[:body],
author: requester
)
end
|
65
66
67
68
|
# File 'lib/zendesk_rails/testing.rb', line 65
def (_opts = {})
list = (@attributes[:comments] + []).map { |c| Comment.new(c) }
list.sort { |a, b| b.created_at <=> a.created_at }
end
|
#requester_id ⇒ Object
54
55
56
|
# File 'lib/zendesk_rails/testing.rb', line 54
def requester_id
@requester_id ||= rand(1..1000)
end
|
#save ⇒ Object
50
51
52
|
# File 'lib/zendesk_rails/testing.rb', line 50
def save
true
end
|