mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Merge d2c01c066f
into 6d62581da1
This commit is contained in:
commit
ef0a96cd50
|
@ -22,7 +22,6 @@ class ApplicationController < ActionController::Base
|
||||||
helper_method :use_seamless_external_login?
|
helper_method :use_seamless_external_login?
|
||||||
helper_method :sso_account_settings
|
helper_method :sso_account_settings
|
||||||
helper_method :limited_federation_mode?
|
helper_method :limited_federation_mode?
|
||||||
helper_method :body_class_string
|
|
||||||
helper_method :skip_csrf_meta_tags?
|
helper_method :skip_csrf_meta_tags?
|
||||||
|
|
||||||
rescue_from ActionController::ParameterMissing, Paperclip::AdapterRegistry::NoHandlerError, with: :bad_request
|
rescue_from ActionController::ParameterMissing, Paperclip::AdapterRegistry::NoHandlerError, with: :bad_request
|
||||||
|
@ -158,10 +157,6 @@ class ApplicationController < ActionController::Base
|
||||||
current_user.setting_theme
|
current_user.setting_theme
|
||||||
end
|
end
|
||||||
|
|
||||||
def body_class_string
|
|
||||||
@body_classes || ''
|
|
||||||
end
|
|
||||||
|
|
||||||
def respond_with_error(code)
|
def respond_with_error(code)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.any { render "errors/#{code}", layout: 'error', status: code, formats: [:html] }
|
format.any { render "errors/#{code}", layout: 'error', status: code, formats: [:html] }
|
||||||
|
|
|
@ -143,13 +143,13 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def body_classes
|
def body_classes
|
||||||
output = body_class_string.split
|
class_names(
|
||||||
output << content_for(:body_classes)
|
content_for(:body_classes),
|
||||||
output << "theme-#{current_theme.parameterize}"
|
"theme-#{current_theme.parameterize}",
|
||||||
output << 'system-font' if current_account&.user&.setting_system_font_ui
|
(current_account&.user&.setting_reduce_motion ? 'reduce-motion' : 'no-reduce-motion'),
|
||||||
output << (current_account&.user&.setting_reduce_motion ? 'reduce-motion' : 'no-reduce-motion')
|
locale_direction,
|
||||||
output << 'rtl' if locale_direction == 'rtl'
|
'system-font': current_account&.user&.setting_system_font_ui
|
||||||
output.compact_blank.join(' ')
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cdn_host
|
def cdn_host
|
||||||
|
|
|
@ -5,12 +5,20 @@ require 'rails_helper'
|
||||||
RSpec.describe ApplicationHelper do
|
RSpec.describe ApplicationHelper do
|
||||||
describe 'body_classes' do
|
describe 'body_classes' do
|
||||||
context 'with a body class string from a controller' do
|
context 'with a body class string from a controller' do
|
||||||
before { helper.extend controller_helpers }
|
before do
|
||||||
|
user = Fabricate :user
|
||||||
|
user.settings['web.use_system_font'] = true
|
||||||
|
user.settings['web.reduce_motion'] = true
|
||||||
|
user.save
|
||||||
|
|
||||||
it 'uses the controller body classes in the result' do
|
helper.extend controller_helpers
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'uses the current theme and user settings classes in the result' do
|
||||||
expect(helper.body_classes)
|
expect(helper.body_classes)
|
||||||
.to match(/modal-layout compose-standalone/)
|
.to match(/theme-default/)
|
||||||
.and match(/theme-default/)
|
.and match(/system-font/)
|
||||||
|
.and match(/reduce-motion/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'includes values set via content_for' do
|
it 'includes values set via content_for' do
|
||||||
|
@ -24,10 +32,8 @@ RSpec.describe ApplicationHelper do
|
||||||
|
|
||||||
def controller_helpers
|
def controller_helpers
|
||||||
Module.new do
|
Module.new do
|
||||||
def body_class_string = 'modal-layout compose-standalone'
|
|
||||||
|
|
||||||
def current_account
|
def current_account
|
||||||
@current_account ||= Fabricate(:account)
|
@current_account ||= Fabricate(:account, user: User.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_theme = 'default'
|
def current_theme = 'default'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user