Browse Source

Fix tests after asset pipeline implementation (#39111).

Patch by Takashi Kato (@tohosaku).

git-svn-id: https://svn.redmine.org/redmine/trunk@22628 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/145/merge
Marius Balteanu 4 months ago
parent
commit
88a8234513

+ 8
- 8
test/helpers/application_helper_test.rb View File

end end


def test_stylesheet_link_tag_should_pick_the_default_stylesheet def test_stylesheet_link_tag_should_pick_the_default_stylesheet
assert_match 'href="/stylesheets/styles.css"', stylesheet_link_tag("styles")
assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles")
end end


def test_stylesheet_link_tag_for_plugin_should_pick_the_plugin_stylesheet def test_stylesheet_link_tag_for_plugin_should_pick_the_plugin_stylesheet
assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"',
assert_match 'href="/assets/plugin_assets/foo/styles.css"',
stylesheet_link_tag("styles", :plugin => :foo) stylesheet_link_tag("styles", :plugin => :foo)
end end


def test_image_tag_should_pick_the_default_image def test_image_tag_should_pick_the_default_image
assert_match 'src="/images/image.png"', image_tag("image.png")
assert_match 'src="/assets/image.png"', image_tag("image.png")
end end


def test_image_tag_should_pick_the_theme_image_if_it_exists def test_image_tag_should_pick_the_theme_image_if_it_exists
theme.images << 'image.png' theme.images << 'image.png'


with_settings :ui_theme => theme.id do with_settings :ui_theme => theme.id do
assert_match %|src="/themes/#{theme.dir}/images/image.png"|, image_tag("image.png")
assert_match %|src="/images/other.png"|, image_tag("other.png")
assert_match %|src="/assets/themes/#{theme.dir}/image.png"|, image_tag("image.png")
assert_match %|src="/assets/other.png"|, image_tag("other.png")
end end
ensure ensure
theme.images.delete 'image.png' theme.images.delete 'image.png'
end end


def test_image_tag_sfor_plugin_should_pick_the_plugin_image def test_image_tag_sfor_plugin_should_pick_the_plugin_image
assert_match 'src="/plugin_assets/foo/images/image.png"', image_tag("image.png", :plugin => :foo)
assert_match 'src="/assets/plugin_assets/foo/image.png"', image_tag("image.png", :plugin => :foo)
end end


def test_javascript_include_tag_should_pick_the_default_javascript def test_javascript_include_tag_should_pick_the_default_javascript
assert_match 'src="/javascripts/scripts.js"', javascript_include_tag("scripts")
assert_match 'src="/assets/scripts.js"', javascript_include_tag("scripts")
end end


def test_javascript_include_tag_for_plugin_should_pick_the_plugin_javascript def test_javascript_include_tag_for_plugin_should_pick_the_plugin_javascript
assert_match 'src="/plugin_assets/foo/javascripts/scripts.js"', javascript_include_tag("scripts", :plugin => :foo)
assert_match 'src="/assets/plugin_assets/foo/scripts.js"', javascript_include_tag("scripts", :plugin => :foo)
end end


def test_raw_json_should_escape_closing_tags def test_raw_json_should_escape_closing_tags

+ 2
- 2
test/helpers/avatars_helper_test.rb View File

end end


def test_avatar_with_anonymous_user def test_avatar_with_anonymous_user
assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
assert_match %r{src="/assets/anonymous(-\w+)?.png"}, avatar(User.anonymous)
end end


def test_avatar_with_group def test_avatar_with_group
assert_match %r{src="/images/group.png(\?\d+)?"}, avatar(Group.first)
assert_match %r{src="/assets/group(-\w+)?.png"}, avatar(Group.first)
end end


def test_avatar_with_invalid_arg_should_return_nil def test_avatar_with_invalid_arg_should_return_nil

+ 9
- 9
test/integration/layout_test.rb View File

Role.anonymous.add_permission! :add_issues Role.anonymous.add_permission! :add_issues


get '/projects/ecookbook/issues/new' get '/projects/ecookbook/issues/new'
assert_select 'head script[src^=?]', '/javascripts/jstoolbar/jstoolbar.js?'
assert_select "head script:match('src',?)", %r{/assets/jstoolbar/jstoolbar-\w+.js}
assert_include "var userHlLanguages = #{UserPreference::DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.to_json};", response.body assert_include "var userHlLanguages = #{UserPreference::DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.to_json};", response.body
end end


def test_calendar_header_tags def test_calendar_header_tags
with_settings :default_language => 'fr' do with_settings :default_language => 'fr' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-fr.js", response.body
assert_match %r{/assets/i18n/datepicker-fr-\w+.js}, response.body
end end


with_settings :default_language => 'en-GB' do with_settings :default_language => 'en-GB' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-en-GB.js", response.body
assert_match %r{/assets/i18n/datepicker-en-GB-\w+.js}, response.body
end end


with_settings :default_language => 'en' do with_settings :default_language => 'en' do
get '/issues' get '/issues'
assert_not_include "/javascripts/i18n/datepicker", response.body
assert_not_include "/assets/i18n/datepicker", response.body
end end


with_settings :default_language => 'es' do with_settings :default_language => 'es' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-es.js", response.body
assert_match %r{/assets/i18n/datepicker-es-\w+.js}, response.body
end end


with_settings :default_language => 'es-PA' do with_settings :default_language => 'es-PA' do


with_settings :default_language => 'zh' do with_settings :default_language => 'zh' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-zh-CN.js", response.body
assert_match %r{/assets/i18n/datepicker-zh-CN-\w+.js}, response.body
end end


with_settings :default_language => 'zh-TW' do with_settings :default_language => 'zh-TW' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-zh-TW.js", response.body
assert_match %r{/assets/i18n/datepicker-zh-TW-\w+.js}, response.body
end end


with_settings :default_language => 'pt' do with_settings :default_language => 'pt' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-pt.js", response.body
assert_match %r{/assets/i18n/datepicker-pt-\w+.js}, response.body
end end


with_settings :default_language => 'pt-BR' do with_settings :default_language => 'pt-BR' do
get '/issues' get '/issues'
assert_include "/javascripts/i18n/datepicker-pt-BR.js", response.body
assert_match %r{/assets/i18n/datepicker-pt-BR-\w+.js}, response.body
end end
end end



+ 1
- 1
test/integration/lib/redmine/hook_test.rb View File

Redmine::Hook.add_listener(ProjectBasedTemplate) Redmine::Hook.add_listener(ProjectBasedTemplate)


get '/projects/ecookbook' get '/projects/ecookbook'
assert_select 'head link[href=?]', '/stylesheets/ecookbook.css'
assert_select 'head link[href=?]', '/assets/ecookbook.css'
end end


def test_empty_sidebar_should_be_hidden def test_empty_sidebar_should_be_hidden

+ 8
- 8
test/integration/lib/redmine/themes_test.rb View File

get '/' get '/'


assert_response :success assert_response :success
assert_select "link[rel=stylesheet][href^=?]", "/themes/#{@theme.dir}/stylesheets/application.css"
assert_select "link[rel=stylesheet]:match('href', ?)", %r{/assets/themes/#{@theme.dir}/application-\w+\.css}
end end


def test_without_theme_js def test_without_theme_js
get '/' get '/'


assert_response :success assert_response :success
assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 0
assert_select "script[src^=?]", "/assets/themes/#{@theme.dir}/theme.js", 0
end end


def test_with_theme_js def test_with_theme_js
get '/' get '/'


assert_response :success assert_response :success
assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 1
assert_select "script[src^=?]", "/assets/themes/#{@theme.dir}/theme.js", 1
ensure ensure
@theme.javascripts.delete 'theme' @theme.javascripts.delete 'theme'
end end
get '/' get '/'


assert_response :success assert_response :success
assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/a.ico"
assert_select 'link[rel="shortcut icon"][href^=?]', "/assets/themes/#{@theme.dir}/a.ico"
ensure ensure
@theme.favicons.delete 'a.ico' @theme.favicons.delete 'a.ico'
end end


assert_response :success assert_response :success
assert_select 'link[rel="shortcut icon"]', 1 assert_select 'link[rel="shortcut icon"]', 1
assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/b.ico"
assert_select 'link[rel="shortcut icon"][href^=?]', "/assets/themes/#{@theme.dir}/b.ico"
ensure ensure
@theme.favicons.delete("b.ico") @theme.favicons.delete("b.ico")
@theme.favicons.delete("a.png") @theme.favicons.delete("a.png")
get '/' get '/'


assert_response :success assert_response :success
assert_select "link[rel=stylesheet][href^=?]", "/foo/themes/#{@theme.dir}/stylesheets/application.css"
assert_select "script[src^=?]", "/foo/themes/#{@theme.dir}/javascripts/theme.js"
assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/themes/#{@theme.dir}/favicon/a.ico"
assert_select "link[rel=stylesheet]:match('href', ?)", %r{/foo/assets/themes/#{@theme.dir}/application-\w+\.css}
assert_select "script[src^=?]", "/foo/assets/themes/#{@theme.dir}/theme.js"
assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/assets/themes/#{@theme.dir}/a.ico"
ensure ensure
Redmine::Utils.relative_url_root = '' Redmine::Utils.relative_url_root = ''
end end

+ 1
- 0
test/test_helper.rb View File



class HelperTest < ActionView::TestCase class HelperTest < ActionView::TestCase
include Redmine::I18n include Redmine::I18n
include Propshaft::Helper


def setup def setup
super super

Loading…
Cancel
Save