comparison test/integration/lib/redmine/themes_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
30 30
31 def test_application_css 31 def test_application_css
32 get '/' 32 get '/'
33 33
34 assert_response :success 34 assert_response :success
35 assert_tag :tag => 'link', 35 assert_select "link[rel=stylesheet][href^=/themes/#{@theme.dir}/stylesheets/application.css]"
36 :attributes => {:href => %r{^/themes/#{@theme.dir}/stylesheets/application.css}}
37 end 36 end
38 37
39 def test_without_theme_js 38 def test_without_theme_js
40 get '/' 39 get '/'
41 40
42 assert_response :success 41 assert_response :success
43 assert_no_tag :tag => 'script', 42 assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 0
44 :attributes => {:src => %r{^/themes/#{@theme.dir}/javascripts/theme.js}}
45 end 43 end
46 44
47 def test_with_theme_js 45 def test_with_theme_js
48 # Simulates a theme.js 46 # Simulates a theme.js
49 @theme.javascripts << 'theme' 47 @theme.javascripts << 'theme'
50 get '/' 48 get '/'
51 49
52 assert_response :success 50 assert_response :success
53 assert_tag :tag => 'script', 51 assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 1
54 :attributes => {:src => %r{^/themes/#{@theme.dir}/javascripts/theme.js}}
55
56 ensure 52 ensure
57 @theme.javascripts.delete 'theme' 53 @theme.javascripts.delete 'theme'
54 end
55
56 def test_use_default_favicon_if_theme_provides_none
57 get '/'
58
59 assert_response :success
60 assert_select 'link[rel=shortcut icon][href^=/favicon.ico]'
61 end
62
63 def test_use_theme_favicon_if_theme_provides_one
64 # Simulate a theme favicon
65 @theme.favicons << 'a.ico'
66 get '/'
67
68 assert_response :success
69 assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/a.ico]"
70 ensure
71 @theme.favicons.delete 'a.ico'
72 end
73
74 def test_use_only_one_theme_favicon_if_theme_provides_many
75 @theme.favicons.concat %w{b.ico a.png}
76 get '/'
77
78 assert_response :success
79 assert_select "link[rel=shortcut icon]", 1
80 assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/b.ico]"
81 ensure
82 @theme.favicons.delete("b.ico")
83 @theme.favicons.delete("a.png")
58 end 84 end
59 85
60 def test_with_sub_uri 86 def test_with_sub_uri
61 Redmine::Utils.relative_url_root = '/foo' 87 Redmine::Utils.relative_url_root = '/foo'
62 @theme.javascripts << 'theme' 88 @theme.javascripts << 'theme'
89 @theme.favicons << 'a.ico'
63 get '/' 90 get '/'
64 91
65 assert_response :success 92 assert_response :success
66 assert_tag :tag => 'link', 93 assert_select "link[rel=stylesheet][href^=/foo/themes/#{@theme.dir}/stylesheets/application.css]"
67 :attributes => {:href => %r{^/foo/themes/#{@theme.dir}/stylesheets/application.css}} 94 assert_select "script[src^=/foo/themes/#{@theme.dir}/javascripts/theme.js]"
68 assert_tag :tag => 'script', 95 assert_select "link[rel=shortcut icon][href^=/foo/themes/#{@theme.dir}/favicon/a.ico]"
69 :attributes => {:src => %r{^/foo/themes/#{@theme.dir}/javascripts/theme.js}}
70
71 ensure 96 ensure
72 Redmine::Utils.relative_url_root = '' 97 Redmine::Utils.relative_url_root = ''
73 end 98 end
74 end 99 end