zendesk_api 1.13.1 → 1.13.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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/zendesk_api/client.rb +1 -1
  3. data/lib/zendesk_api/middleware/response/parse_json.rb +0 -1
  4. data/lib/zendesk_api/version.rb +1 -1
  5. metadata +10 -205
  6. data/.gitignore +0 -15
  7. data/.rspec +0 -2
  8. data/.travis.yml +0 -10
  9. data/.yardopts +0 -10
  10. data/Gemfile +0 -14
  11. data/LICENSE +0 -176
  12. data/README.md +0 -425
  13. data/Rakefile +0 -52
  14. data/spec/core/association_spec.rb +0 -256
  15. data/spec/core/bulk_actions_spec.rb +0 -69
  16. data/spec/core/client_spec.rb +0 -280
  17. data/spec/core/collection_spec.rb +0 -901
  18. data/spec/core/configuration_spec.rb +0 -28
  19. data/spec/core/create_resource_spec.rb +0 -39
  20. data/spec/core/data_namespace_spec.rb +0 -15
  21. data/spec/core/data_resource_spec.rb +0 -239
  22. data/spec/core/inflection_spec.rb +0 -7
  23. data/spec/core/lru_cache_spec.rb +0 -26
  24. data/spec/core/middleware/request/encode_json_spec.rb +0 -73
  25. data/spec/core/middleware/request/etag_cache_spec.rb +0 -21
  26. data/spec/core/middleware/request/retry_spec.rb +0 -49
  27. data/spec/core/middleware/request/test.jpg +0 -0
  28. data/spec/core/middleware/request/upload_spec.rb +0 -164
  29. data/spec/core/middleware/response/callback_spec.rb +0 -17
  30. data/spec/core/middleware/response/deflate_spec.rb +0 -21
  31. data/spec/core/middleware/response/gzip_spec.rb +0 -25
  32. data/spec/core/middleware/response/parse_iso_dates_spec.rb +0 -44
  33. data/spec/core/middleware/response/parse_json_spec.rb +0 -53
  34. data/spec/core/middleware/response/raise_error_spec.rb +0 -128
  35. data/spec/core/middleware/response/sanitize_response_spec.rb +0 -19
  36. data/spec/core/read_resource_spec.rb +0 -97
  37. data/spec/core/resource_spec.rb +0 -541
  38. data/spec/core/resources/automation_spec.rb +0 -81
  39. data/spec/core/resources/macro_spec.rb +0 -27
  40. data/spec/core/resources/trigger_spec.rb +0 -67
  41. data/spec/core/resources/view_spec.rb +0 -97
  42. data/spec/core/search_spec.rb +0 -23
  43. data/spec/core/spec_helper.rb +0 -162
  44. data/spec/core/trackie_spec.rb +0 -129
  45. data/spec/fixtures/Argentina.gif +0 -0
  46. data/spec/fixtures/Argentina2.gif +0 -0
  47. data/spec/fixtures/credentials.yml.example +0 -3
  48. data/spec/fixtures/sample_app.zip +0 -0
  49. data/spec/fixtures/test_resources.rb +0 -22
  50. data/spec/fixtures/zendesk.rb +0 -109
  51. data/spec/live/Readme.md +0 -4
  52. data/spec/live/activity_spec.rb +0 -12
  53. data/spec/live/app_installation_spec.rb +0 -58
  54. data/spec/live/app_spec.rb +0 -58
  55. data/spec/live/audit_spec.rb +0 -15
  56. data/spec/live/automation_spec.rb +0 -23
  57. data/spec/live/bookmark_spec.rb +0 -11
  58. data/spec/live/brand_spec.rb +0 -14
  59. data/spec/live/category_spec.rb +0 -12
  60. data/spec/live/collection_spec.rb +0 -64
  61. data/spec/live/custom_role_spec.rb +0 -5
  62. data/spec/live/dynamic_content/item_spec.rb +0 -16
  63. data/spec/live/dynamic_content/variant_spec.rb +0 -19
  64. data/spec/live/forum_spec.rb +0 -14
  65. data/spec/live/forum_subscription_spec.rb +0 -12
  66. data/spec/live/group_membership_spec.rb +0 -18
  67. data/spec/live/group_spec.rb +0 -32
  68. data/spec/live/identity_spec.rb +0 -14
  69. data/spec/live/locale_spec.rb +0 -9
  70. data/spec/live/macro_spec.rb +0 -44
  71. data/spec/live/organization_field_spec.rb +0 -12
  72. data/spec/live/organization_membership_spec.rb +0 -11
  73. data/spec/live/organization_spec.rb +0 -12
  74. data/spec/live/push_notification_device_spec.rb +0 -21
  75. data/spec/live/request_spec.rb +0 -38
  76. data/spec/live/satisfaction_rating_spec.rb +0 -6
  77. data/spec/live/setting_spec.rb +0 -25
  78. data/spec/live/suspended_ticket_spec.rb +0 -8
  79. data/spec/live/tag_spec.rb +0 -58
  80. data/spec/live/target_spec.rb +0 -17
  81. data/spec/live/ticket_field_spec.rb +0 -12
  82. data/spec/live/ticket_form_spec.rb +0 -14
  83. data/spec/live/ticket_metrics_spec.rb +0 -6
  84. data/spec/live/ticket_spec.rb +0 -136
  85. data/spec/live/topic_comment_spec.rb +0 -52
  86. data/spec/live/topic_spec.rb +0 -46
  87. data/spec/live/topic_subscription_spec.rb +0 -12
  88. data/spec/live/topic_vote_spec.rb +0 -13
  89. data/spec/live/trigger_spec.rb +0 -23
  90. data/spec/live/upload_spec.rb +0 -10
  91. data/spec/live/user_field_spec.rb +0 -12
  92. data/spec/live/user_spec.rb +0 -71
  93. data/spec/live/user_view_spec.rb +0 -16
  94. data/spec/live/view_spec.rb +0 -22
  95. data/spec/live/voice/phone_number_spec.rb +0 -13
  96. data/spec/macros/resource_macros.rb +0 -169
  97. data/zendesk_api.gemspec +0 -38
@@ -1,49 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Request::Retry do
4
- def runtime
5
- start = Time.now.to_f
6
- yield
7
- Time.now.to_f - start
8
- end
9
-
10
- [429, 503].each do |error_code|
11
- it "should wait requisite seconds and then retry request on #{error_code}" do
12
- stub_request(:get, %r{blergh}).
13
- to_return(:status => 429, :headers => { :retry_after => 1 }).
14
- to_return(:status => 200)
15
-
16
- seconds = runtime {
17
- expect(client.connection.get("blergh").status).to eq(200)
18
- }
19
-
20
- expect(seconds).to be_within(0.2).of(1)
21
- end
22
- end
23
-
24
- context "with failing request", :prevent_logger_changes do
25
- before do
26
- stub_request(:get, %r{blergh}).
27
- to_return(:status => 503).
28
- to_return(:status => 200)
29
-
30
- expect_any_instance_of(ZendeskAPI::Middleware::Request::Retry).to receive(:sleep).exactly(10).times.with(1)
31
- end
32
-
33
- it "should wait default timeout seconds and then retry request on error" do
34
- expect(runtime {
35
- expect(client.connection.get("blergh").status).to eq(200)
36
- }).to be <= 0.5
37
- end
38
-
39
- it "should print to logger" do
40
- expect(client.config.logger).to receive(:warn).at_least(:once)
41
- client.connection.get("blergh")
42
- end
43
-
44
- it "should not fail without a logger" do
45
- client.config.logger = false
46
- client.connection.get("blergh")
47
- end
48
- end
49
- end
@@ -1,164 +0,0 @@
1
- require 'core/spec_helper'
2
- require 'tempfile'
3
- require 'action_dispatch'
4
-
5
- describe ZendeskAPI::Middleware::Request::Upload do
6
- subject { ZendeskAPI::Middleware::Request::Upload.new(lambda {|env| env}) }
7
- let(:filename) { File.join(File.dirname(__FILE__), "test.jpg") }
8
-
9
- it "should handle no body" do
10
- expect(subject.call({})).to eq({})
11
- end
12
-
13
- it "should handle body with no file" do
14
- expect(subject.call(:body => {})[:body]).to eq({})
15
- end
16
-
17
- it "should handle invalid types" do
18
- expect(subject.call(:body => { :file => :invalid })[:body]).to eq({})
19
- end
20
-
21
- context "with file string" do
22
- before(:each) do
23
- @env = subject.call(:body => { :file => filename })
24
- end
25
-
26
- it "should convert file string to UploadIO" do
27
- expect(@env[:body][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
28
- end
29
-
30
- it "should remove file string" do
31
- expect(@env[:body][:file]).to be_nil
32
- end
33
-
34
- it "should add filename if none exist" do
35
- expect(@env[:body][:filename]).to eq("test.jpg")
36
- end
37
-
38
- context "with filename" do
39
- before(:each) do
40
- @env = subject.call(:body => { :file => filename, :filename => "test" })
41
- end
42
-
43
- it "should not change filename" do
44
- expect(@env[:body][:filename]).to_not eq("test.jpg")
45
- end
46
- end
47
- end
48
-
49
- context "with an ActionDispatch::Http::UploadedFile" do
50
- before(:each) do
51
- @upload = ActionDispatch::Http::UploadedFile.new(:filename => "hello.jpg", :tempfile => Tempfile.new(['hello', '.jpg']))
52
- @env = subject.call(:body => { :file => @upload })
53
- end
54
-
55
- it "should convert file string to UploadIO" do
56
- expect(@env[:body][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
57
- end
58
-
59
- it "should remove file string" do
60
- expect(@env[:body][:file]).to be_nil
61
- end
62
-
63
- it "should add filename if none exist" do
64
- expect(@env[:body][:filename]).to eq("hello.jpg")
65
- end
66
-
67
- it "should use the content type of the tempfile" do
68
- expect(@env[:body][:uploaded_data].content_type).to eq("image/jpeg")
69
- end
70
-
71
- context "when path does not resolve a mime_type" do
72
- it "should pass correct filename to Faraday::UploadIO" do
73
- expect(@env[:body][:filename]).to eq("hello.jpg")
74
- expect(@env[:body][:uploaded_data].original_filename).to eq(@env[:body][:filename])
75
- end
76
-
77
- it "should use the content_type of ActionDispatch::Http::UploadedFile " do
78
- @upload.content_type = 'application/random'
79
-
80
- env = subject.call(:body => { :file => @upload })
81
- expect(env[:body][:uploaded_data].content_type).to eq('application/random')
82
- end
83
- end
84
- end
85
-
86
- context "with a Tempfile" do
87
- before(:each) do
88
- @tempfile = Tempfile.new(File.basename(filename))
89
- @env = subject.call(:body => { :file => @tempfile })
90
- end
91
-
92
- it "should convert file string to UploadIO" do
93
- expect(@env[:body][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
94
- end
95
-
96
- it "should remove file string" do
97
- expect(@env[:body][:file]).to be_nil
98
- end
99
-
100
- it "should add filename if none exist" do
101
- expect(@env[:body][:filename]).to eq(File.basename(@tempfile.path))
102
- end
103
- end
104
-
105
- context "with file instance" do
106
- context "top-level" do
107
- before(:each) do
108
- @env = subject.call(:body => { :file => File.new(filename) })
109
- end
110
-
111
- it "should convert file string to UploadIO" do
112
- expect(@env[:body][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
113
- end
114
-
115
- it "should remove file string" do
116
- expect(@env[:body][:file]).to be_nil
117
- end
118
-
119
- it "should add filename if none exist" do
120
- expect(@env[:body][:filename]).to eq("test.jpg")
121
- end
122
-
123
- context "with filename" do
124
- before(:each) do
125
- @env = subject.call(:body => { :file => File.new(filename), :filename => "test" })
126
- end
127
-
128
- it "should not change filename" do
129
- expect(@env[:body][:filename]).to_not eq("test.jpg")
130
- end
131
- end
132
- end
133
-
134
- context "underneath a key" do
135
- context "only a file" do
136
- before(:each) do
137
- @env = subject.call(:body => { :user => { :photo => File.new(filename) } })
138
- end
139
-
140
- it "should convert file string to UploadIO" do
141
- expect(@env[:body][:user][:photo][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
142
- end
143
-
144
- it "should add filename if none exist" do
145
- expect(@env[:body][:user][:photo][:filename]).to eq("test.jpg")
146
- end
147
- end
148
-
149
- context "with filename" do
150
- before(:each) do
151
- @env = subject.call(:body => { :user => { :photo => { :file => File.new(filename), :filename => "test" } } })
152
- end
153
-
154
- it "should convert file string to UploadIO" do
155
- expect(@env[:body][:user][:photo][:uploaded_data]).to be_instance_of(Faraday::UploadIO)
156
- end
157
-
158
- it "should not change filename" do
159
- expect(@env[:body][:user][:photo][:filename]).to_not eq("test.jpg")
160
- end
161
- end
162
- end
163
- end
164
- end
@@ -1,17 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::Callback do
4
- let(:response) { "TEST" }
5
-
6
- before(:each) do
7
- client.insert_callback do |env|
8
- env[:body] = response
9
- end
10
-
11
- stub_request(:get, %r{test_endpoint}).to_return(:body => JSON.dump({ "ABC" => "DEF" }))
12
- end
13
-
14
- it "should call callbacks " do
15
- expect(client.connection.get("test_endpoint").body).to eq(response)
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::Deflate do
4
- context "with content-encoding = 'deflate'" do
5
- subject { '{ "TESTDATA": true }' }
6
-
7
- before(:each) do
8
- stub_request(:get, %r{blergh}).to_return(
9
- :headers => {
10
- :content_encoding => "deflate",
11
- :content_type => "application/json"
12
- },
13
- :body => Zlib::Deflate.deflate(subject)
14
- )
15
- end
16
-
17
- it "should inflate returned body" do
18
- expect(client.connection.get("blergh").body['TESTDATA']).to be(true)
19
- end
20
- end
21
- end
@@ -1,25 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::Gzip do
4
- context "with content-encoding = 'gzip'" do
5
- subject { '{ "TESTDATA": true }' }
6
- before(:each) do
7
- encoded_data = StringIO.new
8
- gz = Zlib::GzipWriter.new(encoded_data)
9
- gz.write(subject)
10
- gz.close
11
-
12
- stub_request(:get, %r{blergh}).to_return(
13
- :headers => {
14
- :content_encoding => "gzip",
15
- :content_type => "application/json"
16
- },
17
- :body => encoded_data.string
18
- )
19
- end
20
-
21
- it "should inflate returned body" do
22
- expect(client.connection.get("blergh").body['TESTDATA']).to be(true)
23
- end
24
- end
25
- end
@@ -1,44 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::ParseIsoDates do
4
- def fake_response(data)
5
- stub_json_request(:get, %r{blergh}, data)
6
- response = client.connection.get("blergh")
7
- expect(response.status).to eq(200)
8
- response
9
- end
10
-
11
- let(:parsed){
12
- if RUBY_VERSION > "1.9"
13
- "2012-02-01 13:14:15 UTC"
14
- else
15
- "Wed Feb 01 13:14:15 UTC 2012"
16
- end
17
- }
18
-
19
- it "should parse dates" do
20
- expect(fake_response('{"x":"2012-02-01T13:14:15Z"}').body["x"].to_s).to eq(parsed)
21
- end
22
-
23
- it "should parse nested dates in hash" do
24
- expect(fake_response('{"x":{"y":"2012-02-01T13:14:15Z"}}').body["x"]["y"].to_s).to eq(parsed)
25
- end
26
-
27
- it "should parse nested dates in arrays" do
28
- expect(fake_response('{"x":[{"y":"2012-02-01T13:14:15Z"}]}').body["x"][0]["y"].to_s).to eq(parsed)
29
- end
30
-
31
- it "should not blow up on empty body" do
32
- expect(fake_response('').body).to eq('')
33
- end
34
-
35
- it "should leave arrays with ids alone" do
36
- expect(fake_response('{"x":[1,2,3]}').body).to eq({"x" => [1,2,3]})
37
- end
38
-
39
- it "should not parse date-like things" do
40
- expect(fake_response('{"x":"2012-02-01T13:14:15Z bla"}').body["x"].to_s).to eq("2012-02-01T13:14:15Z bla")
41
- expect(fake_response('{"x":"12012-02-01T13:14:15Z"}').body["x"].to_s).to eq("12012-02-01T13:14:15Z")
42
- expect(fake_response(%Q{{"x":"2012-02-01T13:14:15Z\\nfoo"}}).body["x"].to_s).to eq("2012-02-01T13:14:15Z\nfoo")
43
- end
44
- end
@@ -1,53 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::ParseJson do
4
- context "with another content-type" do
5
- before(:each) do
6
- stub_request(:get, %r{blergh}).to_return(
7
- :headers => {
8
- :content_type => "application/xml"
9
- },
10
- :body => '<nope></nope>'
11
- )
12
- end
13
-
14
- it "should not return nil body" do
15
- expect(client.connection.get("blergh").body).to eql('<nope></nope>')
16
- end
17
- end
18
-
19
- context "with content-type = 'application/json'" do
20
- before(:each) do
21
- stub_request(:get, %r{blergh}).to_return(
22
- :headers => {
23
- :content_type => "application/json"
24
- },
25
- :body => body
26
- )
27
- end
28
-
29
- context "with a nil body" do
30
- let(:body) { nil }
31
-
32
- it "should return empty body" do
33
- expect(client.connection.get("blergh").body).to eql('')
34
- end
35
- end
36
-
37
- context "with a empty body" do
38
- let(:body) { '' }
39
-
40
- it "should return empty body" do
41
- expect(client.connection.get("blergh").body).to eql('')
42
- end
43
- end
44
-
45
- context 'proper json' do
46
- let(:body) { '{ "TESTDATA": true }' }
47
-
48
- it "should parse returned body" do
49
- expect(client.connection.get("blergh").body['TESTDATA']).to be(true)
50
- end
51
- end
52
- end
53
- end
@@ -1,128 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Middleware::Response::RaiseError do
4
- context "with a failed connection" do
5
- context "connection failed" do
6
- before(:each) do
7
- stub_request(:any, /.*/).to_raise(Faraday::Error::ConnectionFailed)
8
- end
9
-
10
- it "should raise NetworkError" do
11
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
12
- end
13
- end
14
-
15
- context "connection timeout" do
16
- before(:each) do
17
- stub_request(:any, /.*/).to_timeout
18
- end
19
-
20
- it "should raise NetworkError" do
21
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
22
- end
23
- end
24
- end
25
-
26
- context "status errors" do
27
- let(:body) { "" }
28
-
29
- before(:each) do
30
- stub_request(:any, /.*/).to_return(:status => status, :body => body,
31
- :headers => { :content_type => "application/json" })
32
- end
33
-
34
- context "with status = 404" do
35
- let(:status) { 404 }
36
-
37
- it "should raise RecordNotFound when status is 404" do
38
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::RecordNotFound)
39
- end
40
- end
41
-
42
- context "with status in 400...600" do
43
- let(:status) { 500 }
44
-
45
- it "should raise NetworkError" do
46
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
47
- end
48
- end
49
-
50
- context "with status in 1XX" do
51
- let(:status) { 100 }
52
-
53
- it "should raise NetworkError" do
54
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
55
- end
56
- end
57
-
58
- context "with status = 304" do
59
- let(:status) { 304 }
60
-
61
- it "should not raise" do
62
- client.connection.get "/abcdef"
63
- end
64
- end
65
-
66
- context "with status in 3XX" do
67
- let(:status) { 302 }
68
-
69
- it "should raise NetworkError" do
70
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::NetworkError)
71
- end
72
- end
73
-
74
- context "with status = 422" do
75
- let(:status) { 422 }
76
-
77
- it "should raise RecordInvalid" do
78
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::RecordInvalid)
79
- end
80
-
81
- context "with a body" do
82
- let(:body) { JSON.dump(:details => "hello") }
83
-
84
- it "should return RecordInvalid with proper message" do
85
- begin
86
- client.connection.get "/non_existent"
87
- rescue ZendeskAPI::Error::RecordInvalid => e
88
- expect(e.errors).to eq("hello")
89
- expect(e.to_s).to eq("ZendeskAPI::Error::RecordInvalid: hello")
90
- else
91
- fail # didn't raise an error
92
- end
93
- end
94
- end
95
- end
96
-
97
- context "with status = 413" do
98
- let(:status) { 413 }
99
-
100
- it "should raise RecordInvalid" do
101
- expect { client.connection.get "/non_existent" }.to raise_error(ZendeskAPI::Error::RecordInvalid)
102
- end
103
-
104
- context "with a body" do
105
- let(:body) { JSON.dump(:description => "big file is big") }
106
-
107
- it "should return RecordInvalid with proper message" do
108
- begin
109
- client.connection.get "/non_existent"
110
- rescue ZendeskAPI::Error::RecordInvalid => e
111
- expect(e.errors).to eq("big file is big")
112
- expect(e.to_s).to eq("ZendeskAPI::Error::RecordInvalid: big file is big")
113
- else
114
- fail # didn't raise an error
115
- end
116
- end
117
- end
118
- end
119
-
120
- context "with status = 200" do
121
- let(:status) { 200 }
122
-
123
- it "should not raise" do
124
- client.connection.get "/abcdef"
125
- end
126
- end
127
- end
128
- end