diff options
author | Robert Speicher <rspeicher@gmail.com> | 2018-11-27 21:04:00 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-11-27 21:07:02 +0300 |
commit | df8f0ab52128e173690f624575fef286d1a3cf4c (patch) | |
tree | 68e39eb1ed78ccb264a1f6dbaa93b4af7cd52415 | |
parent | 1cd570cf77b79f37f30ef3ccd399c337056aa236 (diff) |
Remove `options` assignment from ExtractsPath
This assignment is only used by the Projects::NetworkController, so
we're needlessly assigning this very generically-named instance variable
on every controller which includes `ExtractsPath`, which is quite a few.
Further, the way we were passing this hash to
`HashWithIndifferentAccess` caused the following deprecation warning
after upgrading to Rails 5:
DEPRECATION WARNING: #to_hash unexpectedly ignores parameter
filtering, and will change to enforce it in Rails 5.1. Enable
`raise_on_unfiltered_parameters` to respect parameter filtering,
which is the default in new applications. For the existing
deprecated behaviour, call #to_unsafe_h instead. (called from new at
lib/extracts_path.rb:116)
-rw-r--r-- | app/controllers/projects/network_controller.rb | 8 | ||||
-rw-r--r-- | lib/extracts_path.rb | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index ad2466a8588..6543711ecfa 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -8,6 +8,7 @@ class Projects::NetworkController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars before_action :authorize_download_code! + before_action :assign_options before_action :assign_commit def show @@ -29,10 +30,13 @@ class Projects::NetworkController < Projects::ApplicationController render end + def assign_options + @options = params.permit(:filter_ref, :extended_sha1) + end + def assign_commit - return if params[:extended_sha1].blank? + return if @options[:extended_sha1].blank? - @options[:extended_sha1] = params[:extended_sha1] @commit = @repo.commit(@options[:extended_sha1]) end diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 655278da711..b2c8d46ede1 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -110,11 +110,6 @@ module ExtractsPath # resolved (e.g., when a user inserts an invalid path or ref). # rubocop:disable Gitlab/ModuleWithInstanceVariables def assign_ref_vars - # assign allowed options - allowed_options = ["filter_ref"] - @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } - @options = HashWithIndifferentAccess.new(@options) - @id = get_id @ref, @path = extract_ref(@id) @repo = @project.repository |