|
3 | 3 |
|
4 | 4 | RSpec.describe 'v3 service route bindings' do |
5 | 5 | describe 'GET /v3/service_route_bindings' do |
| 6 | + # Because route bindings don't have names, we can't use the 'paginated response' shared example |
| 7 | + describe 'behaving like a paginated resource' do |
| 8 | + let!(:resources) { Array.new(2) { VCAP::CloudController::RouteBinding.make } } |
| 9 | + |
| 10 | + it 'returns pagination information' do |
| 11 | + get '/v3/service_route_bindings?per_page=1', nil, admin_headers |
| 12 | + |
| 13 | + expect(last_response).to have_status_code(200) |
| 14 | + expect_route_bindings([resources[0]]) |
| 15 | + |
| 16 | + expect(parsed_response['pagination']['total_results']).to eq(resources.length) |
| 17 | + expect(parsed_response['pagination']['total_pages']).to eq(resources.length) |
| 18 | + expect(parsed_response['pagination']['first']['href']).to include('/v3/service_route_bindings?page=1&per_page=1') |
| 19 | + expect(parsed_response['pagination']['next']['href']).to include('/v3/service_route_bindings?page=2&per_page=1') |
| 20 | + expect(parsed_response['pagination']['last']['href']).to include("/v3/service_route_bindings?page=#{resources.length}&per_page=1") |
| 21 | + end |
| 22 | + |
| 23 | + it 'keeps filtering information in links' do |
| 24 | + resources_guids = resources.map(&:guid) |
| 25 | + get "/v3/service_route_bindings?per_page=1&guids=#{resources_guids.join(',')}", nil, admin_headers |
| 26 | + |
| 27 | + expect(last_response).to have_status_code(200) |
| 28 | + expect_route_bindings([resources[0]]) |
| 29 | + |
| 30 | + expect(parsed_response['pagination']['next']['href']).to include("guids=#{resources_guids.join('%2C')}") |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + it_behaves_like 'request_spec_shared_examples.rb list query endpoint' do |
| 35 | + let(:request) { 'v3/service_route_bindings' } |
| 36 | + let(:message) { VCAP::CloudController::ServiceRouteBindingsListMessage } |
| 37 | + let(:user_header) { headers_for(user) } |
| 38 | + let(:params) do |
| 39 | + { |
| 40 | + include: 'route,service_instance', |
| 41 | + route_guids: %w(foo bar), |
| 42 | + service_instance_names: %w(foo bar), |
| 43 | + service_instance_guids: %w(foo bar), |
| 44 | + per_page: '10', |
| 45 | + page: 2, |
| 46 | + order_by: 'updated_at', |
| 47 | + label_selector: 'foo==bar', |
| 48 | + guids: 'foo,bar', |
| 49 | + created_ats: "#{Time.now.utc.iso8601},#{Time.now.utc.iso8601}", |
| 50 | + updated_ats: { gt: Time.now.utc.iso8601 }, |
| 51 | + } |
| 52 | + end |
| 53 | + end |
| 54 | + |
6 | 55 | describe 'no bindings to list' do |
7 | 56 | let(:api_call) { ->(user_headers) { get '/v3/service_route_bindings', nil, user_headers } } |
8 | 57 | let(:expected_codes_and_responses) do |
|
183 | 232 | expect(last_response).to have_status_code(400) |
184 | 233 | end |
185 | 234 | end |
| 235 | + |
| 236 | + describe 'order_by' do |
| 237 | + it_behaves_like 'list endpoint order_by timestamps', '/v3/service_route_bindings' do |
| 238 | + let(:resource_klass) { VCAP::CloudController::RouteBinding } |
| 239 | + end |
| 240 | + end |
186 | 241 | end |
187 | 242 |
|
188 | 243 | describe 'GET /v3/service_route_bindings/:guid' do |
|
0 commit comments