theme_loader_helper_test.rb
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# encoding: UTF-8
require_relative "../test_helper"
class ThemeLoaderHelperTest < ActionView::TestCase
include ThemeLoaderHelper
should 'get theme from environment by default' do
@environment = mock
@environment.stubs(:theme).returns('my-environment-theme')
stubs(:profile).returns(nil)
stubs(:environment).returns(@environment)
assert_equal 'my-environment-theme', current_theme
end
should 'get theme from profile when profile is present' do
profile = mock
profile.stubs(:theme).returns('my-profile-theme')
stubs(:profile).returns(profile)
assert_equal 'my-profile-theme', current_theme
end
should 'override theme with testing theme from session' do
stubs(:session).returns(:user_theme => 'theme-under-test')
assert_equal 'theme-under-test', current_theme
end
should 'point to system theme path by default' do
expects(:current_theme).returns('my-system-theme')
assert_equal '/designs/themes/my-system-theme', theme_path
end
should 'point to user theme path when testing theme' do
stubs(:session).returns({:user_theme => 'theme-under-test'})
assert_equal '/user_themes/theme-under-test', theme_path
end
should 'point to session theme is defined' do
session = mock
stubs(:session).returns(session)
my_session_theme = 'session_theme'
session.stubs(:[]).with(:user_theme).returns(nil)
session.stubs(:[]).with(:theme).returns(my_session_theme)
assert_equal '/designs/themes/' + my_session_theme, theme_path
end
end