mirror of https://github.com/mastodon/mastodon
Move posting defaults to their own preferences sub-category (#35966)
parent
f21d9f64db
commit
ab698ff521
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Settings::Preferences::PostingDefaultsController < Settings::Preferences::BaseController
|
||||
private
|
||||
|
||||
def after_update_redirect_path
|
||||
settings_preferences_posting_defaults_path
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,48 @@
|
||||
- content_for :page_title do
|
||||
= t('preferences.posting_defaults')
|
||||
|
||||
- content_for :heading_actions do
|
||||
= button_tag t('generic.save_changes'), class: 'button', form: 'edit_preferences'
|
||||
|
||||
= simple_form_for current_user, url: settings_preferences_posting_defaults_path, html: { id: :edit_preferences } do |f|
|
||||
= render 'shared/error_messages', object: current_user
|
||||
|
||||
= f.simple_fields_for :settings, current_user.settings do |ff|
|
||||
.flash-message= t('posting_defaults.explanation')
|
||||
|
||||
.fields-group
|
||||
= ff.input :default_privacy,
|
||||
collection: Status.selectable_visibilities,
|
||||
selected: current_user.setting_default_privacy,
|
||||
hint: false,
|
||||
include_blank: false,
|
||||
label_method: ->(visibility) { safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') },
|
||||
label: I18n.t('simple_form.labels.defaults.setting_default_privacy'),
|
||||
required: false,
|
||||
wrapper: :with_label
|
||||
|
||||
.fields-group
|
||||
= ff.input :default_quote_policy,
|
||||
collection: %w(public followers nobody),
|
||||
include_blank: false,
|
||||
label_method: ->(policy) { I18n.t("statuses.quote_policies.#{policy}") },
|
||||
label: I18n.t('simple_form.labels.defaults.setting_default_quote_policy'),
|
||||
hint: I18n.t('simple_form.hints.defaults.setting_default_quote_policy'),
|
||||
required: false,
|
||||
wrapper: :with_label
|
||||
|
||||
.fields-group
|
||||
= ff.input :default_language,
|
||||
collection: [nil] + filterable_languages,
|
||||
hint: false,
|
||||
include_blank: false,
|
||||
label_method: ->(locale) { locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) },
|
||||
label: I18n.t('simple_form.labels.defaults.setting_default_language'),
|
||||
required: false,
|
||||
wrapper: :with_label
|
||||
|
||||
.fields-group
|
||||
= ff.input :default_sensitive,
|
||||
hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive'),
|
||||
label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'),
|
||||
wrapper: :with_label
|
||||
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings preferences posting defaults page' do
|
||||
let(:user) { Fabricate :user }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'Views and updates user prefs' do
|
||||
visit settings_preferences_posting_defaults_path
|
||||
|
||||
expect(page)
|
||||
.to have_private_cache_control
|
||||
|
||||
check mark_sensitive_field
|
||||
|
||||
expect { save_changes }
|
||||
.to change { user.reload.settings.default_sensitive }.to(true)
|
||||
expect(page)
|
||||
.to have_title(I18n.t('preferences.posting_defaults'))
|
||||
end
|
||||
|
||||
def save_changes
|
||||
click_on submit_button
|
||||
end
|
||||
|
||||
def mark_sensitive_field
|
||||
form_label('defaults.setting_default_sensitive')
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue