kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.0 KiB
106 lines
3.0 KiB
12 years ago
|
#-- copyright
|
||
|
# OpenProject is a project management system.
|
||
|
#
|
||
|
# Copyright (C) 2012-2013 the OpenProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
12 years ago
|
require 'spec_helper'
|
||
|
|
||
12 years ago
|
module OpenProject
|
||
12 years ago
|
describe Themes do
|
||
12 years ago
|
before { Themes.clear_themes }
|
||
12 years ago
|
|
||
12 years ago
|
describe '.new_theme' do
|
||
|
it "returns a new theme" do
|
||
|
theme = Themes.new_theme(:new_theme)
|
||
|
expect(theme).to be_kind_of Themes::Theme
|
||
|
expect(theme.identifier).to eq :new_theme
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.themes' do
|
||
12 years ago
|
it "returns the known themes" do
|
||
12 years ago
|
theme = Themes.new_theme
|
||
|
expect(Themes.themes).to include theme
|
||
12 years ago
|
end
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
12 years ago
|
describe '.clear_themes' do
|
||
12 years ago
|
it "clears the known themes" do
|
||
12 years ago
|
theme = Themes.new_theme
|
||
|
Themes.clear_themes
|
||
|
expect(Themes.themes).to be_empty
|
||
12 years ago
|
end
|
||
12 years ago
|
end
|
||
12 years ago
|
|
||
12 years ago
|
describe '.theme' do
|
||
|
it "returns a theme by name" do
|
||
|
theme = Themes.new_theme(:new_theme)
|
||
|
expect(Themes.theme(:new_theme)).to be theme
|
||
12 years ago
|
end
|
||
|
|
||
12 years ago
|
it "returns the default theme if theme not found" do
|
||
|
expect(Themes.theme(:missing_theme)).to be Themes.default_theme
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.default_theme' do
|
||
|
it "returns the instance of the default theme class" do
|
||
|
expect(Themes.default_theme).to be Themes::DefaultTheme.instance
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.each' do
|
||
|
it "iterates over the registered themes" do
|
||
|
Themes.new_theme(:new_theme)
|
||
|
themes = []
|
||
|
Themes.each { |theme| themes << theme.identifier }
|
||
|
expect(themes).to eq [:new_theme]
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.inject' do
|
||
|
it "iterates over the registered themes" do
|
||
|
Themes.new_theme(:new_theme)
|
||
|
identifiers = Themes.inject [] { |themes, theme| themes << theme.identifier }
|
||
|
expect(identifiers).to eq [:new_theme]
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.current_theme' do
|
||
|
it "returns the theme with identifier defined by current theme identifier" do
|
||
|
theme = Themes.new_theme :new_theme
|
||
|
Themes.stub(:current_theme_identifier).and_return :new_theme
|
||
|
expect(Themes.current_theme).to eq theme
|
||
12 years ago
|
end
|
||
|
|
||
12 years ago
|
it "returns the default theme if configured theme wasn't found" do
|
||
|
Themes.stub(:current_theme_identifier).and_return :missing_theme
|
||
|
expect(Themes.current_theme).to eq Themes.default_theme
|
||
12 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
describe '.current_theme_identifier' do
|
||
|
it "normalizes current theme setting to a symbol" do
|
||
|
Setting.stub(:ui_theme).and_return 'new_theme'
|
||
|
expect(Themes.current_theme_identifier).to eq :new_theme
|
||
12 years ago
|
end
|
||
|
|
||
12 years ago
|
it "returns nil for an empty string" do
|
||
|
Setting.stub(:ui_theme).and_return ''
|
||
|
expect(Themes.current_theme_identifier).to be_nil
|
||
12 years ago
|
end
|
||
|
|
||
12 years ago
|
it "returns nil for nil" do
|
||
|
Setting.stub(:ui_theme).and_return nil
|
||
|
expect(Themes.current_theme_identifier).to be_nil
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
12 years ago
|
end
|