diff --git a/lib/zendesk_api/resources.rb b/lib/zendesk_api/resources.rb
index 8f120410..12779f0d 100644
--- a/lib/zendesk_api/resources.rb
+++ b/lib/zendesk_api/resources.rb
@@ -463,7 +463,7 @@ class Ticket < Resource
extend DestroyMany
def self.cbp_path_regexes
- [/^tickets$/, %r{organizations/\d+/tickets}]
+ [/^tickets$/, %r{organizations/\d+/tickets}, %r{users/\d+/tickets/requested}]
end
# Unlike other attributes, "comment" is not a property of the ticket,
diff --git a/spec/core/spec_helper.rb b/spec/core/spec_helper.rb
index 8bf01c1f..f2c898f2 100644
--- a/spec/core/spec_helper.rb
+++ b/spec/core/spec_helper.rb
@@ -94,6 +94,10 @@ def options
end
end
+def random_string(length = 10)
+ ('a'..'z').to_a.shuffle.take(length).join
+end
+
module TestHelper
def silence_logger
old_level = client.config.logger.level
diff --git a/spec/live/cbp_support_spec.rb b/spec/live/cbp_support_spec.rb
index 89b8d890..639ce544 100644
--- a/spec/live/cbp_support_spec.rb
+++ b/spec/live/cbp_support_spec.rb
@@ -116,6 +116,18 @@
let(:collection) { organization.tickets }
end
end
+
+ describe '/users/:id/tickets/requested' do
+ let(:user) do
+ VCR.use_cassette("cbp_#{described_class}_user_fetch") do
+ client.users.fetch.first
+ end
+ end
+
+ it_behaves_like 'an endpoint that supports CBP' do
+ let(:collection) { user.requested_tickets }
+ end
+ end
end
describe ZendeskAPI::Ticket::Audit do
diff --git a/spec/live/organization_field_spec.rb b/spec/live/organization_field_spec.rb
index b8d301d1..7a8f8d01 100644
--- a/spec/live/organization_field_spec.rb
+++ b/spec/live/organization_field_spec.rb
@@ -2,11 +2,11 @@
describe ZendeskAPI::OrganizationField, :delete_after do
def valid_attributes
- { :type => "text", :title => "Age", :key => "age" }
+ { :type => "text", :title => "Age", :key => random_string(5) }
end
it_should_be_creatable
it_should_be_updatable :title, "key"
- it_should_be_deletable
it_should_be_readable :organization_fields, :create => true
+ it_should_be_deletable :marked_for_deletion => true
end
diff --git a/spec/live/user_field_spec.rb b/spec/live/user_field_spec.rb
index e7dfd3d2..3306d012 100644
--- a/spec/live/user_field_spec.rb
+++ b/spec/live/user_field_spec.rb
@@ -2,11 +2,11 @@
describe ZendeskAPI::UserField, :delete_after do
def valid_attributes
- { :type => "text", :title => "title_ruby_sdk_test", :key => 'ruby_sdk_test_key' }
+ { :type => "text", :title => random_string(20), :key => random_string(10) }
end
it_should_be_deletable
it_should_be_creatable
- it_should_be_updatable :title, "updated_title_ruby_sdk_test"
+ it_should_be_updatable :title, random_string(22)
it_should_be_readable :user_fields, :create => true
end
diff --git a/spec/macros/resource_macros.rb b/spec/macros/resource_macros.rb
index 7ed1f7d3..9a6564ab 100644
--- a/spec/macros/resource_macros.rb
+++ b/spec/macros/resource_macros.rb
@@ -37,7 +37,7 @@ def it_should_be_creatable(options = {})
end
after(:all) do
- return unless @creatable_object.id
+ return unless @creatable_object&.id
VCR.use_cassette("#{described_class.to_s}_create_delete") do
@creatable_object.destroy
@@ -81,7 +81,7 @@ def it_should_be_updatable(attribute, value = "TESTDATA", extra = {})
after(:all) do
VCR.use_cassette("#{described_class.to_s}_update_delete") do
- @updatable_object.destroy
+ @updatable_object&.destroy
end
end if metadata[:delete_after]
end
@@ -110,7 +110,7 @@ def it_should_be_deletable(options = {})
if options[:find]
expect(obj.send(options[:find].first)).to eq(options[:find].last)
else
- expect(obj).to be_nil
+ options[:marked_for_deletion] ? (expect(obj.active?).to be_falsey) : (expect(obj).to be_nil)
end
end
end