diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-10 10:20:07 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-10 10:20:07 +0000 |
commit | ce6a48cbd0b297bf955206f6acb1da86c1fa4529 (patch) | |
tree | 1916d2fa90a5f2ce663427864101dd941c8aa070 /spec | |
parent | 94668490a141568dbab604540b843c54e6e6a7e5 (diff) | |
parent | f8dd11957ace6897e0273babfc87a6d02348388c (diff) | |
download | gitlab-ce-ce6a48cbd0b297bf955206f6acb1da86c1fa4529.tar.gz |
Merge branch 'test-all-etag-routes' into 'master'
Test all enabled routes in ETag caching middleware and fix pipeline routes
Closes #30563
See merge request !10535
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/etag_caching/router_spec.rb | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb new file mode 100644 index 00000000000..f3dacb4ef04 --- /dev/null +++ b/spec/lib/gitlab/etag_caching/router_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe Gitlab::EtagCaching::Router do + it 'matches issue notes endpoint' do + env = build_env( + '/my-group/and-subgroup/here-comes-the-project/noteable/issue/1/notes' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'issue_notes' + end + + it 'matches issue title endpoint' do + env = build_env( + '/my-group/my-project/issues/123/rendered_title' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'issue_title' + end + + it 'matches project pipelines endpoint' do + env = build_env( + '/my-group/my-project/pipelines.json' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'project_pipelines' + end + + it 'matches commit pipelines endpoint' do + env = build_env( + '/my-group/my-project/commit/aa8260d253a53f73f6c26c734c72fdd600f6e6d4/pipelines.json' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'commit_pipelines' + end + + it 'matches new merge request pipelines endpoint' do + env = build_env( + '/my-group/my-project/merge_requests/new.json' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'new_merge_request_pipelines' + end + + it 'matches merge request pipelines endpoint' do + env = build_env( + '/my-group/my-project/merge_requests/234/pipelines.json' + ) + + result = described_class.match(env) + + expect(result).to be_present + expect(result.name).to eq 'merge_request_pipelines' + end + + it 'does not match blob with confusing name' do + env = build_env( + '/my-group/my-project/blob/master/pipelines.json' + ) + + result = described_class.match(env) + + expect(result).to be_blank + end + + def build_env(path) + { 'PATH_INFO' => path } + end +end |