Skip to content

Commit

Permalink
Merge pull request #582 from zendesk/fvilela/requested_tickets
Browse files Browse the repository at this point in the history
[RED-2366] Add CBP support to requested_tickets api/v2/users/:id/tickets/requested
  • Loading branch information
fbvilela authored Sep 4, 2024
2 parents 127d3f8 + 2ac92e7 commit e42474b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
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

0 comments on commit e42474b

Please sign in to comment.