zendesk_api 1.3.9 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -1
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +31 -21
  5. data/lib/zendesk_api/collection.rb +7 -0
  6. data/lib/zendesk_api/version.rb +1 -1
  7. data/spec/core/association_spec.rb +40 -40
  8. data/spec/core/client_spec.rb +37 -37
  9. data/spec/core/collection_spec.rb +81 -70
  10. data/spec/core/configuration_spec.rb +4 -4
  11. data/spec/core/create_resource_spec.rb +2 -2
  12. data/spec/core/data_resource_spec.rb +28 -28
  13. data/spec/core/inflection_spec.rb +1 -1
  14. data/spec/core/lru_cache_spec.rb +8 -8
  15. data/spec/core/middleware/request/encode_json_spec.rb +8 -8
  16. data/spec/core/middleware/request/etag_cache_spec.rb +5 -5
  17. data/spec/core/middleware/request/retry_spec.rb +10 -8
  18. data/spec/core/middleware/request/upload_spec.rb +25 -25
  19. data/spec/core/middleware/response/callback_spec.rb +1 -1
  20. data/spec/core/middleware/response/deflate_spec.rb +1 -1
  21. data/spec/core/middleware/response/gzip_spec.rb +1 -1
  22. data/spec/core/middleware/response/parse_iso_dates_spec.rb +9 -9
  23. data/spec/core/middleware/response/parse_json_spec.rb +4 -4
  24. data/spec/core/middleware/response/raise_error_spec.rb +2 -2
  25. data/spec/core/read_resource_spec.rb +6 -6
  26. data/spec/core/resource_spec.rb +66 -66
  27. data/spec/core/search_spec.rb +3 -3
  28. data/spec/core/spec_helper.rb +5 -4
  29. data/spec/core/trackie_spec.rb +17 -17
  30. data/spec/live/app_installation_spec.rb +2 -2
  31. data/spec/live/app_spec.rb +1 -1
  32. data/spec/live/audit_spec.rb +2 -2
  33. data/spec/live/collection_spec.rb +8 -8
  34. data/spec/live/locale_spec.rb +1 -1
  35. data/spec/live/macro_spec.rb +4 -4
  36. data/spec/live/setting_spec.rb +1 -1
  37. data/spec/live/tag_spec.rb +7 -7
  38. data/spec/live/ticket_spec.rb +10 -10
  39. data/spec/live/topic_comment_spec.rb +2 -2
  40. data/spec/live/topic_spec.rb +2 -2
  41. data/spec/live/user_spec.rb +15 -15
  42. data/spec/macros/resource_macros.rb +17 -17
  43. metadata +2 -2
@@ -4,19 +4,19 @@ describe ZendeskAPI::Search do
4
4
  context ".new" do
5
5
  context "when given an existing class" do
6
6
  it "should return the correct class" do
7
- ZendeskAPI::Search.new(nil, { "result_type" => "user" }).should be_instance_of(ZendeskAPI::User)
7
+ expect(ZendeskAPI::Search.new(nil, { "result_type" => "user" })).to be_instance_of(ZendeskAPI::User)
8
8
  end
9
9
  end
10
10
 
11
11
  context "when given a nonexistent class" do
12
12
  it "should return an object of the type Search::Result" do
13
- ZendeskAPI::Search.new(nil, { "result_type" => "blah" }).should be_instance_of(ZendeskAPI::Search::Result)
13
+ expect(ZendeskAPI::Search.new(nil, { "result_type" => "blah" })).to be_instance_of(ZendeskAPI::Search::Result)
14
14
  end
15
15
  end
16
16
 
17
17
  context "when not given anything" do
18
18
  it "should return an object of the type Search::Result" do
19
- ZendeskAPI::Search.new(nil, {}).should be_instance_of(ZendeskAPI::Search::Result)
19
+ expect(ZendeskAPI::Search.new(nil, {})).to be_instance_of(ZendeskAPI::Search::Result)
20
20
  end
21
21
  end
22
22
  end
@@ -15,6 +15,11 @@ require 'logger'
15
15
  require 'stringio'
16
16
  require 'multi_json'
17
17
 
18
+ begin
19
+ require 'byebug'
20
+ rescue LoadError
21
+ end
22
+
18
23
  class String
19
24
  def encoding_aware?; false; end
20
25
  end
@@ -120,10 +125,6 @@ module TestHelper
120
125
  end
121
126
 
122
127
  RSpec.configure do |c|
123
- # so we can use `:vcr` rather than `:vcr => true`;
124
- # in RSpec 3 this will no longer be necessary.
125
- c.treat_symbols_as_metadata_keys_with_true_values = true
126
-
127
128
  c.before(:each) do
128
129
  ZendeskAPI::TestResource.associations.clear
129
130
  ZendeskAPI::TestResource.has_many :children, :class => ZendeskAPI::TestResource::TestChild
@@ -5,19 +5,19 @@ describe ZendeskAPI::Trackie do
5
5
  before(:each) { subject.clear_changes }
6
6
 
7
7
  it "should not be changed" do
8
- subject.changed?.should be_false
8
+ expect(subject.changed?).to be(false)
9
9
  end
10
10
 
11
11
  context "adding keys" do
12
12
  before(:each) { subject[:key] = true }
13
13
 
14
14
  it "should include key in changes" do
15
- subject.changes[:key].should be_true
15
+ expect(subject.changes[:key]).to be(true)
16
16
  end
17
17
 
18
18
  specify "key should be changed" do
19
- subject.changed?(:key).should be_true
20
- subject.changed?.should be_true
19
+ expect(subject.changed?(:key)).to be(true)
20
+ expect(subject.changed?).to be(true)
21
21
  end
22
22
  end
23
23
 
@@ -27,14 +27,14 @@ describe ZendeskAPI::Trackie do
27
27
  end
28
28
 
29
29
  it "returns key on deletion" do
30
- subject.delete(:key).should be_true
30
+ expect(subject.delete(:key)).to be(true)
31
31
  end
32
32
 
33
33
  context "after deletion" do
34
34
  before(:each) { subject.delete(:key) }
35
35
 
36
36
  it "keeps the changes" do
37
- subject.changed?(:key).should be_true
37
+ expect(subject.changed?(:key)).to be(true)
38
38
  end
39
39
  end
40
40
  end
@@ -48,12 +48,12 @@ describe ZendeskAPI::Trackie do
48
48
  end
49
49
 
50
50
  it "should not include key in changes" do
51
- subject.changes[:key].should be_false
51
+ expect(subject.changes[:key]).to be_falsey
52
52
  end
53
53
 
54
54
  specify "key should not be changed" do
55
- subject.changed?(:key).should be_false
56
- subject.changed?.should be_false
55
+ expect(subject.changed?(:key)).to be(false)
56
+ expect(subject.changed?).to be(false)
57
57
  end
58
58
  end
59
59
 
@@ -65,11 +65,11 @@ describe ZendeskAPI::Trackie do
65
65
  end
66
66
 
67
67
  it "should include changes from nested hash" do
68
- subject.changes[:key][:test].should be_true
68
+ expect(subject.changes[:key][:test]).to be(true)
69
69
  end
70
70
 
71
71
  specify "subject should be changed" do
72
- subject.changed?.should be_true
72
+ expect(subject.changed?).to be(true)
73
73
  end
74
74
  end
75
75
 
@@ -82,11 +82,11 @@ describe ZendeskAPI::Trackie do
82
82
  end
83
83
 
84
84
  it "should include changes from nested array" do
85
- subject.changes[:key].should == [:test]
85
+ expect(subject.changes[:key]).to eq([:test])
86
86
  end
87
87
 
88
88
  specify "subject should be changed" do
89
- subject.changed?.should be_true
89
+ expect(subject.changed?).to be(true)
90
90
  end
91
91
  end
92
92
  =end
@@ -99,11 +99,11 @@ describe ZendeskAPI::Trackie do
99
99
  end
100
100
 
101
101
  it "should include changes from nested array" do
102
- subject.changes[:key].first[:test].should be_true
102
+ expect(subject.changes[:key].first[:test]).to be(true)
103
103
  end
104
104
 
105
105
  specify "subject should be changed" do
106
- subject.changed?.should be_true
106
+ expect(subject.changed?).to be(true)
107
107
  end
108
108
 
109
109
  context "clearing" do
@@ -112,7 +112,7 @@ describe ZendeskAPI::Trackie do
112
112
  end
113
113
 
114
114
  it "should not have any changes" do
115
- subject.changes.should be_empty
115
+ expect(subject.changes).to be_empty
116
116
  end
117
117
  end
118
118
  end
@@ -123,7 +123,7 @@ describe ZendeskAPI::Trackie do
123
123
  end
124
124
 
125
125
  it "returns the value corresponding to the :size key" do
126
- subject.size.should == 42
126
+ expect(subject.size).to eq(42)
127
127
  end
128
128
  end
129
129
  end
@@ -44,12 +44,12 @@ describe ZendeskAPI::AppInstallation do
44
44
  VCR.use_cassette("app_install_fetch") { installations.fetch! }
45
45
  VCR.use_cassette("app_install_find") { client.app.installations.find!(:id => install.id) }
46
46
 
47
- installations.should include(install)
47
+ expect(installations).to include(install)
48
48
 
49
49
  install.settings.name = "My New Name"
50
50
  VCR.use_cassette("app_install_update") { install.save! }
51
51
 
52
- install.settings.title.should == "My New Name"
52
+ expect(install.settings.title).to eq("My New Name")
53
53
 
54
54
  VCR.use_cassette("app_install_destroy") { install.destroy! }
55
55
 
@@ -20,7 +20,7 @@ describe ZendeskAPI::App do
20
20
 
21
21
  VCR.use_cassette("app_save") { app.save! }
22
22
 
23
- app.author_name.should == "Mr. Sprinkles"
23
+ expect(app.author_name).to eq("Mr. Sprinkles")
24
24
 
25
25
  VCR.use_cassette("app_find") { client.apps.find!(:id => app.id) }
26
26
  VCR.use_cassette("app_destroy") { app.destroy! }
@@ -8,8 +8,8 @@ describe ZendeskAPI::Ticket::Audit do
8
8
  audit = ticket.audits(include: :users).first
9
9
  event = audit.events.first
10
10
 
11
- event.should be_instance_of(ZendeskAPI::Ticket::Audit::Event)
12
- event.author.should be_instance_of(ZendeskAPI::User)
11
+ expect(event).to be_instance_of(ZendeskAPI::Ticket::Audit::Event)
12
+ expect(event.author).to be_instance_of(ZendeskAPI::User)
13
13
  end
14
14
  end
15
15
  end
@@ -24,16 +24,16 @@ describe ZendeskAPI::Collection do
24
24
  current = subject.to_a.dup
25
25
  nxt = subject.next
26
26
 
27
- nxt.size.should == 1
28
- nxt.should_not == current
27
+ expect(nxt.size).to eq(1)
28
+ expect(nxt).to_not eq(current)
29
29
  end
30
30
 
31
31
  it "should find the prev page by calling fetch" do
32
32
  current = subject.to_a.dup
33
33
  prev = subject.prev
34
34
 
35
- prev.size.should == 1
36
- prev.should_not == current
35
+ expect(prev.size).to eq(1)
36
+ expect(prev).to_not eq(current)
37
37
  end
38
38
  end
39
39
 
@@ -41,22 +41,22 @@ describe ZendeskAPI::Collection do
41
41
  before(:each) { subject.per_page(1).page(2) }
42
42
 
43
43
  it "should increase page option and not call fetch" do
44
- subject.next.should == 3
44
+ expect(subject.next).to eq(3)
45
45
  end
46
46
 
47
47
  it "should decrease page option and not call fetch" do
48
- subject.prev.should == 1
48
+ expect(subject.prev).to eq(1)
49
49
  end
50
50
 
51
51
  context "with page == 1" do
52
52
  before do
53
53
  subject.page(1)
54
54
  subject.clear_cache
55
- subject.should_not_receive(:fetch)
55
+ expect(subject).to_not receive(:fetch)
56
56
  end
57
57
 
58
58
  it "should do nothing on #prev" do
59
- subject.prev.should == []
59
+ expect(subject.prev).to eq([])
60
60
  end
61
61
  end
62
62
  end
@@ -2,7 +2,7 @@ require 'core/spec_helper'
2
2
 
3
3
  describe ZendeskAPI::Locale, :vcr do
4
4
  specify "client#current_locale" do
5
- client.current_locale.should be_instance_of(described_class)
5
+ expect(client.current_locale).to be_instance_of(described_class)
6
6
  end
7
7
 
8
8
  it_should_be_readable :locales
@@ -28,15 +28,15 @@ describe ZendeskAPI::Macro, :delete_after do
28
28
  describe "to a ticket" do
29
29
  it "should return a hash" do
30
30
  result = subject.apply(ticket)
31
- result.should be_instance_of(Hashie::Mash)
32
- result.ticket.should_not be_nil
31
+ expect(result).to be_instance_of(Hashie::Mash)
32
+ expect(result.ticket).to_not be_nil
33
33
  end
34
34
  end
35
35
 
36
36
  it "should be appliable" do
37
37
  result = subject.apply
38
- result.should be_instance_of(Hashie::Mash)
39
- result.ticket.should_not be_nil
38
+ expect(result).to be_instance_of(Hashie::Mash)
39
+ expect(result.ticket).to_not be_nil
40
40
  end
41
41
  end
42
42
  end
@@ -18,7 +18,7 @@ describe ZendeskAPI::Setting do
18
18
  settings.fetch!(true)
19
19
 
20
20
  lotus = settings.detect {|set| set.on == "lotus"}
21
- lotus.keyboard_shortcuts_enabled.should == !original_setting
21
+ expect(lotus.keyboard_shortcuts_enabled).to eq(!original_setting)
22
22
  end
23
23
  end
24
24
  end
@@ -11,45 +11,45 @@ describe ZendeskAPI::Tag, :vcr, :not_findable do
11
11
  end
12
12
 
13
13
  it "can be set" do
14
- tags.should == %w{tag2 tag3}
14
+ expect(tags).to eq(%w{tag2 tag3})
15
15
  end
16
16
 
17
17
  it "should be removable" do
18
18
  parent.tags.destroy!(:id => "tag2")
19
19
 
20
- tags.should == %w{tag3}
20
+ expect(tags).to eq(%w{tag3})
21
21
  end
22
22
 
23
23
  it "shouldn't re-save destroyed tags" do
24
24
  parent.tags.first.destroy!
25
25
  parent.tags.save!
26
26
 
27
- tags.should == %w{tag3}
27
+ expect(tags).to eq(%w{tag3})
28
28
  end
29
29
 
30
30
  it "should be updatable" do
31
31
  parent.tags.update!(:id => "tag4")
32
32
 
33
- tags.should == %w{tag2 tag3 tag4}
33
+ expect(tags).to eq(%w{tag2 tag3 tag4})
34
34
  end
35
35
 
36
36
  it "should be savable" do
37
37
  parent.tags << "tag4"
38
38
  parent.tags.save!
39
39
 
40
- tags.should == %w{tag2 tag3 tag4}
40
+ expect(tags).to eq(%w{tag2 tag3 tag4})
41
41
  end
42
42
 
43
43
  it "should be modifiable" do
44
44
  parent.tags.delete(ZendeskAPI::Tag.new(nil, :id => "tag2"))
45
45
  parent.tags.save!
46
46
 
47
- tags.should == %w{tag3}
47
+ expect(tags).to eq(%w{tag3})
48
48
 
49
49
  parent.tags.delete_if {|tag| tag.id == "tag3"}
50
50
  parent.tags.save!
51
51
 
52
- tags.should be_empty
52
+ expect(tags).to be_empty
53
53
  end
54
54
  end
55
55
  end
@@ -52,7 +52,7 @@ describe ZendeskAPI::Ticket do
52
52
  end
53
53
 
54
54
  it "finds tickets after a old date" do
55
- results.to_a.first.should be_an_instance_of ZendeskAPI::Ticket
55
+ expect(results.to_a.first).to be_an_instance_of ZendeskAPI::Ticket
56
56
  end
57
57
 
58
58
  it "is able to do next" do
@@ -60,7 +60,7 @@ describe ZendeskAPI::Ticket do
60
60
  stub_json_request(:get, %r{/api/v2/exports/tickets}, json(:results => []))
61
61
 
62
62
  results.next
63
- results.first.should_not == first
63
+ expect(results.first).to_not eq(first)
64
64
  end
65
65
  end
66
66
 
@@ -69,13 +69,13 @@ describe ZendeskAPI::Ticket do
69
69
  VCR.use_cassette("ticket_import_can_import") do
70
70
  old = Time.now - 5*365*24*60*60
71
71
  ticket = ZendeskAPI::Ticket.import(client, valid_attributes.merge(:created_at => old))
72
- ZendeskAPI::Ticket.find(client, ticket).created_at.year.should == old.year
72
+ expect(ZendeskAPI::Ticket.find(client, ticket).created_at.year).to eq(old.year)
73
73
  end
74
74
  end
75
75
 
76
76
  it "returns nothing if import fails" do
77
77
  VCR.use_cassette("ticket_import_cannot_import") do
78
- silence_logger { ZendeskAPI::Ticket.import(client, {}).should == nil }
78
+ silence_logger { expect(ZendeskAPI::Ticket.import(client, {})).to eq(nil) }
79
79
  end
80
80
  end
81
81
  end
@@ -87,8 +87,8 @@ describe ZendeskAPI::Ticket do
87
87
  ticket.comment.uploads << File.new("spec/fixtures/Argentina.gif")
88
88
 
89
89
  ticket.save!
90
- ticket.changes.should == {} # uploads were set before save
91
- ticket.comment.attributes[:uploads].map(&:class).should == [String, String] # upload was sent as tokens
90
+ expect(ticket.changes).to eq({}) # uploads were set before save
91
+ expect(ticket.comment.attributes[:uploads].map(&:class)).to eq([String, String]) # upload was sent as tokens
92
92
  end
93
93
  end
94
94
 
@@ -98,8 +98,8 @@ describe ZendeskAPI::Ticket do
98
98
  ticket.comment = ZendeskAPI::Ticket::Comment.new(client, :value => "My comment", :public => false)
99
99
  ticket.save!
100
100
 
101
- ticket.changes.should == {} # comment was set before save
102
- ticket.attributes[:comment].should == {"value" => "My comment", "public" => false}
101
+ expect(ticket.changes).to eq({}) # comment was set before save
102
+ expect(ticket.attributes[:comment]).to eq({"value" => "My comment", "public" => false})
103
103
  end
104
104
  end
105
105
 
@@ -127,12 +127,12 @@ describe ZendeskAPI::Ticket do
127
127
  end
128
128
 
129
129
  user = client.users.detect {|user| user.email == email}
130
- user.should_not be_nil
130
+ expect(user).to_not be_nil
131
131
 
132
132
  user.requested_tickets.each(&:destroy)
133
133
  user.destroy
134
134
 
135
- threads.all? {|st| [201, 422, 409].include?(st)}.should be_true
135
+ expect(threads.all? {|st| [201, 422, 409].include?(st)}).to be(true)
136
136
  end
137
137
  end
138
138
  end
@@ -17,13 +17,13 @@ describe ZendeskAPI::Topic::TopicComment do
17
17
  VCR.use_cassette("topic_comment_import_can_import") do
18
18
  old = Time.now - 4*365*24*60*60
19
19
  comment = ZendeskAPI::Topic::TopicComment.import(client, valid_attributes.merge(:created_at => old, :topic_id => topic.id))
20
- ZendeskAPI::Topic::TopicComment.find(client, comment).created_at.year.should == old.year
20
+ expect(ZendeskAPI::Topic::TopicComment.find(client, comment).created_at.year).to eq(old.year)
21
21
  end
22
22
  end
23
23
 
24
24
  it "returns nothing if import fails" do
25
25
  VCR.use_cassette("topic_comment_import_cannot_import") do
26
- silence_logger { ZendeskAPI::Topic::TopicComment.import(client, {}).should == nil }
26
+ silence_logger { expect(ZendeskAPI::Topic::TopicComment.import(client, {})).to eq(nil) }
27
27
  end
28
28
  end
29
29
  end
@@ -21,13 +21,13 @@ describe ZendeskAPI::Topic do
21
21
  VCR.use_cassette("topic_import_can_import") do
22
22
  old = Time.now - 5*365*24*60*60
23
23
  topic = ZendeskAPI::Topic.import(client, valid_attributes.merge(:created_at => old))
24
- ZendeskAPI::Topic.find(client, topic).created_at.year.should == old.year
24
+ expect(ZendeskAPI::Topic.find(client, topic).created_at.year).to eq(old.year)
25
25
  end
26
26
  end
27
27
 
28
28
  it "returns nothing if import fails" do
29
29
  VCR.use_cassette("topic_import_cannot_import") do
30
- silence_logger { ZendeskAPI::Topic.import(client, {}).should == nil }
30
+ silence_logger { expect(ZendeskAPI::Topic.import(client, {})).to eq(nil) }
31
31
  end
32
32
  end
33
33
  end
@@ -13,7 +13,7 @@ describe ZendeskAPI::User, :delete_after do
13
13
 
14
14
  it "should be able to find by email" do
15
15
  VCR.use_cassette("user_find_by_email") do
16
- client.users.search(:query => current_user.email).to_a.should == [current_user]
16
+ expect(client.users.search(:query => current_user.email).to_a).to eq([current_user])
17
17
  end
18
18
  end
19
19
 
@@ -37,13 +37,13 @@ describe ZendeskAPI::User, :delete_after do
37
37
 
38
38
  it "should include role" do
39
39
  if subject
40
- subject.changes.key?(:role_id).should be_false
41
- subject.role.should_not be_nil
42
- subject.role.id.should be_nil
43
- subject.role.name.should == "admin"
44
- subject.role.configuration.should_not be_nil
40
+ expect(subject.changes.key?(:role_id)).to be(false)
41
+ expect(subject.role).to_not be_nil
42
+ expect(subject.role.id).to be_nil
43
+ expect(subject.role.name).to eq("admin")
44
+ expect(subject.role.configuration).to_not be_nil
45
45
 
46
- subject.custom_role.should be_nil
46
+ expect(subject.custom_role).to be_nil
47
47
  end
48
48
  end
49
49
  end
@@ -55,15 +55,15 @@ describe ZendeskAPI::User, :delete_after do
55
55
 
56
56
  it "should include role" do
57
57
  if subject
58
- subject.changes.key?(:role_id).should be_false
59
- subject.role.should_not be_nil
60
- subject.role.id.should be_nil
61
- subject.role.name.should == "agent"
58
+ expect(subject.changes.key?(:role_id)).to be(false)
59
+ expect(subject.role).to_not be_nil
60
+ expect(subject.role.id).to be_nil
61
+ expect(subject.role.name).to eq("agent")
62
62
 
63
- subject.custom_role.should_not be_nil
64
- subject.custom_role.id.should == 3692
65
- subject.custom_role.name.should == "Staff"
66
- subject.custom_role.configuration.should_not be_nil
63
+ expect(subject.custom_role).to_not be_nil
64
+ expect(subject.custom_role.id).to eq(3692)
65
+ expect(subject.custom_role.name).to eq("Staff")
66
+ expect(subject.custom_role.configuration).to_not be_nil
67
67
  end
68
68
  end
69
69
  end