zendesk2 0.0.23 → 0.1.0

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/.travis.yml CHANGED
@@ -1,7 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - "1.9.3"
4
+ - "rbx-19mode"
5
+ - "jruby-19mode"
4
6
  bundler_args: "--without development"
5
7
  before_install:
6
- - gem install bundler --pre
8
+ - "gem install bundler -v 1.2.3"
7
9
  script: "bundle exec rake --trace"
data/Gemfile CHANGED
@@ -4,9 +4,12 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rake'
7
- gem 'cistern'
8
7
 
9
8
  group :test do
10
9
  gem 'guard-rspec'
10
+ gem 'guard-bundler'
11
11
  gem 'rspec'
12
+ gem 'rb-fsevent'
13
+ gem 'awesome_print'
14
+ gem 'pry-nav'
12
15
  end
data/Guardfile CHANGED
@@ -1,9 +1,10 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
1
+ guard 'bundler' do
2
+ watch('Gemfile')
3
+ watch(/^.+\.gemspec/)
4
+ end
3
5
 
4
- guard 'rspec', :version => 2 do
6
+ guard 'rspec' do
5
7
  watch(%r{^spec/.+_spec\.rb$})
6
8
  watch(%r{^lib/(.+)\.rb$}) { "spec" }
7
9
  watch('spec/spec_helper.rb') { "spec" }
8
10
  end
9
-
data/README.md CHANGED
@@ -164,6 +164,23 @@ Zendesk2::Client::Ticket.new(id: 1).save # performs an update
164
164
 
165
165
  Attributes can be enumerated by the `attributes` method.
166
166
 
167
+ ## Testing
168
+ ### Running
169
+
170
+ $ bundle exec rspec
171
+
172
+ ### Testing Live
173
+
174
+ Run against a real Zendesk installation by setting ```MOCK_ZENDESK=false```
175
+
176
+ $ MOCK_ZENDESK=false bundle exec rspec
177
+
178
+ Credentials are sourced from your ```~/.zendesk2``` file
179
+
180
+ Raw responses and requests can be echoed to STDOUT by adding ```VERBOSE=true```
181
+
182
+ $ VERBOSE=true bundle exec rspec
183
+
167
184
  ## Releasing
168
185
 
169
186
  $ gem install gem-release
data/TODO.md ADDED
@@ -0,0 +1,2 @@
1
+ # yarddoc
2
+ * change attribute enumerations to use yarddoc format
@@ -0,0 +1,33 @@
1
+ class Zendesk2::Client::AuditEvent < Cistern::Model
2
+ extend Zendesk2::Attributes
3
+ extend Forwardable
4
+
5
+ # @return [Integer] Automatically assigned when creating events
6
+ identity :id, type: :integer
7
+ # @return [String] Has the value Comment
8
+ attribute :type, type: :string
9
+ # @return [String] The actual comment made by the author
10
+ attribute :body, type: :string
11
+ # @return [String] The actual comment made by the author formatted to HTML
12
+ attribute :html_body, type: :string
13
+ # @return [Boolean] If this is a public comment or an internal agents only note
14
+ attribute :public, type: :boolean
15
+ # @return [Boolean] If this comment is trusted or marked as being potentially fraudulent
16
+ attribute :trusted, type: :boolean
17
+ # @return [Integer] The id of the author of this comment
18
+ attribute :author_id, type: :integer
19
+ # @return [Array] The attachments on this comment as Attachment objects
20
+ attribute :attachments, type: :array
21
+
22
+ # @return [Zendesk2::Client::TicketAudit] audit that includes this event
23
+ attr_accessor :ticket_audit
24
+
25
+ def_delegators :ticket_audit, :created_at
26
+
27
+ # @return [Zendesk2::Client::User] event author
28
+ def author
29
+ requires :author_id
30
+
31
+ self.connection.users.get(self.author_id)
32
+ end
33
+ end
@@ -3,44 +3,76 @@ class Zendesk2::Client::Ticket < Zendesk2::Model
3
3
 
4
4
  PARAMS = %w[external_id via requester_id submitter_id assignee_id organization_id subject description fields recipient status collaborator_ids]
5
5
 
6
- identity :id, type: :id
7
- attribute :external_id
8
- attribute :via
9
- attribute :created_at, type: :time
10
- attribute :updated_at, type: :time
11
- attribute :type
12
- attribute :subject
13
- attribute :description
14
- attribute :priority
15
- attribute :status
16
- attribute :recipient
17
- attribute :requester_id, type: :integer
18
- attribute :submitter_id, type: :integer
19
- attribute :assignee_id, type: :integer
20
- attribute :organization_id, type: :integer
21
- attribute :group_id, type: :integer
6
+ # @return [Integer] Automatically assigned when creating tickets
7
+ identity :id, type: :integer
8
+ # @return [Integer] What agent is currently assigned to the ticket
9
+ attribute :assignee_id, type: :integer
10
+ # @return [Array] Who are currently CC'ed on the ticket
22
11
  attribute :collaborator_ids, type: :array
23
- attribute :forum_topic_id, type: :integer
24
- attribute :problem_id, type: :integer
25
- attribute :has_incidents, type: :boolean
26
- attribute :due_at, type: :time
27
- attribute :tags, type: :array
28
- attribute :fields, type: :array
12
+ # @return [Time] When this record was created
13
+ attribute :created_at, type: :time
14
+ # @return [Array] The custom fields of the ticket
15
+ attribute :custom_fields, type: :array
16
+ # @return [String] The first comment on the ticket
17
+ attribute :description, type: :string
18
+ # @return [Time] If this is a ticket of type "task" it has a due date. Due date format uses ISO 8601 format.
19
+ attribute :due_at, type: :time
20
+ # @return [String] A unique external id, you can use this to link Zendesk tickets to local records
21
+ attribute :external_id, type: :string
22
+ # @return [Integer] The topic this ticket originated from, if any
23
+ attribute :forum_topic_id, type: :integer
24
+ # @return [Integer] The group this ticket is assigned to
25
+ attribute :group_id, type: :integer
26
+ # @return [Boolean] Is true of this ticket has been marked as a problem, false otherwise
27
+ attribute :has_incidents, type: :boolean
28
+ # @return [Integer] The organization of the requester
29
+ attribute :organization_id, type: :integer
30
+ # @return [String] Priority, defines the urgency with which the ticket should be addressed: "urgent", "high", "normal", "low"
31
+ attribute :priority, type: :string
32
+ # @return [Integer] The problem this incident is linked to, if any
33
+ attribute :problem_id, type: :integer
34
+ # @return [String] The original recipient e-mail address of the ticket
35
+ attribute :recipient, type: :string
36
+ # @return [Integer] The user who requested this ticket
37
+ attribute :requester_id, type: :integer
38
+ # @return [Hash] The satisfaction rating of the ticket, if it exists
39
+ attribute :satisfaction_rating
40
+ # @return [Array] The ids of the sharing agreements used for this ticket
41
+ attribute :sharing_agreement_ids, type: :array
42
+ # @return [String] The state of the ticket, "new", "open", "pending", "hold", "solved", "closed"
43
+ attribute :status, type: :string
44
+ # @return [String] The value of the subject field for this ticket
45
+ attribute :subject, type: :string
46
+ # @return [Integer] The user who submitted the ticket; this is the currently authenticated API user
47
+ attribute :submitter_id, type: :integer
48
+ # @return [Array] The array of tags applied to this ticket
49
+ attribute :tags, type: :array
50
+ # @return [String] The type of this ticket, i.e. "problem", "incident", "question" or "task"
51
+ attribute :type, type: :string
52
+ # @return [Time] When this record last got updated
53
+ attribute :updated_at, type: :time
54
+ # @return [String] The API url of this ticket
55
+ attribute :url, type: :string
56
+ # @return [Hash] This object explains how the ticket was created
57
+ attribute :via
29
58
 
59
+ # @return [Zendesk2::Client::Organization] organization assigned to ticket
30
60
  assoc_reader :organization
61
+ # @return [Zendesk2::Client::User] user that requested the ticket
31
62
  assoc_accessor :requester, collection: :users
63
+ # @return [Zendesk2::Client::User] user that submitted the ticket
32
64
  assoc_reader :submitter, collection: :users
33
65
 
34
66
  def save!
35
- if new_record?
36
- requires :subject, :description
37
- data = connection.create_ticket(params).body["ticket"]
38
- merge_attributes(data)
39
- else
40
- requires :identity
41
- data = connection.update_ticket(params.merge("id" => self.identity)).body["ticket"]
42
- merge_attributes(data)
43
- end
67
+ data = if new_record?
68
+ requires :subject, :description
69
+ connection.create_ticket(params).body["ticket"]
70
+ else
71
+ requires :identity
72
+ connection.update_ticket(params.merge("id" => self.identity)).body["ticket"]
73
+ end
74
+
75
+ merge_attributes(data)
44
76
  end
45
77
 
46
78
  def destroy
@@ -49,31 +81,40 @@ class Zendesk2::Client::Ticket < Zendesk2::Model
49
81
  connection.destroy_ticket("id" => self.identity)
50
82
  end
51
83
 
84
+ # Adds a ticket comment
85
+ #
86
+ # @param [String] text comment body
87
+ # @param [Hash] options comment options
88
+ # @option options [Array] :attachments Attachment to upload with comment
89
+ # @option options [Boolean] :public (true)
90
+ def comment(text, options={})
91
+ requires :identity
92
+
93
+ options[:public] = true if options[:public].nil?
94
+ comment = Zendesk2.stringify_keys(options).merge("body" => text)
95
+
96
+ connection.update_ticket("id" => self.identity, "comment" => comment)
97
+ end
98
+
99
+ # @return [Array<Zendesk2::Client::User>] All users CCD on this ticket
52
100
  def collaborators
53
101
  self.collaborator_ids.map{|cid| self.connection.users.get(cid)}
54
102
  end
55
103
 
104
+ # Update list of users to be CCD on this ticket
105
+ # @param [Array<Zendesk2::Client::User>] collaborators list of users
56
106
  def collaborators=(collaborators)
57
- self.collaborator_ids= collaborators.map(&:identity)
58
- end
59
-
60
- def destroyed?
61
- !self.reload
107
+ self.collaborator_ids = collaborators.map(&:identity)
62
108
  end
63
109
 
110
+ # @return [Zendesk2::Client::TicketAudits] all audits for this ticket
64
111
  def audits
65
- connection.get_audits('ticket_id' => id).body['audits']
112
+ self.connection.ticket_audits(:ticket_id => self.identity).all
66
113
  end
67
114
 
115
+ # @return [Array<Zendesk2::Client::AuditEvent>] audit events of type 'Comment'
68
116
  def comments
69
- comments = []
70
- audits.each do |audit|
71
- events = audit['events'].select { |e| e['type'] == 'Comment' }
72
- events.each do |event|
73
- comments << event.merge({'created_at' => audit['created_at'], 'author_id' => audit['author_id']})
74
- end
75
- end
76
- comments
117
+ audits.map{|audit| audit.events.select{|e| e.type == "Comment"}}.flatten
77
118
  end
78
119
 
79
120
  private
@@ -81,5 +122,4 @@ class Zendesk2::Client::Ticket < Zendesk2::Model
81
122
  def params
82
123
  Cistern::Hash.slice(Zendesk2.stringify_keys(attributes), *PARAMS)
83
124
  end
84
-
85
125
  end
@@ -0,0 +1,28 @@
1
+ class Zendesk2::Client::TicketAudit < Cistern::Model
2
+ extend Zendesk2::Attributes
3
+
4
+ # @return [Integer] Automatically assigned when creating audits
5
+ identity :id, type: :integer
6
+ # @return [Integer] The ID of the associated ticket
7
+ attribute :ticket_id, type: :integer
8
+ # @return [Hash] Metadata for the audit, custom and system data
9
+ attribute :metadata
10
+ # @return [Hash] This object explains how this audit was created
11
+ attribute :via
12
+ # @return [Time] The time the audit was created
13
+ attribute :created_at, type: :time
14
+ # @return [Integer] The user who created the audit
15
+ attribute :author_id, type: :integer
16
+ # @return [Array] An array of the events that happened in this audit
17
+ attribute :events, type: :array
18
+
19
+ def ticket
20
+ requires :ticket_id
21
+
22
+ self.connection.tickets.get(self.ticket_id)
23
+ end
24
+
25
+ def events
26
+ (self.attributes[:events] || []).map{|ae| self.connection.audit_event(ae.merge(ticket_audit: self))}
27
+ end
28
+ end
@@ -0,0 +1,36 @@
1
+ class Zendesk2::Client::TicketAudits < Zendesk2::Collection
2
+ include Zendesk2::PagedCollection
3
+
4
+ model Zendesk2::Client::TicketAudit
5
+
6
+ attribute :ticket_id, type: :integer
7
+
8
+ self.collection_method = :get_ticket_audits
9
+ self.collection_root = "audits"
10
+ self.model_method = :get_ticket_audit
11
+ self.model_root = "audit"
12
+
13
+ def ticket
14
+ self.connection.tickets.get(self.ticket_id)
15
+ end
16
+
17
+ def all(params={})
18
+ requires :ticket_id
19
+
20
+ body = connection.send(collection_method, {"ticket_id" => self.ticket_id}.merge(params)).body
21
+
22
+ collection = self.clone.load(body[collection_root])
23
+ collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
24
+ collection
25
+ end
26
+
27
+ def get(id)
28
+ requires :ticket_id
29
+
30
+ if data = self.connection.send(model_method, {"ticket_id" => self.ticket_id, "id" => id}).body[self.model_root]
31
+ new(data)
32
+ end
33
+ rescue Zendesk2::Error
34
+ nil
35
+ end
36
+ end
@@ -21,12 +21,14 @@ class Zendesk2::Client
21
21
  "collaborator_ids" => [],
22
22
  }.merge(params)
23
23
 
24
- record["requester_id"] ||= @current_user_id
25
- record["submitter_id"]= @current_user_id
24
+ record["requester_id"] ||= current_user_id
25
+ record["submitter_id"] = current_user_id
26
+
27
+ # FIXME: throw error if user doesn't exist?
26
28
  requester = self.data[:users][record["requester_id"]]
27
- # TODO: throw error if user doesn't exist?
28
- record["organization_id"]= requester["organization_id"]
29
- self.data[:tickets][identity]= record
29
+ record["organization_id"] = requester["organization_id"]
30
+
31
+ self.data[:tickets][identity] = record
30
32
 
31
33
  response(
32
34
  :method => :post,
@@ -16,7 +16,7 @@ class Zendesk2::Client
16
16
  def get_ccd_tickets(params={})
17
17
  id = params["id"]
18
18
 
19
- page(params, :tickets, "/ccds/#{id}/tickets.json", "tickets", filter: lambda{|c| c.select{|u| u["collaborator_ids"].include?(id)}})
19
+ page(params, :tickets, "/users/#{id}/tickets/ccd.json", "tickets", filter: lambda{|c| c.select{|u| u["collaborator_ids"].include?(id)}})
20
20
  end
21
21
  end # Mock
22
22
  end
@@ -0,0 +1,37 @@
1
+ class Zendesk2::Client
2
+ class Real
3
+ def get_ticket_audit(params={})
4
+ id = params["id"]
5
+ ticket_id = params["ticket_id"]
6
+
7
+ request(
8
+ :method => :get,
9
+ :path => "/tickets/#{ticket_id}/audits/#{id}.json"
10
+ )
11
+ end
12
+ end # Real
13
+
14
+ class Mock
15
+ def get_ticket_audit(params={})
16
+ id = params["id"]
17
+ ticket_id = params["ticket_id"]
18
+
19
+ path = "/ticket_audits/#{id}.json"
20
+
21
+ if body = self.data[:ticket_audits][id]
22
+ response(
23
+ :path => path,
24
+ :body => {
25
+ "ticket_audit" => body
26
+ },
27
+ )
28
+ else
29
+ response(
30
+ :path => path,
31
+ :status => 404,
32
+ :body => {"error" => "RecordNotFound", "description" => "Not found"},
33
+ )
34
+ end
35
+ end
36
+ end # Mock
37
+ end
@@ -0,0 +1,22 @@
1
+ class Zendesk2::Client
2
+ class Real
3
+ def get_ticket_audits(params={})
4
+ ticket_id = params["ticket_id"]
5
+ page_params = Zendesk2.paging_parameters(params)
6
+
7
+ request(
8
+ :params => page_params,
9
+ :method => :get,
10
+ :path => "/tickets/#{ticket_id}/audits.json",
11
+ )
12
+ end
13
+ end # Real
14
+
15
+ class Mock
16
+ def get_ticket_audits(params={})
17
+ ticket_id = params["ticket_id"]
18
+
19
+ page(params, :ticket_audits, "/tickets/#{ticket_id}/audits.json", "audits", filter: lambda{|c| c.select{|a| a["ticket_id"] == ticket_id}})
20
+ end
21
+ end # Mock
22
+ end
@@ -14,12 +14,50 @@ class Zendesk2::Client
14
14
  end
15
15
  class Mock
16
16
  def update_ticket(params={})
17
- id = params.delete("id")
18
- body = self.data[:tickets][id].merge!(params)
17
+ ticket_id = params.delete("id")
18
+ body = self.data[:tickets][ticket_id].merge!(params)
19
+
20
+ if comment = params["comment"]
21
+ audit_id = self.class.new_id
22
+ self.data[:ticket_audits][audit_id] = {
23
+ "id" => audit_id,
24
+ "ticket_id" => ticket_id,
25
+ "created_at" => Time.now,
26
+ "author_id" => current_user_id,
27
+ "via" => {
28
+ "channel" => "api",
29
+ "source" => {
30
+ "form" => {},
31
+ "to" => {},
32
+ "rel" => nil,
33
+ }
34
+ },
35
+ "metadata" => {
36
+ "system" => {
37
+ "client" => Zendesk2::Client::USER_AGENT,
38
+ "ip_address" => "127.0.0.1",
39
+ "location" => "Oakland, CA, United States",
40
+ "latitude" => 37.83449999999999,
41
+ "longitude" => -122.2647,
42
+ },
43
+ "custom" => {},
44
+ },
45
+ "events" => [
46
+ "id" => self.class.new_id,
47
+ "type" => "Comment",
48
+ "author_id" => current_user_id,
49
+ "body" => comment["body"],
50
+ "html_body" => "<p>#{comment["body"]}</p>",
51
+ "public" => comment["public"].nil? ? true : comment["public"],
52
+ "trusted" => comment["trusted"].nil? ? true : comment["trusted"],
53
+ "attachments" => comment["attachments"] || [],
54
+ ]
55
+ }
56
+ end
19
57
 
20
58
  response(
21
59
  :method => :put,
22
- :path => "/tickets/#{id}.json",
60
+ :path => "/tickets/#{ticket_id}.json",
23
61
  :body => {
24
62
  "ticket" => body
25
63
  },
@@ -1,64 +1,70 @@
1
1
  class Zendesk2::Client < Cistern::Service
2
+ USER_AGENT = "Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}) Zendesk2/#{Zendesk2::VERSION} Faraday/#{Faraday::VERSION}".freeze
2
3
 
3
4
  model_path "zendesk2/client/models"
4
5
  request_path "zendesk2/client/requests"
5
6
 
6
- model :category
7
7
  collection :categories
8
- model :forum
9
8
  collection :forums
10
- model :topic
11
- collection :topics
12
- model :topic_comment
9
+ collection :organizations
10
+ collection :ticket_audits
11
+ collection :tickets
13
12
  collection :topic_comments
13
+ collection :topics
14
+ collection :users
15
+ model :audit_event
16
+ model :category
17
+ model :forum
14
18
  model :organization
15
- collection :organizations
16
19
  model :ticket
17
- collection :tickets
20
+ model :ticket_audit
21
+ model :topic
22
+ model :topic_comment
18
23
  model :user
19
- collection :users
20
24
 
21
25
  request :create_category
22
26
  request :create_forum
23
- request :create_topic
24
- request :create_topic_comment
25
27
  request :create_organization
26
28
  request :create_ticket
29
+ request :create_topic
30
+ request :create_topic_comment
27
31
  request :create_user
28
32
  request :destroy_category
29
33
  request :destroy_forum
30
- request :destroy_topic
31
- request :destroy_topic_comment
32
34
  request :destroy_organization
33
35
  request :destroy_ticket
36
+ request :destroy_topic
37
+ request :destroy_topic_comment
34
38
  request :destroy_user
35
39
  request :get_audits
36
- request :get_current_user
40
+ request :get_categories
37
41
  request :get_category
42
+ request :get_ccd_tickets
43
+ request :get_current_user
38
44
  request :get_forum
39
- request :get_topic
40
- request :get_topic_comment
45
+ request :get_forums
41
46
  request :get_organization
42
47
  request :get_organization_tickets
43
48
  request :get_organization_users
44
- request :get_ticket
45
- request :get_user
46
- request :get_categories
47
- request :get_forums
48
- request :get_topics
49
- request :get_topic_comments
50
49
  request :get_organizations
51
50
  request :get_requested_tickets
52
- request :get_ccd_tickets
51
+ request :get_ticket
52
+ request :get_ticket_audit
53
+ request :get_ticket_audits
53
54
  request :get_tickets
55
+ request :get_topic
56
+ request :get_topic_comment
57
+ request :get_topic_comments
58
+ request :get_topics
59
+ request :get_user
54
60
  request :get_users
55
61
  request :search
56
62
  request :update_category
57
63
  request :update_forum
58
- request :update_topic
59
- request :update_topic_comment
60
64
  request :update_organization
61
65
  request :update_ticket
66
+ request :update_topic
67
+ request :update_topic_comment
62
68
  request :update_user
63
69
 
64
70
  recognizes :url, :subdomain, :host, :port, :path, :scheme, :logger, :adapter, :username, :password, :token
@@ -110,13 +116,13 @@ class Zendesk2::Client < Cistern::Service
110
116
  url = File.join(@url, "/api/v2", options[:path])
111
117
  params = options[:params] || {}
112
118
  body = options[:body]
113
- headers = options[:headers] || {}
119
+ headers = {"User-Agent" => USER_AGENT}.merge(options[:headers] || {})
114
120
 
115
121
  @connection.send(method) do |req|
116
122
  req.url url
117
123
  req.headers.merge!(headers)
118
124
  req.params.merge!(params)
119
- req.body= body
125
+ req.body = body
120
126
  end
121
127
  rescue Faraday::Error::ClientError => e
122
128
  raise Zendesk2::Error.new(e)
@@ -125,7 +131,7 @@ class Zendesk2::Client < Cistern::Service
125
131
 
126
132
  class Mock
127
133
 
128
- attr_reader :username, :url, :token
134
+ attr_reader :username, :url, :token, :current_user_id
129
135
 
130
136
  def self.data
131
137
  @data ||= {
@@ -136,6 +142,7 @@ class Zendesk2::Client < Cistern::Service
136
142
  :topics => {},
137
143
  :categories => {},
138
144
  :topic_comments => {},
145
+ :ticket_audits => {},
139
146
  }
140
147
  end
141
148
 
@@ -1,3 +1,3 @@
1
1
  module Zendesk2
2
- VERSION = "0.0.23"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/zendesk2.rb CHANGED
@@ -46,6 +46,6 @@ module Zendesk2
46
46
  end
47
47
 
48
48
  def self.blank?(string)
49
- !string || string == ""
49
+ string.nil? || string == ""
50
50
  end
51
51
  end
data/spec/spec_helper.rb CHANGED
@@ -4,14 +4,17 @@ Bundler.require(:test)
4
4
 
5
5
  require File.expand_path("../../lib/zendesk2", __FILE__)
6
6
 
7
- Dir["./spec/{support,shared}/**/*.rb"].each {|f| require f}
7
+ Dir[File.expand_path("../{support,shared}/**/*.rb", __FILE__)].each {|f| require f}
8
8
 
9
9
  if ENV["MOCK_ZENDESK"] == 'true'
10
10
  Zendesk2::Client.mock!
11
11
  end
12
12
 
13
+ Cistern.formatter = Cistern::Formatter::AwesomePrint
14
+
13
15
  RSpec.configure do |config|
14
16
  config.before(:all) do
15
17
  Zendesk2::Client.reset! if Zendesk2::Client.mocking?
16
18
  end
19
+ config.filter_run_excluding(:mock_only => true) unless Zendesk2::Client.mocking?
17
20
  end
data/spec/tickets_spec.rb CHANGED
@@ -20,19 +20,26 @@ describe "tickets" do
20
20
 
21
21
  describe "comments" do
22
22
  let(:ticket) { client.tickets.create(subject: Zendesk2.uuid, description: Zendesk2.uuid) }
23
- before(:each) { client.data[:ticket_audits] = {} }
24
23
 
25
24
  it "lists audits" do
26
- ticket.audits.size.should == 0
27
- client.data[:ticket_audits][1] = {'ticket_id' => ticket.id}
28
- ticket.audits.size.should == 1
25
+ body = Zendesk2.uuid
26
+ ticket.comment(body)
27
+
28
+ audit = ticket.audits.last
29
+ audit.ticket.should == ticket
30
+
31
+ events = audit.events
32
+ events.size.should == 1
33
+
34
+ event = events.first
35
+ event.body.should == body
29
36
  end
30
37
 
31
38
  it "lists comments" do
32
- ticket.comments.size.should == 0
33
- client.data[:ticket_audits][2] = {'ticket_id' => ticket.id, 'events' => [{'type' => 'Comment'}]}
34
- client.data[:ticket_audits][3] = {'ticket_id' => ticket.id, 'events' => [{'type' => 'Change'}]}
35
- ticket.comments.size.should == 1
39
+ body = Zendesk2.uuid
40
+ ticket.comment(body)
41
+
42
+ (comment = ticket.comments.find{|c| c.body == body}).should_not be_nil
36
43
  end
37
44
  end
38
45
  end
data/spec/users_spec.rb CHANGED
@@ -15,7 +15,7 @@ describe "users" do
15
15
 
16
16
  describe do
17
17
  before(:each) do
18
- @user = client.users.create(email: "zendesk2+#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid)
18
+ @user = client.users.create(email: "zendesk2+#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid)
19
19
  end
20
20
 
21
21
  let(:user) { @user }
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: zendesk2
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.23
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Josh Lane
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-18 00:00:00.000000000 Z
12
+ date: 2012-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  prerelease: false
@@ -89,9 +89,11 @@ files:
89
89
  - LICENSE
90
90
  - README.md
91
91
  - Rakefile
92
+ - TODO.md
92
93
  - lib/zendesk2.rb
93
94
  - lib/zendesk2/attributes.rb
94
95
  - lib/zendesk2/client.rb
96
+ - lib/zendesk2/client/models/audit_event.rb
95
97
  - lib/zendesk2/client/models/categories.rb
96
98
  - lib/zendesk2/client/models/category.rb
97
99
  - lib/zendesk2/client/models/forum.rb
@@ -99,6 +101,8 @@ files:
99
101
  - lib/zendesk2/client/models/organization.rb
100
102
  - lib/zendesk2/client/models/organizations.rb
101
103
  - lib/zendesk2/client/models/ticket.rb
104
+ - lib/zendesk2/client/models/ticket_audit.rb
105
+ - lib/zendesk2/client/models/ticket_audits.rb
102
106
  - lib/zendesk2/client/models/tickets.rb
103
107
  - lib/zendesk2/client/models/topic.rb
104
108
  - lib/zendesk2/client/models/topic_comment.rb
@@ -133,6 +137,8 @@ files:
133
137
  - lib/zendesk2/client/requests/get_organizations.rb
134
138
  - lib/zendesk2/client/requests/get_requested_tickets.rb
135
139
  - lib/zendesk2/client/requests/get_ticket.rb
140
+ - lib/zendesk2/client/requests/get_ticket_audit.rb
141
+ - lib/zendesk2/client/requests/get_ticket_audits.rb
136
142
  - lib/zendesk2/client/requests/get_tickets.rb
137
143
  - lib/zendesk2/client/requests/get_topic.rb
138
144
  - lib/zendesk2/client/requests/get_topic_comment.rb
@@ -201,3 +207,4 @@ test_files:
201
207
  - spec/topic_comments_spec.rb
202
208
  - spec/topics_spec.rb
203
209
  - spec/users_spec.rb
210
+ has_rdoc: