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,81 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Automation do
4
- def valid_attributes
5
- {
6
- :title => "my test automation",
7
- :conditions => {
8
- :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
- :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
- },
11
- :actions => [{ :field => "priority", :value => "urgent" }],
12
- }
13
- end
14
-
15
- subject do
16
- described_class.new(double, valid_attributes)
17
- end
18
-
19
- describe "#all_conditions=" do
20
- it "should assign new values to all conditions" do
21
- new_conditions = [
22
- { "field" => "type", "operator" => "is", "value" => "question" },
23
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
24
- ]
25
- subject.all_conditions = new_conditions
26
-
27
- expect(subject.conditions[:all]).to eq(new_conditions)
28
- end
29
- end
30
-
31
- describe "#any_conditions=" do
32
- it "should assign new values to any conditions" do
33
- new_conditions = [
34
- { "field" => "type", "operator" => "is", "value" => "question" },
35
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
36
- ]
37
- subject.any_conditions = new_conditions
38
-
39
- expect(subject.conditions[:any]).to eq(new_conditions)
40
- end
41
- end
42
-
43
- describe "#add_all_condition" do
44
- it "should add a condition to all condition" do
45
- new_condition = { :field => "type", :operator => "is", :value => "problem" }
46
- existing_conditions = subject.conditions[:all]
47
-
48
- expect(existing_conditions).not_to include(new_condition)
49
-
50
- subject.add_all_condition("type", "is", "problem")
51
-
52
- expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
53
- end
54
- end
55
-
56
- describe "#add_any_condition" do
57
- it "should add a condition to any condition" do
58
- new_condition = { :field => "type", :operator => "is", :value => "task" }
59
- existing_conditions = subject.conditions[:any]
60
-
61
- expect(existing_conditions).not_to include(new_condition)
62
-
63
- subject.add_any_condition("type", "is", "task")
64
-
65
- expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
66
- end
67
- end
68
-
69
- describe "#add_action" do
70
- it "should add an action to the current actions" do
71
- new_action = { :field => "status", :value => "solved" }
72
- existing_actions = subject.actions
73
-
74
- expect(existing_actions).not_to include(new_action)
75
-
76
- subject.add_action("status", "solved")
77
-
78
- expect(subject.actions).to eq(existing_actions << new_action)
79
- end
80
- end
81
- end
@@ -1,27 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Macro do
4
- def valid_attributes
5
- {
6
- :title => "my test macro",
7
- :actions => [{ :field => "priority", :value => "urgent" }],
8
- }
9
- end
10
-
11
- subject do
12
- described_class.new(double, valid_attributes)
13
- end
14
-
15
- describe "#add_action" do
16
- it "should add an action to the current actions" do
17
- new_action = { :field => "status", :value => "solved" }
18
- existing_actions = subject.actions
19
-
20
- expect(existing_actions).not_to include(new_action)
21
-
22
- subject.add_action("status", "solved")
23
-
24
- expect(subject.actions).to eq(existing_actions << new_action)
25
- end
26
- end
27
- end
@@ -1,67 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Trigger do
4
- def valid_attributes
5
- {
6
- :title => "my test trigger",
7
- :conditions => {
8
- :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
- :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
- },
11
- }
12
- end
13
-
14
- subject do
15
- described_class.new(double, valid_attributes)
16
- end
17
-
18
- describe "#all_conditions=" do
19
- it "should assign new values to all conditions" do
20
- new_conditions = [
21
- { "field" => "type", "operator" => "is", "value" => "question" },
22
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
23
- ]
24
- subject.all_conditions = new_conditions
25
-
26
- expect(subject.conditions[:all]).to eq(new_conditions)
27
- end
28
- end
29
-
30
- describe "#any_conditions=" do
31
- it "should assign new values to any conditions" do
32
- new_conditions = [
33
- { "field" => "type", "operator" => "is", "value" => "question" },
34
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
35
- ]
36
- subject.any_conditions = new_conditions
37
-
38
- expect(subject.conditions[:any]).to eq(new_conditions)
39
- end
40
- end
41
-
42
- describe "#add_all_condition" do
43
- it "should add a condition to all condition" do
44
- new_condition = { :field => "type", :operator => "is", :value => "problem" }
45
- existing_conditions = subject.conditions[:all]
46
-
47
- expect(existing_conditions).not_to include(new_condition)
48
-
49
- subject.add_all_condition("type", "is", "problem")
50
-
51
- expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
52
- end
53
- end
54
-
55
- describe "#add_any_condition" do
56
- it "should add a condition to any condition" do
57
- new_condition = { :field => "type", :operator => "is", :value => "task" }
58
- existing_conditions = subject.conditions[:any]
59
-
60
- expect(existing_conditions).not_to include(new_condition)
61
-
62
- subject.add_any_condition("type", "is", "task")
63
-
64
- expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
65
- end
66
- end
67
- end
@@ -1,97 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::View do
4
- def valid_attributes
5
- {
6
- :title => "my test view",
7
- :conditions => {
8
- :any => [{ :field => "assignee_id", :operator => "is", :value => 1}],
9
- :all => [{ :field => "status", :operator => "is", :value => "open" }]
10
- },
11
- :execution => {
12
- :columns => [:id => "status", :title=> "Status"]
13
- }
14
- }
15
- end
16
-
17
- subject do
18
- described_class.new(double, valid_attributes)
19
- end
20
-
21
- describe "#columns=" do
22
- it "should add a single column" do
23
- new_column = ["priority"]
24
- subject.columns = new_column
25
-
26
- expect(subject.output["columns"]).to eq(new_column)
27
- end
28
-
29
- it "should set columns on output" do
30
- new_columns = ["type", "priority"]
31
- subject.columns = new_columns
32
-
33
- expect(subject.output["columns"]).to eq(new_columns)
34
- end
35
- end
36
-
37
- describe "#add_column" do
38
- it "should add a column to the existing columns" do
39
- existing_columns = subject.execution.columns.map {|c| c["id"]}
40
- expect(existing_columns.include?("type")).to eq(false)
41
-
42
- subject.add_column("type")
43
-
44
- expect(subject.output["columns"]).to eq(existing_columns << "type")
45
- end
46
- end
47
-
48
- describe "#all_conditions=" do
49
- it "should assign new values to all conditions" do
50
- new_conditions = [
51
- { "field" => "type", "operator" => "is", "value" => "question" },
52
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
53
- ]
54
- subject.all_conditions = new_conditions
55
-
56
- expect(subject.conditions[:all]).to eq(new_conditions)
57
- end
58
- end
59
-
60
- describe "#any_conditions=" do
61
- it "should assign new values to any conditions" do
62
- new_conditions = [
63
- { "field" => "type", "operator" => "is", "value" => "question" },
64
- { "field" => "status", "operator" => "less_than", "value" => "solved" }
65
- ]
66
- subject.any_conditions = new_conditions
67
-
68
- expect(subject.conditions[:any]).to eq(new_conditions)
69
- end
70
- end
71
-
72
- describe "#add_all_condition" do
73
- it "should add a condition to all condition" do
74
- new_condition = { :field => "type", :operator => "is", :value => "problem" }
75
- existing_conditions = subject.conditions[:all]
76
-
77
- expect(existing_conditions).not_to include(new_condition)
78
-
79
- subject.add_all_condition("type", "is", "problem")
80
-
81
- expect(subject.conditions[:all]).to eq(existing_conditions << new_condition)
82
- end
83
- end
84
-
85
- describe "#add_any_condition" do
86
- it "should add a condition to any condition" do
87
- new_condition = { :field => "type", :operator => "is", :value => "task" }
88
- existing_conditions = subject.conditions[:any]
89
-
90
- expect(existing_conditions).not_to include(new_condition)
91
-
92
- subject.add_any_condition("type", "is", "task")
93
-
94
- expect(subject.conditions[:any]).to eq(existing_conditions << new_condition)
95
- end
96
- end
97
- end
@@ -1,23 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Search do
4
- context ".new" do
5
- context "when given an existing class" do
6
- it "should return the correct class" do
7
- expect(ZendeskAPI::Search.new(nil, { "result_type" => "user" })).to be_instance_of(ZendeskAPI::User)
8
- end
9
- end
10
-
11
- context "when given a nonexistent class" do
12
- it "should return an object of the type Search::Result" do
13
- expect(ZendeskAPI::Search.new(nil, { "result_type" => "blah" })).to be_instance_of(ZendeskAPI::Search::Result)
14
- end
15
- end
16
-
17
- context "when not given anything" do
18
- it "should return an object of the type Search::Result" do
19
- expect(ZendeskAPI::Search.new(nil, {})).to be_instance_of(ZendeskAPI::Search::Result)
20
- end
21
- end
22
- end
23
- end
@@ -1,162 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), "macros"))
2
-
3
- ENV['TZ'] = 'CET' # something that is not local and not utc so we find all the bugs
4
-
5
- if RUBY_VERSION =~ /1.9/ && ENV["COVERAGE"]
6
- require 'simplecov'
7
- SimpleCov.start do
8
- add_filter "spec/"
9
- end
10
- end
11
-
12
- require 'zendesk_api'
13
- require 'vcr'
14
- require 'logger'
15
- require 'stringio'
16
-
17
- begin
18
- require 'byebug'
19
- rescue LoadError
20
- end
21
-
22
- class String
23
- def encoding_aware?; false; end
24
- end
25
-
26
- require File.join(File.dirname(__FILE__), '..', 'macros', 'resource_macros')
27
- require File.join(File.dirname(__FILE__), '..', 'fixtures', 'zendesk')
28
- require File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_resources')
29
-
30
- $credentials_warning = false
31
-
32
- # tests fail when this is included in a Module (someone else also defines client)
33
- def client
34
- credentials = File.join(File.dirname(__FILE__), '..', 'fixtures', 'credentials.yml')
35
- @client ||= begin
36
- client = ZendeskAPI::Client.new do |config|
37
- if File.exist?(credentials)
38
- data = YAML.load(File.read(credentials))
39
- config.username = data["username"]
40
-
41
- if data["token"]
42
- config.access_token = data["token"]
43
- config.url_based_access_token = true
44
- else
45
- config.password = data["password"]
46
- end
47
-
48
- if data["auth"]
49
- config.extend(Module.new do
50
- attr_accessor :authorization
51
-
52
- def options
53
- super.tap do |options|
54
- options[:headers].merge!(
55
- :authorization => "Basic #{Base64.urlsafe_encode64(authorization)}"
56
- )
57
- end
58
- end
59
- end)
60
- config.authorization = data["auth"]
61
- end
62
-
63
- config.url = data["url"]
64
-
65
- if data["url"].start_with?("http://")
66
- config.allow_http = true
67
- end
68
- else
69
- unless $credentials_warning
70
- STDERR.puts "using default credentials: live specs will fail."
71
- STDERR.puts "add your credentials to spec/fixtures/credentials.yml (see: spec/fixtures/credentials.yml.example)"
72
- $credentials_warning = true
73
- end
74
-
75
- config.username = "please.change"
76
- config.password = "me"
77
- config.url = "https://my.zendesk.com/api/v2"
78
- end
79
-
80
- config.retry = true
81
- end
82
-
83
- client.config.logger.level = (ENV["LOG"] ? Logger::DEBUG : Logger::WARN)
84
- client.config.cache.size = 0
85
- client.callbacks.clear
86
-
87
- client.insert_callback do |env|
88
- warning = env[:response_headers]["X-Zendesk-API-Warn"]
89
-
90
- if warning && warning !~ /\["access_token"\]/ && client.config.logger
91
- client.config.logger.warn "WARNING: #{warning}"
92
- end
93
- end
94
-
95
- client
96
- end
97
- end
98
-
99
- module TestHelper
100
- def silence_logger
101
- old_level = client.config.logger.level
102
- client.config.logger.level = 6
103
- yield
104
- ensure
105
- client.config.logger.level = old_level
106
- end
107
-
108
- def silence_stderr
109
- $stderr = File.new( '/dev/null', 'w' )
110
- yield
111
- ensure
112
- $stderr = STDERR
113
- end
114
-
115
- def json(body = {})
116
- JSON.dump(body)
117
- end
118
-
119
- def stub_json_request(verb, path_matcher, body = json, options = {})
120
- stub_request(verb, path_matcher).to_return(Hashie::Mash.new(
121
- :body => body, :headers => { :content_type => "application/json", :content_length => body.size }
122
- ).deep_merge(options))
123
- end
124
- end
125
-
126
- RSpec.configure do |c|
127
- c.before(:each) do
128
- ZendeskAPI::TestResource.associations.clear
129
- ZendeskAPI::TestResource.has_many :children, :class => ZendeskAPI::TestResource::TestChild
130
- end
131
-
132
- c.before(:each) do
133
- WebMock.reset!
134
- end
135
-
136
- c.around(:each, :silence_logger) do |example|
137
- silence_logger{ example.call }
138
- end
139
-
140
- c.around(:each, :prevent_logger_changes) do |example|
141
- begin
142
- old_logger = client.config.logger
143
- example.call
144
- ensure
145
- client.config.logger = old_logger
146
- end
147
- end
148
-
149
- c.extend ResourceMacros
150
- c.extend ZendeskAPI::Fixtures
151
- c.include ZendeskAPI::Fixtures
152
- c.include TestHelper
153
- end
154
-
155
- VCR.configure do |c|
156
- c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'cassettes')
157
- c.default_cassette_options = { :record => :new_episodes, :decode_compressed_response => true, :serialize_with => :json, :preserve_exact_body_bytes => true }
158
- c.hook_into :webmock
159
- c.configure_rspec_metadata!
160
- end
161
-
162
- include WebMock::API