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,58 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Tag, :vcr, :not_findable do
4
- [organization, topic, ticket].each do |object|
5
- under object do
6
- before(:each) do
7
- parent.tags = %w{tag2 tag3}
8
- parent.tags.save!
9
- end
10
-
11
- it "can be set" do
12
- expect(tags).to eq(%w{tag2 tag3})
13
- end
14
-
15
- it "should be removable" do
16
- parent.tags.destroy!(:id => "tag2")
17
-
18
- expect(tags).to eq(%w{tag3})
19
- end
20
-
21
- it "shouldn't re-save destroyed tags" do
22
- parent.tags.first.destroy!
23
- parent.tags.save!
24
-
25
- expect(tags).to eq(%w{tag3})
26
- end
27
-
28
- it "should be updatable" do
29
- parent.tags.update!(:id => "tag4")
30
-
31
- expect(tags).to eq(%w{tag2 tag3 tag4})
32
- end
33
-
34
- it "should be savable" do
35
- parent.tags << "tag4"
36
- parent.tags.save!
37
-
38
- expect(tags).to eq(%w{tag2 tag3 tag4})
39
- end
40
-
41
- it "should be modifiable" do
42
- parent.tags.delete(ZendeskAPI::Tag.new(nil, :id => "tag2"))
43
- parent.tags.save!
44
-
45
- expect(tags).to eq(%w{tag3})
46
-
47
- parent.tags.delete_if {|tag| tag.id == "tag3"}
48
- parent.tags.save!
49
-
50
- expect(tags).to be_empty
51
- end
52
- end
53
- end
54
-
55
- def tags
56
- parent.tags.fetch!(:reload).map(&:id).sort
57
- end
58
- end
@@ -1,17 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Target, :delete_after do
4
- def valid_attributes
5
- {
6
- :type => "email_target",
7
- :title => "Test Email Target",
8
- :email => "hello@example.com",
9
- :subject => "Test Target"
10
- }
11
- end
12
-
13
- it_should_be_readable :targets, :create => :true
14
- it_should_be_creatable
15
- it_should_be_updatable :email, "bye@example.com"
16
- it_should_be_deletable
17
- end
@@ -1,12 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::TicketField, :delete_after do
4
- def valid_attributes
5
- { :type => "text", :title => "Age" }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_updatable :title
10
- it_should_be_deletable
11
- it_should_be_readable :ticket_fields
12
- end
@@ -1,14 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::TicketForm, :delete_after do
4
- def valid_attributes
5
- { :name => "Ticket Form-o", :position => 9999, :active => false }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_updatable :name
10
- it_should_be_deletable :find => false # Deleted ticket forms are still returned from the show action
11
- it_should_be_readable :ticket_forms
12
-
13
- # TODO: clone
14
- end
@@ -1,6 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::TicketMetric do
4
- it_should_be_readable :ticket_metrics
5
- it_should_be_readable ticket, :metrics
6
- end
@@ -1,136 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Ticket do
4
- def valid_attributes
5
- {
6
- :type => "question",
7
- :subject => "This is a question?",
8
- :comment => { :value => "Indeed it is!" },
9
- :priority => "normal",
10
- :requester_id => user.id,
11
- :submitter_id => user.id,
12
- :collaborator_ids => [agent.id],
13
- :tags => ["awesome", "blossom"]
14
- }
15
- end
16
-
17
- it_should_be_creatable
18
- it_should_be_updatable :subject
19
- it_should_be_deletable
20
- it_should_be_readable :tickets
21
- it_should_be_readable user, :requested_tickets
22
- it_should_be_readable agent, :ccd_tickets
23
- it_should_be_readable organization, :tickets
24
-
25
- context "recent tickets" do
26
- before(:all) do
27
- VCR.use_cassette("visit_recent_ticket") do
28
- client.tickets.find(id: 1)
29
-
30
- sleep(5)
31
- end
32
- end
33
-
34
- it_should_be_readable :tickets, :recent
35
- end
36
-
37
- describe ".incremental_export" do
38
- let(:results) { ZendeskAPI::Ticket.incremental_export(client, Time.at(1023059503)) } # ~ 10 years ago
39
-
40
- around do |example|
41
- # 1 request every 5 minutes allowed <-> you can only test 1 call ...
42
- VCR.use_cassette("incremental_export") do
43
- client.config.retry = false
44
-
45
- example.call
46
-
47
- client.config.retry = true
48
- end
49
- end
50
-
51
- it "finds tickets after a old date" do
52
- expect(results.to_a.first).to be_an_instance_of ZendeskAPI::Ticket
53
- end
54
-
55
- it "is able to do next" do
56
- first = results.to_a.first
57
- stub_json_request(:get, %r{/api/v2/exports/tickets}, json(:results => []))
58
-
59
- results.next
60
- expect(results.first).to_not eq(first)
61
- end
62
- end
63
-
64
- describe ".import" do
65
- it "can import" do
66
- VCR.use_cassette("ticket_import_can_import") do
67
- old = Time.now - 5*365*24*60*60
68
- ticket = ZendeskAPI::Ticket.import(client, valid_attributes.merge(:created_at => old.iso8601))
69
- expect(ZendeskAPI::Ticket.find(client, :id => ticket.id).created_at.year).to eq(old.year)
70
- end
71
- end
72
-
73
- it "returns nothing if import fails" do
74
- VCR.use_cassette("ticket_import_cannot_import") do
75
- silence_logger { expect(ZendeskAPI::Ticket.import(client, {})).to eq(nil) }
76
- end
77
- end
78
- end
79
-
80
- it "can upload while creating" do
81
- VCR.use_cassette("ticket_inline_uploads") do
82
- ticket = ZendeskAPI::Ticket.new(client, valid_attributes)
83
- ticket.comment.uploads << "spec/fixtures/Argentina.gif"
84
- ticket.comment.uploads << File.new("spec/fixtures/Argentina.gif")
85
-
86
- ticket.save!
87
- expect(ticket.changes).to eq({}) # uploads were set before save
88
- expect(ticket.comment.attributes[:uploads].map(&:class)).to eq([String, String]) # upload was sent as tokens
89
- end
90
- end
91
-
92
- it "can comment while creating" do
93
- VCR.use_cassette("ticket_inline_comments") do
94
- ticket = ZendeskAPI::Ticket.new(client, valid_attributes)
95
- ticket.comment = ZendeskAPI::Ticket::Comment.new(client, :value => "My comment", :public => false)
96
- ticket.save!
97
-
98
- expect(ticket.changes).to eq({}) # comment was set before save
99
- expect(ticket.attributes[:comment]).to eq({"value" => "My comment", "public" => false})
100
- end
101
- end
102
-
103
- describe "import race condition" do
104
- let(:email) { "test+#{rand(100000)}@test.com" }
105
-
106
- it "should handle it" do
107
- VCR.use_cassette("ticket_import_race") do
108
- threads = []
109
-
110
- 3.times do
111
- threads << Thread.new do
112
- client.insert_callback do |response|
113
- Thread.current[:response] = response
114
- end
115
-
116
- ZendeskAPI::Ticket.import(client, :requester => { :email => email, :name => "Hello" }, :subject => "Test", :description => "Test")
117
- end
118
- end
119
-
120
- threads.map! do |thread|
121
- thread.join(5)
122
- fail("could not get response in 5 seconds") unless thread[:response]
123
- thread[:response][:status]
124
- end
125
-
126
- user = client.users.detect {|user| user.email == email}
127
- expect(user).to_not be_nil
128
-
129
- user.requested_tickets.each(&:destroy)
130
- user.destroy
131
-
132
- expect(threads.all? {|st| [201, 422, 409].include?(st)}).to be(true)
133
- end
134
- end
135
- end
136
- end
@@ -1,52 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Topic::TopicComment do
4
- def valid_attributes
5
- { :body => "Texty-text, text." }
6
- end
7
-
8
- under topic do
9
- it_should_be_creatable
10
- it_should_be_updatable :body
11
- it_should_be_deletable
12
- it_should_be_readable topic, :comments
13
- end
14
-
15
- describe ".import" do
16
- it "can import" do
17
- VCR.use_cassette("topic_comment_import_can_import") do
18
- old = Time.now - 4*365*24*60*60
19
- comment = ZendeskAPI::Topic::TopicComment.import(client, valid_attributes.merge(:created_at => old, :topic_id => topic.id))
20
- expect(ZendeskAPI::Topic::TopicComment.find(client, comment).created_at.year).to eq(old.year)
21
- end
22
- end
23
-
24
- it "returns nothing if import fails" do
25
- VCR.use_cassette("topic_comment_import_cannot_import") do
26
- silence_logger { expect(ZendeskAPI::Topic::TopicComment.import(client, {})).to eq(nil) }
27
- end
28
- end
29
- end
30
-
31
- it "can upload while creating" do
32
- VCR.use_cassette("topic_comment_inline_uploads") do
33
- comment = ZendeskAPI::Topic::TopicComment.new(client, valid_attributes.merge(:topic_id => topic.id))
34
- comment.uploads << "spec/fixtures/Argentina.gif"
35
- comment.uploads << File.new("spec/fixtures/Argentina.gif")
36
-
37
- comment.save!
38
- expect(comment.changes).to eq({}) # uploads were set before save
39
- expect(comment.attributes[:uploads].map(&:class)).to eq([String, String]) # upload was sent as tokens
40
- end
41
- end
42
- end
43
-
44
- describe ZendeskAPI::User::TopicComment do
45
- def valid_attributes
46
- { :body => "Texty-text, text."}
47
- end
48
-
49
- under current_user do
50
- it_should_be_readable current_user, :topic_comments
51
- end
52
- end
@@ -1,46 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Topic do
4
- def valid_attributes
5
- {
6
- :forum_id => forum.id, :title => "My Topic",
7
- :body => "The mayan calendar ends December 31st. Coincidence? I think not."
8
- }
9
- end
10
-
11
- it_should_be_creatable
12
- it_should_be_updatable :title
13
- it_should_be_deletable :create => true
14
- it_should_be_readable :topics
15
- it_should_be_readable current_user, :topics
16
- it_should_be_readable forum, :topics
17
- #it_should_be_readable :topics, :show_many, :verb => :post, :ids =>
18
-
19
- describe ".import" do
20
- it "can import" do
21
- VCR.use_cassette("topic_import_can_import") do
22
- old = Time.now - 5*365*24*60*60
23
- topic = ZendeskAPI::Topic.import(client, valid_attributes.merge(:created_at => old))
24
- expect(ZendeskAPI::Topic.find(client, topic).created_at.year).to eq(old.year)
25
- end
26
- end
27
-
28
- it "returns nothing if import fails" do
29
- VCR.use_cassette("topic_import_cannot_import") do
30
- silence_logger { expect(ZendeskAPI::Topic.import(client, {})).to eq(nil) }
31
- end
32
- end
33
- end
34
-
35
- it "can upload while creating" do
36
- VCR.use_cassette("topic_inline_uploads") do
37
- topic = ZendeskAPI::Topic.new(client, valid_attributes)
38
- topic.uploads << "spec/fixtures/Argentina.gif"
39
- topic.uploads << File.new("spec/fixtures/Argentina.gif")
40
-
41
- topic.save!
42
- expect(topic.changes).to eq({}) # uploads were set before save
43
- expect(topic.attributes[:uploads].map(&:class)).to eq([String, String]) # upload was sent as tokens
44
- end
45
- end
46
- end
@@ -1,12 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::TopicSubscription, :delete_after do
4
- def valid_attributes
5
- { :topic_id => topic.id, :user_id => user.id }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_deletable
10
- it_should_be_readable topic, :subscriptions, :create => true
11
- it_should_be_readable user, :topic_subscriptions, :create => true
12
- end
@@ -1,13 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Topic::TopicVote, :delete_after do
4
- def valid_attributes
5
- { :topic_id => topic.id }
6
- end
7
-
8
- under topic do
9
- it_should_be_creatable
10
- it_should_be_deletable
11
- it_should_be_readable topic, :votes, :create => true
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Trigger, :delete_after do
4
- def valid_attributes
5
- {
6
- :title => "my test trigger",
7
- :conditions => {
8
- :all => [{ :field => "status", :operator => "is", :value => "open" }]
9
- },
10
- :actions => [{ :field => "status", :value => "solved" }]
11
- }
12
- end
13
-
14
- it_should_be_readable :triggers
15
- it_should_be_readable :triggers, :active
16
-
17
- it_should_be_creatable
18
- it_should_be_updatable :conditions, {
19
- "any" => [],
20
- "all" => [{ "field" => "priority", "operator" => "is", "value" => "low" }]
21
- }
22
- it_should_be_deletable
23
- end
@@ -1,10 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::Upload, :not_findable do
4
- def valid_attributes
5
- { :file => "spec/fixtures/Argentina.gif" }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_deletable
10
- end
@@ -1,12 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::UserField, :delete_after do
4
- def valid_attributes
5
- { :type => "text", :title => "Age", :key => "age" }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_updatable :title, "key"
10
- it_should_be_deletable
11
- it_should_be_readable :user_fields, :create => true
12
- end
@@ -1,71 +0,0 @@
1
- require 'core/spec_helper'
2
-
3
- describe ZendeskAPI::User, :delete_after do
4
- def valid_attributes
5
- { :name => "Test U.", :email => "test@example.org" }
6
- end
7
-
8
- it_should_be_creatable
9
- it_should_be_updatable :name
10
- it_should_be_deletable :find => [:active?, false]
11
- it_should_be_readable :users
12
- it_should_be_readable organization, :users
13
-
14
- it "should be able to find by email" do
15
- VCR.use_cassette("user_find_by_email") do
16
- expect(client.users.search(:query => current_user.email).to_a).to eq([current_user])
17
- end
18
- end
19
-
20
- context "passwords", :vcr do
21
- let(:password) { client.config.password || ENV['PASSWORD'] }
22
-
23
- it "sets the password" do
24
- agent.set_password!(:password => password)
25
- end
26
-
27
- it "changes the password" do
28
- current_user.change_password!(:previous_password => password, :password => password)
29
- end
30
- end
31
-
32
- context "side-loading" do
33
- context "no permission set" do
34
- subject do
35
- VCR.use_cassette("user_admin_role") { client.users.find(:id => 20014182, :include => :roles) }
36
- end
37
-
38
- it "should include role" do
39
- if subject
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
-
46
- expect(subject.custom_role).to be_nil
47
- end
48
- end
49
- end
50
-
51
- context "permission set" do
52
- subject do
53
- VCR.use_cassette("user_permission_set") { client.users.find(:id => 20014327, :include => :roles) }
54
- end
55
-
56
- it "should include role" do
57
- if subject
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
-
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
- end
68
- end
69
- end
70
- end
71
- end