zendesk2 0.5.1 → 0.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb29d3d9736c994d3db750ce265af4ff03808d2f
4
- data.tar.gz: 36977a54b393dac6cb297fac0d022fafe8bed24d
3
+ metadata.gz: 34ebab53477c20ee6c21506a5997b9c3ee42f3bf
4
+ data.tar.gz: a8ecb162208217ad57b67e1264105228cc48d210
5
5
  SHA512:
6
- metadata.gz: a1245cffe7169fec4e0d68fabf29984e413ce89205ea63e1e7a8b503f96a5ecc304a151c6b1dd39ec80f464dcbb30c4379a69b76fa6d6d8da41f8679cffcb550
7
- data.tar.gz: a7ccddf702e19386e0475322fe2b55893e9d9486696ddcf3f4c3419d0fa6535d8dba8b9812071226d39c59f131c39b7f64d9882b35474eb0e5d6ae5ed21aa04e
6
+ metadata.gz: 9b4afc752900f25a9fc7de4d150882b959cc291ec6ff4035ea075632082fe2108d5a8555177eb6eaa4e55e7036b16cabf64a20be2ba812e8098a58ce2a9183f1
7
+ data.tar.gz: 56993610a6ce3779a6f5fd7e3eca9f5621621021db9a7eb49a4339a95b989fb95d62ca5fd6400beb6b0f92c305117ee301f3dd3c54a6b0d6b8b628421f337104
data/Gemfile CHANGED
@@ -14,6 +14,6 @@ end
14
14
  group :test do
15
15
  gem 'awesome_print'
16
16
  gem 'guard-bundler', require: false
17
- gem 'guard-rspec', require: false
18
- gem 'rspec'
17
+ gem 'guard-rspec', '~> 4.2', require: false
18
+ gem 'rspec', '~> 2.99'
19
19
  end
@@ -72,6 +72,7 @@ class Zendesk2::Client::Ticket < Zendesk2::Model
72
72
  connection.create_ticket(params.merge("requester" => with_requester)).body["ticket"]
73
73
  else
74
74
  requires :identity
75
+
75
76
  connection.update_ticket(params.merge("id" => self.identity)).body["ticket"]
76
77
  end
77
78
 
@@ -11,8 +11,14 @@ class Zendesk2::Client
11
11
 
12
12
  class Mock
13
13
  def create_ticket(params={})
14
+ params = Cistern::Hash.stringify_keys(params)
15
+
14
16
  identity = self.class.new_id
15
17
 
18
+ if params["description"].nil? || params["description"] == ""
19
+ error!(:invalid, :details => {"base" => [{"description" => "Description: cannot be blank"}]})
20
+ end
21
+
16
22
  if requester = params.delete('requester')
17
23
  if !requester['name'] || requester['name'].size < 1
18
24
  response(
@@ -40,10 +46,17 @@ class Zendesk2::Client
40
46
  params['requester_id'] = user_id
41
47
  end
42
48
 
43
- custom_fields = (params.delete("custom_fields") || [])
49
+ requested_custom_fields = (params.delete("custom_fields") || [])
50
+
51
+ custom_fields = requested_custom_fields.map do |cf|
52
+ field_id = cf["id"].to_i
53
+ if self.data[:ticket_fields][field_id]
54
+ {"id" => field_id, "value" => cf["value"] }
55
+ end
56
+ end.compact
44
57
 
45
58
  self.data[:ticket_fields].each do |field_id, field|
46
- custom_fields.find { |cf| cf["id"] == field_id } ||
59
+ requested_custom_fields.find { |cf| cf["id"] == field_id } ||
47
60
  custom_fields << {"id" => field_id, "value" => nil }
48
61
  end
49
62
 
@@ -25,7 +25,7 @@ class Zendesk2::Client
25
25
  if (email = record["email"]) && self.data[:identities].find{|k,i| i["type"] == "email" && i["value"] == email}
26
26
  error!(:invalid, :details => {
27
27
  "email" => [ {
28
- "description" => "Email #{email} is already being used by another user"
28
+ "description" => "Email: #{email} is already being used by another user"
29
29
  }]})
30
30
  else
31
31
  user_identity_id = self.class.new_id # ugh
@@ -129,15 +129,14 @@ class Zendesk2::Client < Cistern::Service
129
129
  raise ArgumentError, "missing parameters: #{missing.join(", ")}"
130
130
  end
131
131
  end
132
- end
133
132
 
134
- class Real
135
- include Shared
133
+ private
136
134
 
137
- attr_accessor :username, :url, :token, :logger, :jwt_token
135
+ def zendesk_url(options)
136
+ options[:url] || Zendesk2.defaults[:url] || form_zendesk_url(options)
137
+ end
138
138
 
139
- def initialize(options={})
140
- url = options[:url] || Zendesk2.defaults[:url] || begin
139
+ def form_zendesk_url(options)
141
140
  host = options[:host]
142
141
  subdomain = options[:subdomain] || Zendesk2.defaults[:subdomain]
143
142
 
@@ -146,8 +145,17 @@ class Zendesk2::Client < Cistern::Service
146
145
  port = options[:port] || (scheme == "https" ? 443 : 80)
147
146
 
148
147
  "#{scheme}://#{host}:#{port}"
149
- end
148
+ end
149
+ end
150
+
151
+ class Real
152
+ include Shared
150
153
 
154
+ attr_accessor :username, :url, :token, :logger, :jwt_token
155
+
156
+ def initialize(options={})
157
+ options[:subdomain] ||= "mock"
158
+ url = zendesk_url(options)
151
159
  @url = URI.parse(url).to_s
152
160
 
153
161
  @logger = options[:logger] || Logger.new(nil)
@@ -235,14 +243,7 @@ class Zendesk2::Client < Cistern::Service
235
243
  end
236
244
 
237
245
  def initialize(options={})
238
- url = options[:url] || begin
239
- host = options[:host]
240
- host ||= "#{options[:subdomain] || "mock"}.zendesk.com"
241
- scheme = options[:scheme] || "https"
242
- port = options[:port] || (scheme == "https" ? 443 : 80)
243
-
244
- "#{scheme}://#{host}:#{port}"
245
- end
246
+ url = zendesk_url(options)
246
247
 
247
248
  @url = url
248
249
  @path = URI.parse(url).path
@@ -12,8 +12,8 @@ class Zendesk2::Model < Cistern::Model
12
12
  # @return [Zendesk2::Model] self, regardless of success
13
13
  def save
14
14
  save!
15
- rescue Zendesk2::Error => e
16
- self.errors = e.response[:body]["details"].inject({}){|r,(k,v)| r.merge(k => v.map{|e| e["type"] || e["description"]})} rescue nil
15
+ rescue Zendesk2::Error => exception
16
+ self.errors = exception.response[:body]["details"].inject({}){|r,(k,v)| r.merge(k => v.map{|e| e["type"] || e["description"]})} rescue nil
17
17
  self
18
18
  end
19
19
 
@@ -26,4 +26,9 @@ class Zendesk2::Model < Cistern::Model
26
26
  rescue Zendesk2::Error
27
27
  false
28
28
  end
29
+
30
+ # re-define Cistern::Attributes#missing_attributes to require non-blank
31
+ def missing_attributes(args)
32
+ ([:connection] | args).select{|arg| val = send("#{arg}"); val.nil? || val == "" }
33
+ end
29
34
  end
@@ -1,3 +1,3 @@
1
1
  module Zendesk2
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
data/spec/groups_spec.rb CHANGED
@@ -12,6 +12,6 @@ describe "groups" do
12
12
  it "should list assignable groups" do
13
13
  client.groups.create(name: Zendesk2.uuid) # assignable by default
14
14
 
15
- client.groups.assignable.should be_all{|g| !g.deleted}
15
+ expect(client.groups.assignable).to be_all{|g| !g.deleted}
16
16
  end
17
17
  end
@@ -19,12 +19,12 @@ describe "memberships" do
19
19
 
20
20
  another_membership = client.memberships.create!(organization: another_organization, user: user)
21
21
 
22
- membership.default.should be_false # for some reason
23
- another_membership.default.should be_false
22
+ expect(membership.default).to be_falsey # for some reason
23
+ expect(another_membership.default).to be_falsey
24
24
 
25
25
  expect { another_membership.default! }.to change { another_membership.reload.default }.from(false).to(true)
26
26
 
27
- membership.reload.default.should be_false
27
+ expect(membership.reload.default).to be_falsey
28
28
  end
29
29
 
30
30
  it "should get an organization's memberships" do
@@ -35,8 +35,8 @@ describe "memberships" do
35
35
  another_organization.memberships.create!(user: user)
36
36
  organization.memberships.create!(user: another_user)
37
37
 
38
- organization.memberships.size.should == 1
39
- another_organization.memberships.size.should == 2
38
+ expect(organization.memberships.size).to eq(1)
39
+ expect(another_organization.memberships.size).to eq(2)
40
40
  end
41
41
 
42
42
  it "should get an user's memberships" do
@@ -47,8 +47,8 @@ describe "memberships" do
47
47
  user_membership = another_organization.memberships.create!(user: user)
48
48
  organization.memberships.create!(user: another_user)
49
49
 
50
- user.memberships.to_a.should == [user_membership]
51
- another_user.memberships.size.should == 2
50
+ expect(user.memberships.to_a).to eq([user_membership])
51
+ expect(another_user.memberships.size).to eq(2)
52
52
  end
53
53
 
54
54
  describe "create_membership" do
@@ -13,19 +13,19 @@ describe "organizations" do
13
13
  let(:organization) { client.organizations.create(name: Zendesk2.uuid) }
14
14
  it "should get #users" do
15
15
  user = client.users.create(email: "#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid, organization: organization)
16
- organization.users.should include user
16
+ expect(organization.users).to include user
17
17
  end
18
18
 
19
19
  it "should get #tickets" do
20
20
  user = client.users.create(email: "#{Zendesk2.uuid}@example.org", name: Zendesk2.uuid, organization: organization)
21
21
  ticket = client.tickets.create(subject: "#{Zendesk2.uuid}@example.org", description: Zendesk2.uuid, requester: user)
22
- organization.tickets.should include ticket
22
+ expect(organization.tickets).to include ticket
23
23
  end
24
24
 
25
25
  it "should hate non-unique names" do
26
- lambda { client.organizations.create!(name: organization.name) }.should raise_exception(Zendesk2::Error)
26
+ expect { client.organizations.create!(name: organization.name) }.to raise_exception(Zendesk2::Error)
27
27
  model = client.organizations.create(name: organization.name)
28
- model.errors.should == {"name" => ["Name has already been taken"]}
28
+ expect(model.errors).to eq({"name" => ["Name has already been taken"]})
29
29
  end
30
30
 
31
31
  it "should be able to find organizations by external id" do
@@ -34,7 +34,7 @@ describe "organizations" do
34
34
  o.external_id = external_id
35
35
  o.save
36
36
  found = client.organizations.find_by_external_id(external_id).first
37
- found.should === o
37
+ expect(found).to be === o
38
38
  end
39
39
 
40
40
  end
@@ -10,12 +10,12 @@ shared_examples "zendesk resource" do |options={}|
10
10
 
11
11
  it "should be created" do
12
12
  @record = collection.create!(create_params)
13
- record.identity.should_not be_nil
13
+ expect(record.identity).not_to be_nil
14
14
  end
15
15
 
16
16
  it "should be fetched" do
17
17
  @record = collection.create!(create_params)
18
- collection.get!(fetch_params.call(record)).should == record
18
+ expect(collection.get!(fetch_params.call(record))).to eq(record)
19
19
  end
20
20
 
21
21
  if options.fetch(:paged, true)
@@ -27,27 +27,27 @@ shared_examples "zendesk resource" do |options={}|
27
27
  after(:each) { @resources.each { |r| r.destroy } }
28
28
 
29
29
  it "should retrieve first page" do
30
- collection.all("per_page" => "1").size.should == 1
30
+ expect(collection.all("per_page" => "1").size).to eq(1)
31
31
  end
32
32
 
33
33
  it "should retrieve next page" do
34
34
  first_page = collection.all("per_page" => 1)
35
35
  second_page = collection.all("per_page" => 1).next_page
36
- second_page.should_not == first_page
36
+ expect(second_page).not_to eq(first_page)
37
37
  end
38
38
 
39
39
  it "should retreive previous page" do
40
40
  first_page = collection.all("per_page" => "1")
41
41
  previous_to_second_page = collection.all("per_page" => 1).next_page.previous_page
42
- previous_to_second_page.should == first_page
42
+ expect(previous_to_second_page).to eq(first_page)
43
43
  end
44
44
  end
45
45
  else
46
46
  context "paging" do
47
47
  it "should not be present" do
48
- collection.class.attributes.should_not have_key(:next_page_link)
49
- collection.class.attributes.should_not have_key(:previous_page_link)
50
- collection.class.attributes.should have_key(:count)
48
+ expect(collection.class.attributes).not_to have_key(:next_page_link)
49
+ expect(collection.class.attributes).not_to have_key(:previous_page_link)
50
+ expect(collection.class.attributes).to have_key(:count)
51
51
  end
52
52
  end
53
53
  end
@@ -57,17 +57,17 @@ shared_examples "zendesk resource" do |options={}|
57
57
  @record = collection.create!(create_params)
58
58
  record.merge_attributes(update_params)
59
59
  record.save
60
- update_params.each {|k,v| record.send(k).should == v}
60
+ update_params.each {|k,v| expect(record.send(k)).to eq(v)}
61
61
  end
62
62
  end
63
63
 
64
64
  it "should be destroyed" do
65
65
  @record = collection.create!(create_params)
66
- record.identity.should_not be_nil
66
+ expect(record.identity).not_to be_nil
67
67
  record.destroy
68
68
 
69
69
  if !options.fetch(:delayed_destroy, false) && !Zendesk2::Client.mocking?
70
- record.should be_destroyed
70
+ expect(record).to be_destroyed
71
71
  end
72
72
  end
73
73
 
@@ -75,7 +75,7 @@ shared_examples "zendesk resource" do |options={}|
75
75
  # Search index takes 2-3 minutes according to the docs
76
76
  it "should search" do
77
77
  @record = collection.create!(create_params)
78
- collection.search(create_params).should include(record)
78
+ expect(collection.search(create_params)).to include(record)
79
79
  end
80
80
  end
81
81
  end
data/spec/tickets_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "tickets" do
3
+ describe "Zendesk2::Client" do
4
4
  let(:client) { create_client }
5
5
 
6
6
  include_examples "zendesk resource", {
@@ -9,6 +9,14 @@ describe "tickets" do
9
9
  :update_params => lambda { {subject: Zendesk2.uuid} },
10
10
  }
11
11
 
12
+ describe "#create_ticket" do
13
+ it "should require a description" do
14
+ expect {
15
+ client.create_ticket("subject" => Zendesk2.uuid)
16
+ }.to raise_exception(Zendesk2::Error, /Description: cannot be blank/)
17
+ end
18
+ end
19
+
12
20
  describe "when creating a ticket" do
13
21
  let!(:requester_email) { "#{Zendesk2.uuid}@example.org" }
14
22
 
@@ -16,11 +24,11 @@ describe "tickets" do
16
24
  ticket = client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid, requester: {name: "Josh Lane", email: requester_email})
17
25
  if Zendesk2::Client.mocking? # this takes some time for realsies
18
26
  requester = client.users.search(email: requester_email).first
19
- requester.should_not be_nil
27
+ expect(requester).not_to be_nil
20
28
 
21
- ticket.reload.requester.should == requester
29
+ expect(ticket.reload.requester).to eq(requester)
22
30
  else
23
- ticket.reload.requester.should_not be_nil
31
+ expect(ticket.reload.requester).not_to be_nil
24
32
  end
25
33
  end
26
34
 
@@ -29,22 +37,32 @@ describe "tickets" do
29
37
  client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid, requester: {email: requester_email})
30
38
  }.to raise_exception(Zendesk2::Error, /Requester Name: .* too short/)
31
39
  end
40
+
41
+ it "should require a description" do
42
+ expect {
43
+ client.tickets.create!(subject: Zendesk2.uuid)
44
+ }.to raise_exception(ArgumentError, /description is required/)
45
+
46
+ expect {
47
+ client.tickets.create!(subject: Zendesk2.uuid, description: "")
48
+ }.to raise_exception(ArgumentError, /description is required/)
49
+ end
32
50
  end
33
51
 
34
52
  describe "with a created ticket" do
35
53
  let(:ticket) { client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid) }
36
54
  it "should get requester" do
37
- ticket.requester.should == client.users.current
55
+ expect(ticket.requester).to eq(client.users.current)
38
56
  end
39
57
 
40
58
  it "should get submitter" do
41
- ticket.submitter.should == client.users.current
59
+ expect(ticket.submitter).to eq(client.users.current)
42
60
  end
43
61
 
44
62
  it "should have empty custom fields by default" do
45
63
  pending if !Zendesk2::Client.mocking?
46
64
 
47
- ticket.custom_fields.should == []
65
+ expect(ticket.custom_fields).to eq([])
48
66
  end
49
67
  end
50
68
 
@@ -56,38 +74,43 @@ describe "tickets" do
56
74
  ticket.comment(body)
57
75
 
58
76
  audit = ticket.audits.last
59
- audit.ticket.should == ticket
77
+ expect(audit.ticket).to eq(ticket)
60
78
 
61
79
  events = audit.events
62
- events.size.should == 1
80
+ expect(events.size).to eq(1)
63
81
 
64
82
  event = events.first
65
- event.body.should == body
66
- event.should be_a(Zendesk2::Client::TicketComment)
67
- event.ticket_audit.should == audit
83
+ expect(event.body).to eq(body)
84
+ expect(event).to be_a(Zendesk2::Client::TicketComment)
85
+ expect(event.ticket_audit).to eq(audit)
68
86
  end
69
87
 
70
88
  it "lists comments" do
71
89
  body = Zendesk2.uuid
72
90
  ticket.comment(body)
73
91
 
74
- ticket.comments.find{|c| c.body == body}.should_not be_nil
92
+ expect(ticket.comments.find{|c| c.body == body}).not_to be_nil
75
93
  end
76
94
  end
77
95
 
78
96
  describe "custom fields" do
79
- let!(:ticket_field) { client.ticket_fields.create!(title: Zendesk2.uuid, type: "textbox") }
97
+ let!(:ticket_field) { client.ticket_fields.create!(title: SecureRandom.hex(3), type: "text") }
80
98
 
81
99
  it "should be based on ticket_fields" do
82
100
  ticket = client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid)
83
101
  custom_field = ticket.custom_fields.find { |cf| cf["id"] == ticket_field.identity }
84
- custom_field.should_not be_nil
85
- custom_field["value"].should be_nil
102
+
103
+ expect(custom_field).not_to be_nil
104
+ expect(custom_field["value"]).to be_nil
86
105
 
87
106
  ticket = client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid, custom_fields: [{"id" => ticket_field.identity, "value" => "jessicaspacekat"}])
88
107
  custom_field = ticket.custom_fields.find { |cf| cf["id"] == ticket_field.identity }
89
- custom_field.should_not be_nil
90
- custom_field["value"].should == "jessicaspacekat"
108
+
109
+ expect(custom_field).not_to be_nil
110
+ expect(custom_field["value"]).to eq("jessicaspacekat")
111
+
112
+ ticket = client.tickets.create!(subject: Zendesk2.uuid, description: Zendesk2.uuid, custom_fields: [{"id" => "-1", "value" => "fantasy"}])
113
+ expect(ticket.custom_fields).not_to include({"id" => -1, "value" => "fantasy"})
91
114
  end
92
115
  end
93
116
  end
data/spec/users_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe "users" do
11
11
 
12
12
  it "should get current user" do
13
13
  current_user = client.users.current
14
- current_user.email.should == client.username
14
+ expect(current_user.email).to eq(client.username)
15
15
  end
16
16
 
17
17
  describe do
@@ -24,49 +24,49 @@ describe "users" do
24
24
  it "should update organization" do
25
25
  organization = client.organizations.create(name: Zendesk2.uuid)
26
26
  user.organization= organization
27
- user.save.should be_true
28
- user.organization.should == organization
27
+ expect(user.save).to be_truthy
28
+ expect(user.organization).to eq(organization)
29
29
  end
30
30
 
31
31
  it "should get requested tickets" do
32
32
  ticket = client.tickets.create(requester: user, subject: Zendesk2.uuid, description: Zendesk2.uuid)
33
33
 
34
- user.requested_tickets.should include ticket
34
+ expect(user.requested_tickets).to include ticket
35
35
  end
36
36
 
37
37
  it "should get ccd tickets" do
38
38
  ticket = client.tickets.create(collaborators: [user], subject: Zendesk2.uuid, description: Zendesk2.uuid)
39
39
 
40
- user.ccd_tickets.should include ticket
40
+ expect(user.ccd_tickets).to include ticket
41
41
  end
42
42
 
43
43
  it "cannot destroy a user with a ticket" do
44
44
  client.tickets.create(requester: user, subject: Zendesk2.uuid, description: Zendesk2.uuid)
45
45
 
46
- user.destroy.should be_false
46
+ expect(user.destroy).to be_falsey
47
47
 
48
- user.should_not be_destroyed
48
+ expect(user).not_to be_destroyed
49
49
  end
50
50
 
51
51
  it "should list identities" do
52
52
  identities = user.identities.all
53
- identities.size.should == 1
53
+ expect(identities.size).to eq(1)
54
54
 
55
55
  identity = identities.first
56
- identity.primary.should be_true
57
- identity.verified.should be_false
58
- identity.type.should == "email"
59
- identity.value.should == user.email
56
+ expect(identity.primary).to be_truthy
57
+ expect(identity.verified).to be_falsey
58
+ expect(identity.type).to eq("email")
59
+ expect(identity.value).to eq(user.email)
60
60
  end
61
61
 
62
62
  it "should create a new identity" do
63
63
  email = "ey+#{Zendesk2.uuid}@example.org"
64
64
 
65
65
  new_identity = user.identities.create!(type: "email", value: email)
66
- new_identity.primary.should be_false
67
- new_identity.verified.should be_false
68
- new_identity.type.should == "email"
69
- new_identity.value.should == email
66
+ expect(new_identity.primary).to be_falsey
67
+ expect(new_identity.verified).to be_falsey
68
+ expect(new_identity.type).to eq("email")
69
+ expect(new_identity.value).to eq(email)
70
70
  end
71
71
 
72
72
  it "should mark remaining identity as primary" do
@@ -77,10 +77,10 @@ describe "users" do
77
77
 
78
78
  initial_identity.destroy
79
79
 
80
- new_identity.reload.primary.should be_false
80
+ expect(new_identity.reload.primary).to be_falsey
81
81
 
82
82
  new_identity.primary!
83
- new_identity.reload.primary.should be_true
83
+ expect(new_identity.reload.primary).to be_truthy
84
84
  end
85
85
 
86
86
  it "should not allow multiple primary identities" do
@@ -89,19 +89,19 @@ describe "users" do
89
89
  initial_identity = user.identities.all.first
90
90
  new_identity = user.identities.create!(type: "email", value: email)
91
91
  new_identity.primary!
92
- new_identity.primary.should be_true
93
- new_identity.reload.primary.should be_true
92
+ expect(new_identity.primary).to be_truthy
93
+ expect(new_identity.reload.primary).to be_truthy
94
94
 
95
- initial_identity.reload.primary.should be_false
95
+ expect(initial_identity.reload.primary).to be_falsey
96
96
  end
97
97
 
98
98
  it "should hate non-unique emails" do
99
99
  email = "zendesk2+#{Zendesk2.uuid}@example.org"
100
100
  client.users.create(email: email, name: Zendesk2.uuid)
101
- lambda { client.users.create!(email: email, name: Zendesk2.uuid) }.should raise_exception(Zendesk2::Error)
101
+ expect { client.users.create!(email: email, name: Zendesk2.uuid) }.to raise_exception(Zendesk2::Error)
102
102
  user = client.users.create(email: email, name: Zendesk2.uuid)
103
- user.identity.should be_false
104
- user.errors.should == {"email" => ["Email #{email} is already being used by another user"]}
103
+ expect(user.identity).to be_falsey
104
+ expect(user.errors).to eq({"email" => ["Email: #{email} is already being used by another user"]})
105
105
  end
106
106
 
107
107
  it "should create another identity when updating email" do
@@ -109,36 +109,36 @@ describe "users" do
109
109
  user.email = (new_email = "zendesk2+#{Zendesk2.uuid}@example.org")
110
110
  user.save!
111
111
 
112
- (identities = user.identities.all).size.should == 2
112
+ expect((identities = user.identities.all).size).to eq(2)
113
113
  new_identity = identities.find{|i| i.value == new_email}
114
- new_identity.should_not be_nil
114
+ expect(new_identity).not_to be_nil
115
115
 
116
- new_identity.primary.should be_false
116
+ expect(new_identity.primary).to be_falsey
117
117
 
118
118
  original_identity = identities.find{|i| i.value == original_email}
119
- original_identity.should_not be_nil
119
+ expect(original_identity).not_to be_nil
120
120
 
121
- original_identity.primary.should be_true
121
+ expect(original_identity.primary).to be_truthy
122
122
 
123
- user.reload.email.should == original_email
123
+ expect(user.reload.email).to eq(original_email)
124
124
  end
125
125
 
126
126
  it "should form 'legacy' login url" do
127
127
  return_to = "http://engineyard.com"
128
128
  uri = Addressable::URI.parse(user.login_url(Time.now.to_s, return_to: return_to, token: "in-case-you-dont-have-it-in ~/.zendesk2 (aka ci)"))
129
- uri.query_values["return_to"].should == return_to
130
- uri.query_values["name"].should eq user.name
131
- uri.query_values["email"].should eq user.email
132
- uri.query_values["hash"].should_not be_nil
129
+ expect(uri.query_values["return_to"]).to eq(return_to)
130
+ expect(uri.query_values["name"]).to eq user.name
131
+ expect(uri.query_values["email"]).to eq user.email
132
+ expect(uri.query_values["hash"]).not_to be_nil
133
133
  end
134
134
 
135
135
  it "should form jwt login url" do
136
136
  return_to = "http://engineyard.com"
137
137
  uri = Addressable::URI.parse(user.jwt_login_url(return_to: return_to, jwt_token: "in-case-you-dont-have-it-in ~/.zendesk2 (aka ci)"))
138
- uri.query_values["return_to"].should == return_to
139
- uri.query_values["name"].should be_nil
140
- uri.query_values["email"].should be_nil
141
- uri.query_values["jwt"].should_not be_nil
138
+ expect(uri.query_values["return_to"]).to eq(return_to)
139
+ expect(uri.query_values["name"]).to be_nil
140
+ expect(uri.query_values["email"]).to be_nil
141
+ expect(uri.query_values["jwt"]).not_to be_nil
142
142
 
143
143
  #TODO: try JWT.decode
144
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable