diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-08-17 18:37:36 +0300 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2017-09-06 20:54:09 +0300 |
commit | 6c49a628000605d1beb120431003abb329b9fd16 (patch) | |
tree | 03ede462b30999149411ec70287f6aad2507eb56 /spec/lib/gitlab/themes_spec.rb | |
parent | 8d1321d66977dc50577cf23f7cb0a6e9caa8283e (diff) |
Restore some changes from !9199
Diffstat (limited to 'spec/lib/gitlab/themes_spec.rb')
-rw-r--r-- | spec/lib/gitlab/themes_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/lib/gitlab/themes_spec.rb b/spec/lib/gitlab/themes_spec.rb new file mode 100644 index 00000000000..7a140518dd2 --- /dev/null +++ b/spec/lib/gitlab/themes_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe Gitlab::Themes, lib: true do + describe '.body_classes' do + it 'returns a space-separated list of class names' do + css = described_class.body_classes + + expect(css).to include('ui_graphite') + expect(css).to include(' ui_charcoal ') + expect(css).to include(' ui_blue') + end + end + + describe '.by_id' do + it 'returns a Theme by its ID' do + expect(described_class.by_id(1).name).to eq 'Graphite' + expect(described_class.by_id(6).name).to eq 'Blue' + 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 + themes = described_class::THEMES + + 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 +end |