Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send <head> along with pagination frames #5175

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/diary_comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def index

@comments, @newer_comments_id, @older_comments_id = get_page_items(comments, :includes => [:user])

render :partial => "page" if turbo_frame_request_id == "pagination"
render "_page", :layout => "turbo_frame_visit" if turbo_frame_request_id == "pagination"
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/diary_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def index

@entries, @newer_entries_id, @older_entries_id = get_page_items(entries, :includes => [:user, :language])

render :partial => "page" if turbo_frame_request_id == "pagination"
render "_page", :layout => "turbo_frame_visit" if turbo_frame_request_id == "pagination"
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def index
end

@issues, @newer_issues_id, @older_issues_id = get_page_items(@issues, :limit => @params[:limit])
render :partial => "page" if turbo_frame_request_id == "pagination"
render "_page", :layout => "turbo_frame_visit" if turbo_frame_request_id == "pagination"
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/traces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def index
# final helper vars for view
@target_user = target_user

render :partial => "page" if turbo_frame_request_id == "pagination"
render "_page", :layout => "turbo_frame_visit" if turbo_frame_request_id == "pagination"
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def index
@users_count = users.count
@users, @newer_users_id, @older_users_id = get_page_items(users, :limit => 50)

render :partial => "page" if turbo_frame_request_id == "pagination"
render "_page", :layout => "turbo_frame_visit" if turbo_frame_request_id == "pagination"
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/turbo_frame_visit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= render :partial => "layouts/head" %>
<%= yield %>
23 changes: 23 additions & 0 deletions test/system/user_logout_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,27 @@ class UserLogoutTest < ApplicationSystemTestCase
assert_content "Log In"
assert_content "Public GPS Traces"
end

test "Sign out after navigating with Turbo pagination" do
saved_allow_forgery_protection = ActionController::Base.allow_forgery_protection
ActionController::Base.allow_forgery_protection = true

create(:language, :code => "en")
create(:diary_entry, :title => "First Diary Entry")
create_list(:diary_entry, 20) # rubocop:disable FactoryBot/ExcessiveCreateList
user = create(:user)
sign_in_as user

visit diary_entries_path
assert_no_link "Log In"

click_on "Older Entries"
assert_link "First Diary Entry"

click_on user.display_name
click_on "Log Out"
assert_link "Log In"
ensure
ActionController::Base.allow_forgery_protection = saved_allow_forgery_protection
end
end