Skip to content

Commit

Permalink
add CBP support to requested_tickets api/v2/users/:id/tickets/requested
Browse files Browse the repository at this point in the history
  • Loading branch information
fbvilela committed Sep 1, 2024
1 parent 127d3f8 commit 9051c87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 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
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
2 changes: 1 addition & 1 deletion spec/live/organization_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def valid_attributes

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
end
8 changes: 6 additions & 2 deletions spec/macros/resource_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def it_should_be_creatable(options = {})

after(:all) do
return unless @creatable_object.id

VCR.use_cassette("#{described_class.to_s}_create_delete") do
@creatable_object.destroy
sleep(1)
end
end if metadata[:delete_after]
end
Expand Down Expand Up @@ -82,6 +82,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
sleep(1)
end
end if metadata[:delete_after]
end
Expand All @@ -93,6 +94,7 @@ def it_should_be_deletable(options = {})
if options[:object]
@deletable_object = options.delete(:object)
else
sleep(1)
VCR.use_cassette("#{described_class.to_s}_delete_create") do
@deletable_object = described_class.create!(client, valid_attributes.merge(default_options))
end
Expand All @@ -102,6 +104,7 @@ def it_should_be_deletable(options = {})
it "should be destroyable" do |example|
expect(@deletable_object.destroy).to be(true)
expect(@deletable_object.destroyed?).to be(true)
sleep(1)
if (!options.key?(:find) || options[:find]) && !example.metadata[:not_findable]
opts = default_options
opts.merge!(:id => @deletable_object.id) unless described_class.ancestors.include?(ZendeskAPI::SingularResource)
Expand All @@ -110,7 +113,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
expect(obj.nil? || !obj.active?).to eq(true)
end
end
end
Expand All @@ -133,6 +136,7 @@ def it_should_be_readable(*args)
after(:all) do
VCR.use_cassette("#{described_class.to_s}_#{context_name}_delete") do
@readable_object.destroy
sleep(1)
end
end if create

Expand Down

0 comments on commit 9051c87

Please sign in to comment.