blob: ce728c41f48eb1a1420823029bdbe1ecc115ac28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# 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
it 'matches pipeline sha endpoint' do
result = match_route('/api/graphql', 'pipelines/sha/4asd12lla2jiwjdqw9as32glm8is8hiu8s2c5jsw')
expect(result).to be_present
expect(result.name).to eq 'ci_editor'
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
|