Skip to content

Commit

Permalink
Revert "Add refresh to before_action if refresh is present"
Browse files Browse the repository at this point in the history
This reverts commit 5210a01.
  • Loading branch information
David-Feetenby committed Oct 21, 2024
1 parent 9b3efb7 commit 9dd3072
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 38 deletions.
9 changes: 0 additions & 9 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class ApplicationController < ActionController::Base
before_action :set_analytics_tracking_id,
:set_hotjar_site_id,
:prepare_cms
before_action :handle_refresh

helper_method :current_user,
:debug?
Expand Down Expand Up @@ -97,12 +96,4 @@ def user_signed_in?

super
end

def handle_refresh
# Check if the `refresh` parameter is present
if params[:refresh]
# Perform a page reload or any other logic you need
redirect_to request.path, status: :found # Reload the page without the `refresh` parameter
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def after_sign_in_path_for(resource)
elsif !resource.email_preferences_complete?
static_path('email-preferences')
else
my_modules_path(refresh: true)
my_modules_path
end
else
edit_registration_terms_and_conditions_path
Expand Down
26 changes: 0 additions & 26 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
require 'rails_helper'

RSpec.describe ApplicationController, type: :controller do
controller do
# Add an index action for testing purposes
def index
render plain: 'Test page'
end
end

describe '#guest' do
subject(:guest) { controller.send(:guest) }

Expand Down Expand Up @@ -42,23 +35,4 @@ def index
end
end
end

describe 'GET #index with refresh param' do
it 'redirects and removes the refresh param' do
# Simulate a request with the refresh parameter
get :index, params: { refresh: true }

# Check that the response is a redirect
expect(response).to have_http_status(:found)

# Check that it redirects to the correct path
expect(response).to redirect_to('/anonymous')

# Simulate the follow-up request after the redirect
get :index

# Ensure that the refresh parameter is not in the final request
expect(request.query_parameters[:refresh]).to be_nil
end
end
end
4 changes: 2 additions & 2 deletions spec/controllers/users/omniauth_callbacks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

it 'redirects to /my-modules' do
expect(session[:id_token]).to eq id_token
expect(response).to redirect_to my_modules_path(refresh: true)
expect(response).to redirect_to my_modules_path
end
end

Expand All @@ -62,7 +62,7 @@

it 'redirects to /my-modules' do
expect(session[:id_token]).to eq id_token
expect(response).to redirect_to my_modules_path(refresh: true)
expect(response).to redirect_to my_modules_path
end
end

Expand Down

0 comments on commit 9dd3072

Please sign in to comment.