2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Themes, lib: true do
|
2018-03-17 18:26:18 +05:30
|
|
|
describe '.body_classes' do
|
|
|
|
it 'returns a space-separated list of class names' do
|
|
|
|
css = described_class.body_classes
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(css).to include('ui-indigo')
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(css).to include('ui-gray')
|
2018-11-08 19:23:39 +05:30
|
|
|
expect(css).to include('ui-blue')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.by_id' do
|
|
|
|
it 'returns a Theme by its ID' do
|
|
|
|
expect(described_class.by_id(1).name).to eq 'Indigo'
|
2022-07-23 23:45:48 +05:30
|
|
|
expect(described_class.by_id(3).name).to eq 'Light Gray'
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.default' do
|
|
|
|
it 'returns the default application theme' do
|
|
|
|
allow(described_class).to receive(:default_id).and_return(2)
|
|
|
|
expect(described_class.default.id).to eq 2
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'prevents an infinite loop when configuration default is invalid' do
|
|
|
|
default = described_class::APPLICATION_DEFAULT
|
2022-03-02 08:16:31 +05:30
|
|
|
themes = described_class.available_themes
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
config = double(default_theme: 0).as_null_object
|
|
|
|
allow(Gitlab).to receive(:config).and_return(config)
|
|
|
|
expect(described_class.default.id).to eq default
|
|
|
|
|
|
|
|
config = double(default_theme: themes.size + 5).as_null_object
|
|
|
|
allow(Gitlab).to receive(:config).and_return(config)
|
|
|
|
expect(described_class.default.id).to eq default
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.each' do
|
|
|
|
it 'passes the block to the THEMES Array' do
|
|
|
|
ids = []
|
|
|
|
described_class.each { |theme| ids << theme.id }
|
|
|
|
expect(ids).not_to be_empty
|
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
describe 'theme.css_filename' do
|
|
|
|
described_class.each do |theme|
|
|
|
|
next unless theme.css_filename
|
|
|
|
|
|
|
|
context "for #{theme.name}" do
|
|
|
|
it 'returns an existing CSS filename' do
|
|
|
|
css_file_path = Rails.root.join('app/assets/stylesheets/themes', theme.css_filename + '.scss')
|
|
|
|
|
|
|
|
expect(File.exist?(css_file_path)).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|