File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -356,10 +356,15 @@ def intentional_obp_request?
356356 Helpers . present? ( @options [ "page" ] ) && !cbp_request?
357357 end
358358
359+ def should_try_cbp? ( path_query_link )
360+ not_supported_endpoints = %w[ show_many ]
361+ not_supported_endpoints . none? { |endpoint | path_query_link . end_with? ( endpoint ) }
362+ end
363+
359364 def get_resources ( path_query_link )
360365 if intentional_obp_request?
361366 warn "Offset Based Pagination will be deprecated soon"
362- elsif @next_page . nil?
367+ elsif @next_page . nil? && should_try_cbp? ( path_query_link )
363368 @options_per_page_was = @options . delete ( "per_page" )
364369 # Default to CBP by using the page param as a map
365370 @options . page = { size : ( @options_per_page_was || DEFAULT_PAGE_SIZE ) }
Original file line number Diff line number Diff line change @@ -1004,6 +1004,17 @@ def to_proc
10041004 double ( "response" , body : cbp_response )
10051005 end
10061006
1007+ context "when we know for sure that the endpoint does not support CBP" do
1008+ before do
1009+ stub_json_request ( :get , %r{test_resources\/ show_many} , json ( :test_resources => [ { :id => 1 } ] ) )
1010+ end
1011+
1012+ it "does not try to default to CBP" do
1013+ subject . show_many . fetch
1014+ expect ( subject . instance_variable_get ( :@options ) [ "page" ] ) . to be_nil
1015+ end
1016+ end
1017+
10071018 context "when fetching a collection" do
10081019 before do
10091020 expect ( subject ) . to receive ( :get_response ) . with ( "test_resources" ) . and_return ( cbp_success_response )
You can’t perform that action at this time.
0 commit comments