Skip to content
Open
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: 0 additions & 2 deletions app/controllers/admin/account_merger_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Admin::AccountMergerController < InertiaController
layout "inertia"

before_action :require_ultraadmin!

def show = render(inertia: "Admin/AccountMerger")
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class Admin::BaseController < InertiaController
ADMIN_NAV_LEVELS = %w[admin superadmin viewer ultraadmin].freeze

layout "inertia"

before_action :authenticate_admin!

private
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin/leaderboard_shadowbans_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Admin::LeaderboardShadowbansController < InertiaController
layout "inertia"

before_action :require_shadowban_admin!

def index
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/api_keys_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ApiKeysController < InertiaController
layout "inertia", only: [ :show ]

before_action :authenticate_user!

def show
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/deletion_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class DeletionRequestsController < InertiaController
layout "inertia", only: [ :show ]

before_action :require_login
before_action :check_can_request, only: [ :create ]

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/doorkeeper/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module Doorkeeper
class ApplicationsController < InertiaController
layout "inertia"

before_action :authenticate_oauth_owner!
before_action :set_application, only: %i[show edit update destroy rotate_secret]

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/extensions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ExtensionsController < InertiaController
layout "inertia"

def index
render inertia: "Extensions/Index"
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/inertia_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

class InertiaController < ApplicationController
layout "inertia"

inertia_share layout: -> { inertia_layout_props }

private
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/leaderboards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class LeaderboardsController < InertiaController
layout "inertia"

def index
period_type = validated_period_type
country = load_country_context
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/my/project_repo_mappings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class My::ProjectRepoMappingsController < InertiaController
layout "inertia", only: [ :index, :show ]

before_action :ensure_current_user
before_action :require_github_oauth, only: [ :update ]
before_action :set_project_repo_mapping_for_edit, only: [ :update ]
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class ProfilesController < InertiaController
layout "inertia"

before_action :find_user

SOCIAL_LINKS = [
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/settings/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Settings::BaseController < InertiaController
layout "inertia"

before_action :set_user

def show = render_settings_page
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class StaticPagesController < InertiaController
include DashboardData

layout "inertia", only: %i[index wakatime_alternative]

def index
if current_user
flavor_texts = FlavorText.motto + FlavorText.conditional_mottos(current_user)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
class UsersController < InertiaController
SETUP_THEME = "rose_pine_dawn".freeze

layout "inertia", only: %i[setup]

before_action :ensure_current_user_for_setup, only: %i[setup]
before_action :set_setup_meta, only: %i[setup]
before_action :require_admin, only: [ :update_trust_level ]
Expand Down
28 changes: 28 additions & 0 deletions test/controllers/inertia_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "test_helper"

class InertiaControllerTest < ActionDispatch::IntegrationTest
test "pure descendants inherit the Inertia layout" do
get extensions_path

assert_response :success
assert_inertia_component "Extensions/Index"
assert_select "html[data-theme]"
assert_select "[data-page]"
end

test "mixed descendants apply the layout only to Inertia responses" do
get signin_path

assert_response :success
assert_inertia_component "Auth/SignIn"
assert_select "html[data-theme]"
assert_select "[data-page]"

get currently_hacking_count_static_pages_path

assert_response :success
assert_equal "application/json", response.media_type
assert response.parsed_body.key?("count")
assert_not response.body.start_with?("<!DOCTYPE html>")
end
end