Skip to content

[RED-2366] Add CBP support to requested_tickets api/v2/users/:id/tickets/requested #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/zendesk_api/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions spec/core/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/live/cbp_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/live/organization_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions spec/live/user_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spec/macros/resource_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading