Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/application_controller_spec.rb')
-rw-r--r--spec/controllers/application_controller_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 9342513d224..4a729008e67 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -720,6 +720,49 @@ RSpec.describe ApplicationController do
end
end
+ describe '#stream_csv_headers' do
+ controller(described_class) do
+ def index
+ respond_to do |format|
+ format.csv do
+ stream_csv_headers('test.csv')
+
+ self.response_body = fixture_file_upload('spec/fixtures/csv_comma.csv')
+ end
+ end
+ end
+ end
+
+ subject { get :index, format: :csv }
+
+ before do
+ sign_in(user)
+ end
+
+ it 'sets no-cache headers', :aggregate_failures do
+ subject
+
+ expect(response.headers['Cache-Control']).to eq 'no-cache, no-store'
+ expect(response.headers['Pragma']).to eq 'no-cache'
+ expect(response.headers['Expires']).to eq 'Fri, 01 Jan 1990 00:00:00 GMT'
+ end
+
+ it 'sets stream headers', :aggregate_failures do
+ subject
+
+ expect(response.headers['Content-Length']).to be nil
+ expect(response.headers['X-Accel-Buffering']).to eq 'no'
+ expect(response.headers['Last-Modified']).to eq '0'
+ end
+
+ it 'sets the csv specific headers', :aggregate_failures do
+ subject
+
+ expect(response.headers['Content-Type']).to eq 'text/csv; charset=utf-8; header=present'
+ expect(response.headers['Content-Disposition']).to eq "attachment; filename=\"test.csv\""
+ end
+ end
+
context 'Gitlab::Session' do
controller(described_class) do
prepend_before_action do