diff options
author | Francisco Javier López 🌴 On vacation; back on August 22th! <fjlopez@gitlab.com> | 2018-08-01 19:48:33 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-08-01 19:48:33 +0300 |
commit | 4b36f74bfedc854b8628f2597223f17ea19e3abd (patch) | |
tree | a06e901f8f95104d33127fcf77064aa804073d3b /spec/requests/api/files_spec.rb | |
parent | dae5c2665df3dd3b33a04ff215f39ef6a336d1da (diff) |
Fix bug setting http headers in Files API
Diffstat (limited to 'spec/requests/api/files_spec.rb')
-rw-r--r-- | spec/requests/api/files_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 4bc5d3ee899..0aec186f738 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -13,6 +13,24 @@ describe API::Files do let(:author_email) { 'user@example.org' } let(:author_name) { 'John Doe' } + let(:helper) do + fake_class = Class.new do + include ::API::Helpers::HeadersHelpers + + attr_reader :headers + + def initialize + @headers = {} + end + + def header(key, value) + @headers[key] = value + end + end + + fake_class.new + end + before do project.add_developer(user) end @@ -21,6 +39,18 @@ describe API::Files do "/projects/#{project.id}/repository/files/#{file_path}" end + context 'http headers' do + it 'converts value into string' do + helper.set_http_headers(test: 1) + + expect(helper.headers).to eq({ 'X-Gitlab-Test' => '1' }) + end + + it 'raises exception if value is an Enumerable' do + expect { helper.set_http_headers(test: [1]) }.to raise_error(ArgumentError) + end + end + describe "HEAD /projects/:id/repository/files/:file_path" do shared_examples_for 'repository files' do it 'returns file attributes in headers' do |