diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-06-16 13:46:31 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-06-16 13:46:31 +0300 |
commit | c48e7dc2633f8ee8f38150b050938f43e75bd207 (patch) | |
tree | e8fab96b29cfd93f46e0d575436329478e8c7cce /app/controllers/projects/artifacts_controller.rb | |
parent | f733d4f8979a7570a9347186dbe0f8c663c2ff4f (diff) |
[Rails5] Set request.format for artifacts_controller
Since Rails 5 request.format gets set by extension if it's not explicitly
set.
That means artifacts_controller#file no longer works as expected.
This commit explicitly sets request.format for artifacts_controller#file.
Diffstat (limited to 'app/controllers/projects/artifacts_controller.rb')
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index abc283d7aa9..6484a713f8e 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -7,6 +7,7 @@ class Projects::ArtifactsController < Projects::ApplicationController before_action :authorize_read_build! before_action :authorize_update_build!, only: [:keep] before_action :extract_ref_name_and_path + before_action :set_request_format, only: [:file] before_action :validate_artifacts! before_action :entry, only: [:file] @@ -101,4 +102,12 @@ class Projects::ArtifactsController < Projects::ApplicationController render_404 unless @entry.exists? end + + def set_request_format + request.format = :html if set_request_format? + end + + def set_request_format? + request.format != :json + end end |