Skip to content

Commit

Permalink
Revert the deprecation of #redirect_back_or_default method
Browse files Browse the repository at this point in the history
We deprecated `#redirect_back_or_default` method in solidusio#4533 [1]. However,
the original plan was halted because of auth problems in
solidus_auth_devise. See solidusio/solidus_auth_devise/232 for details.

[1] - solidusio#4533
[2] - solidusio/solidus_auth_devise#232
  • Loading branch information
waiting-for-dev committed Jan 16, 2023
1 parent 26f1193 commit ca4d1f5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 26 deletions.
1 change: 0 additions & 1 deletion core/app/models/spree/user_last_url_storer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def self.rules
# or its subclasses. The controller will be passed to each rule for matching.
def initialize(controller)
@controller = controller
Spree::Deprecation.warn("This class will be removed without replacement on the release of Solidus 4.0")
end

# Stores into session[:spree_user_return_to] the request full path for
Expand Down
11 changes: 0 additions & 11 deletions core/lib/spree/core/controller_helpers/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ def current_ability
end

def redirect_back_or_default(default)
Spree::Deprecation.warn <<~MSG
'Please use #stored_spree_user_location_or when using solidus_auth_devise.
Otherwise, please utilize #redirect_back provided in Rails 5+ or
#redirect_back_or_to in Rails 7+ instead'
MSG

redirect_to(session["spree_user_return_to"] || default)
session["spree_user_return_to"] = nil
end
Expand All @@ -57,11 +51,6 @@ def set_guest_token
end

def store_location
Spree::Deprecation.warn <<~MSG
store_location is being deprecated in solidus 4.0
without replacement
MSG

Spree::UserLastUrlStorer.new(self).store_location
end

Expand Down
9 changes: 2 additions & 7 deletions core/spec/lib/spree/core/controller_helpers/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def index; render plain: 'index'; end
describe '#redirect_back_or_default' do
before do
def controller.index
Spree::Deprecation.silence { redirect_back_or_default('/') }
redirect_back_or_default('/')
end
end

Expand All @@ -30,11 +30,6 @@ def controller.index
get :index
expect(response).to redirect_to('/')
end

it 'is deprecated' do
expect(Spree::Deprecation).to receive(:warn)
get :index
end
end

describe '#set_guest_token' do
Expand Down Expand Up @@ -74,7 +69,7 @@ def controller.index
describe '#store_location' do
it 'sets session return url' do
allow(controller).to receive_messages(request: double(fullpath: '/redirect'))
Spree::Deprecation.silence { controller.store_location }
controller.store_location
expect(session[:spree_user_return_to]).to eq '/redirect'
end
end
Expand Down
9 changes: 2 additions & 7 deletions core/spec/models/spree/user_last_url_storer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ def self.match?(_controller)
described_class.rules.delete('CustomRule')
end

it 'is deprecated' do
expect(Spree::Deprecation).to receive(:warn)
described_class.new(controller)
end

describe '::rules' do
it 'includes default rules' do
rule = Spree::UserLastUrlStorer::Rules::AuthenticationRule
Expand All @@ -48,7 +43,7 @@ def self.match?(_controller)
context 'when at least one rule matches' do
it 'does not set the path value into the session' do
described_class.rules << CustomRule
Spree::Deprecation.silence { subject.store_location }
subject.store_location
expect(session[:spree_user_return_to]).to be_nil
end
end
Expand All @@ -57,7 +52,7 @@ def self.match?(_controller)
it 'sets the path value into the session' do
described_class.rules << CustomRule
described_class.rules.delete('CustomRule')
Spree::Deprecation.silence { subject.store_location }
subject.store_location
expect(session[:spree_user_return_to]).to eql fullpath
end
end
Expand Down

0 comments on commit ca4d1f5

Please sign in to comment.