mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-12 01:45:08 +00:00
![Matt Jankowski](/assets/img/avatar_default.png)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
79 lines
1.9 KiB
Ruby
79 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.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)
|
|
.to have_http_status(200)
|
|
.and have_cacheable_headers
|
|
.and have_attributes(
|
|
content_type: match('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)
|
|
.to have_http_status(200)
|
|
.and have_cacheable_headers
|
|
.and have_attributes(
|
|
content_type: match('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)
|
|
.to have_http_status(200)
|
|
.and have_cacheable_headers
|
|
.and have_attributes(
|
|
content_type: match('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
|