Merge commit 'a90696011e563e62100cba56e2d52f6babbaff00' into glitch-soc/merge-upstream
commit
1323dfac80
|
@ -1,8 +1,21 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CustomCssController < ActionController::Base # rubocop:disable Rails/ApplicationController
|
class CustomCssController < ActionController::Base # rubocop:disable Rails/ApplicationController
|
||||||
|
before_action :set_user_roles
|
||||||
|
|
||||||
def show
|
def show
|
||||||
expires_in 3.minutes, public: true
|
expires_in 3.minutes, public: true
|
||||||
render content_type: 'text/css'
|
render content_type: 'text/css'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def custom_css_styles
|
||||||
|
Setting.custom_css
|
||||||
|
end
|
||||||
|
helper_method :custom_css_styles
|
||||||
|
|
||||||
|
def set_user_roles
|
||||||
|
@user_roles = UserRole.where(highlighted: true).where.not(color: [nil, ''])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -489,7 +489,7 @@
|
||||||
"onboarding.profile.lead": "Du kannst das später in den Einstellungen vervollständigen, wo noch mehr Anpassungsmöglichkeiten zur Verfügung stehen.",
|
"onboarding.profile.lead": "Du kannst das später in den Einstellungen vervollständigen, wo noch mehr Anpassungsmöglichkeiten zur Verfügung stehen.",
|
||||||
"onboarding.profile.note": "Über mich",
|
"onboarding.profile.note": "Über mich",
|
||||||
"onboarding.profile.note_hint": "Du kannst andere @Profile erwähnen oder #Hashtags verwenden …",
|
"onboarding.profile.note_hint": "Du kannst andere @Profile erwähnen oder #Hashtags verwenden …",
|
||||||
"onboarding.profile.save_and_continue": "Speichern und fortsetzen",
|
"onboarding.profile.save_and_continue": "Speichern und fortfahren",
|
||||||
"onboarding.profile.title": "Profil einrichten",
|
"onboarding.profile.title": "Profil einrichten",
|
||||||
"onboarding.profile.upload_avatar": "Profilbild hochladen",
|
"onboarding.profile.upload_avatar": "Profilbild hochladen",
|
||||||
"onboarding.profile.upload_header": "Titelbild hochladen",
|
"onboarding.profile.upload_header": "Titelbild hochladen",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<%- if Setting.custom_css.present? %>
|
<%- if custom_css_styles.present? %>
|
||||||
<%= raw Setting.custom_css %>
|
<%= raw custom_css_styles %>
|
||||||
|
|
||||||
<%- end %>
|
<%- end %>
|
||||||
<%- UserRole.where(highlighted: true).select { |role| role.color.present? }.each do |role| %>
|
<%- @user_roles.each do |role| %>
|
||||||
.user-role-<%= role.id %> {
|
.user-role-<%= role.id %> {
|
||||||
--user-role-accent: <%= role.color %>;
|
--user-role-accent: <%= role.color %>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
.report-header
|
.report-header
|
||||||
.report-header__card
|
.report-header__card
|
||||||
= render 'card', strike: @strike
|
= render 'disputes/strikes/card', strike: @strike
|
||||||
|
|
||||||
.report-header__details
|
.report-header__details
|
||||||
.report-header__details__item
|
.report-header__details__item
|
||||||
|
|
|
@ -1445,7 +1445,7 @@ eu:
|
||||||
cooldown: Migratu eta gero egonaldi tarte bat egongo da eta bitartean ezin izango duzu berriro migratu
|
cooldown: Migratu eta gero egonaldi tarte bat egongo da eta bitartean ezin izango duzu berriro migratu
|
||||||
disabled_account: Zure uneko kontua ezin izango da gero erabili. Hala ere, datua exporatu ahal izango dituzu, eta berriro aktibatu.
|
disabled_account: Zure uneko kontua ezin izango da gero erabili. Hala ere, datua exporatu ahal izango dituzu, eta berriro aktibatu.
|
||||||
followers: Ekintza honek jarraitzaile guztiak eramango ditu uneko kontutik kontu berrira
|
followers: Ekintza honek jarraitzaile guztiak eramango ditu uneko kontutik kontu berrira
|
||||||
only_redirect_html: Bestela, <a href="%{path}">zure profilean birbideratze soil bat jarri</a> dezakezu.
|
only_redirect_html: Bestela, <a href="%{path}">zure profilean birbideratze bat jar</a> dezakezu.
|
||||||
other_data: Ez da beste daturik migratuko automatikoki
|
other_data: Ez da beste daturik migratuko automatikoki
|
||||||
redirect: Zure uneko kontuaren profila eguneratuko da birbideratze ohar batekin eta bilaketetatik kenduko da
|
redirect: Zure uneko kontuaren profila eguneratuko da birbideratze ohar batekin eta bilaketetatik kenduko da
|
||||||
moderation:
|
moderation:
|
||||||
|
|
|
@ -93,6 +93,7 @@ ro:
|
||||||
moderation:
|
moderation:
|
||||||
active: Activ
|
active: Activ
|
||||||
all: Toate
|
all: Toate
|
||||||
|
disabled: Dezactivat
|
||||||
pending: În așteptare
|
pending: În așteptare
|
||||||
silenced: Limitat
|
silenced: Limitat
|
||||||
suspended: Suspendate
|
suspended: Suspendate
|
||||||
|
|
|
@ -184,6 +184,7 @@ sk:
|
||||||
create_domain_block: Vytvor zákaz domény
|
create_domain_block: Vytvor zákaz domény
|
||||||
create_email_domain_block: Vytvor zákaz emailovej domény
|
create_email_domain_block: Vytvor zákaz emailovej domény
|
||||||
create_ip_block: Vytvor IP pravidlo
|
create_ip_block: Vytvor IP pravidlo
|
||||||
|
create_unavailable_domain: Vytvor nedostupnú doménu
|
||||||
create_user_role: Vytvoriť rolu
|
create_user_role: Vytvoriť rolu
|
||||||
demote_user: Zniž užívateľskú rolu
|
demote_user: Zniž užívateľskú rolu
|
||||||
destroy_announcement: Vymaž oboznámenie
|
destroy_announcement: Vymaž oboznámenie
|
||||||
|
@ -245,6 +246,7 @@ sk:
|
||||||
destroy_email_domain_block_html: "%{name} odblokoval/a e-mailovú doménu %{target}"
|
destroy_email_domain_block_html: "%{name} odblokoval/a e-mailovú doménu %{target}"
|
||||||
destroy_ip_block_html: "%{name} vymazal/a pravidlo pre IP %{target}"
|
destroy_ip_block_html: "%{name} vymazal/a pravidlo pre IP %{target}"
|
||||||
destroy_status_html: "%{name} zmazal/a príspevok od %{target}"
|
destroy_status_html: "%{name} zmazal/a príspevok od %{target}"
|
||||||
|
destroy_unavailable_domain_html: "%{name} znova spustil/a doručovanie pre doménu %{target}"
|
||||||
destroy_user_role_html: "%{name} vymazal/a rolu pre %{target}"
|
destroy_user_role_html: "%{name} vymazal/a rolu pre %{target}"
|
||||||
enable_user_html: "%{name} povolil/a prihlásenie pre používateľa %{target}"
|
enable_user_html: "%{name} povolil/a prihlásenie pre používateľa %{target}"
|
||||||
memorialize_account_html: "%{name} zmenil/a účet %{target} na pamätnú stránku"
|
memorialize_account_html: "%{name} zmenil/a účet %{target} na pamätnú stránku"
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
if Rake::Task.task_defined?('spec:system')
|
if Rake::Task.task_defined?('spec:system')
|
||||||
namespace :spec do
|
namespace :spec do
|
||||||
task :enable_system_specs do # rubocop:disable Rails/RakeEnvironment
|
task :enable_system_specs do # rubocop:disable Rails/RakeEnvironment
|
||||||
|
ENV['LOCAL_DOMAIN'] = 'localhost:3000'
|
||||||
|
ENV['LOCAL_HTTPS'] = 'false'
|
||||||
ENV['RUN_SYSTEM_SPECS'] = 'true'
|
ENV['RUN_SYSTEM_SPECS'] = 'true'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,19 +10,38 @@ RSpec.describe Disputes::AppealsController do
|
||||||
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
let(:current_user) { Fabricate(:user) }
|
context 'with valid params' do
|
||||||
let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
|
let(:current_user) { Fabricate(:user) }
|
||||||
|
let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
|
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'notifies staff about new appeal', :sidekiq_inline do
|
||||||
|
expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirects back to the strike page' do
|
||||||
|
expect(response).to redirect_to(disputes_strike_path(strike.id))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'notifies staff about new appeal', :sidekiq_inline do
|
context 'with invalid params' do
|
||||||
expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email])
|
let(:current_user) { Fabricate(:user) }
|
||||||
end
|
let(:strike) { Fabricate(:account_warning, target_account: current_user.account) }
|
||||||
|
|
||||||
it 'redirects back to the strike page' do
|
before do
|
||||||
expect(response).to redirect_to(disputes_strike_path(strike.id))
|
post :create, params: { strike_id: strike.id, appeal: { text: '' } }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not send email', :sidekiq_inline do
|
||||||
|
expect(ActionMailer::Base.deliveries.size).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders the strike show page' do
|
||||||
|
expect(response).to render_template('disputes/strikes/show')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe 'Custom CSS' do
|
||||||
|
include RoutingHelper
|
||||||
|
|
||||||
|
describe 'GET /custom.css' do
|
||||||
|
context 'without any CSS or User Roles' do
|
||||||
|
it 'returns empty stylesheet' do
|
||||||
|
get '/custom.css'
|
||||||
|
|
||||||
|
expect(response.content_type).to include('text/css')
|
||||||
|
expect(response.body.presence).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with CSS settings' do
|
||||||
|
before do
|
||||||
|
Setting.custom_css = expected_css
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns stylesheet from settings' do
|
||||||
|
get '/custom.css'
|
||||||
|
|
||||||
|
expect(response.content_type).to include('text/css')
|
||||||
|
expect(response.body.strip).to eq(expected_css)
|
||||||
|
end
|
||||||
|
|
||||||
|
def expected_css
|
||||||
|
<<~CSS.strip
|
||||||
|
body { background-color: red; }
|
||||||
|
CSS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with highlighted colored UserRole records' do
|
||||||
|
before do
|
||||||
|
_highlighted_colored = Fabricate :user_role, highlighted: true, color: '#336699', id: '123_123_123'
|
||||||
|
_highlighted_no_color = Fabricate :user_role, highlighted: true, color: ''
|
||||||
|
_no_highlight_with_color = Fabricate :user_role, highlighted: false, color: ''
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns stylesheet from settings' do
|
||||||
|
get '/custom.css'
|
||||||
|
|
||||||
|
expect(response.content_type).to include('text/css')
|
||||||
|
expect(response.body.strip).to eq(expected_css)
|
||||||
|
end
|
||||||
|
|
||||||
|
def expected_css
|
||||||
|
<<~CSS.strip
|
||||||
|
.user-role-123123123 {
|
||||||
|
--user-role-accent: #336699;
|
||||||
|
}
|
||||||
|
CSS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,18 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.after(:each, type: :system) do
|
||||||
|
errors = page.driver.browser.logs.get(:browser)
|
||||||
|
if errors.present?
|
||||||
|
aggregate_failures 'javascript errrors' do
|
||||||
|
errors.each do |error|
|
||||||
|
expect(error.level).to_not eq('SEVERE'), error.message
|
||||||
|
next unless error.level == 'WARNING'
|
||||||
|
|
||||||
|
$stderr.warn 'WARN: javascript warning'
|
||||||
|
$stderr.warn error.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue