36 lines
1013 B
Ruby
36 lines
1013 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
RSpec.describe Gitlab::EtagCaching::Router do
|
|
describe '.match', :aggregate_failures do
|
|
context 'with RESTful routes' do
|
|
it 'matches project pipelines endpoint' do
|
|
result = match_route('/my-group/my-project/-/pipelines.json')
|
|
|
|
expect(result).to be_present
|
|
expect(result.name).to eq 'project_pipelines'
|
|
expect(result.router).to eq Gitlab::EtagCaching::Router::Restful
|
|
end
|
|
end
|
|
|
|
context 'with GraphQL routes' do
|
|
it 'matches pipelines endpoint' do
|
|
result = match_route('/api/graphql', 'pipelines/id/12')
|
|
|
|
expect(result).to be_present
|
|
expect(result.name).to eq 'pipelines_graph'
|
|
expect(result.router).to eq Gitlab::EtagCaching::Router::Graphql
|
|
end
|
|
end
|
|
end
|
|
|
|
def match_route(path, header = nil)
|
|
headers = { 'X-GITLAB-GRAPHQL-RESOURCE-ETAG' => header }.compact
|
|
|
|
described_class.match(
|
|
double(path_info: path, headers: headers)
|
|
)
|
|
end
|
|
end
|