@@ -1065,6 +1065,18 module ApplicationHelper | |||||
1065 | super sources, options |
|
1065 | super sources, options | |
1066 | end |
|
1066 | end | |
1067 |
|
1067 | |||
|
1068 | # Overrides Rails' image_tag with plugins support. | |||
|
1069 | # Examples: | |||
|
1070 | # image_tag('image.png') # => picks defaults image.png | |||
|
1071 | # image_tag('image.png', :plugin => 'foo) # => picks image.png from plugin's assets | |||
|
1072 | # | |||
|
1073 | def image_tag(source, options={}) | |||
|
1074 | if plugin = options.delete(:plugin) | |||
|
1075 | source = "/plugin_assets/#{plugin}/images/#{source}" | |||
|
1076 | end | |||
|
1077 | super source, options | |||
|
1078 | end | |||
|
1079 | ||||
1068 | # Overrides Rails' javascript_include_tag with plugins support |
|
1080 | # Overrides Rails' javascript_include_tag with plugins support | |
1069 | # Examples: |
|
1081 | # Examples: | |
1070 | # javascript_include_tag('scripts') # => picks scripts.js from defaults |
|
1082 | # javascript_include_tag('scripts') # => picks scripts.js from defaults |
@@ -1054,6 +1054,14 RAW | |||||
1054 | assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"', stylesheet_link_tag("styles", :plugin => :foo) |
|
1054 | assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"', stylesheet_link_tag("styles", :plugin => :foo) | |
1055 | end |
|
1055 | end | |
1056 |
|
1056 | |||
|
1057 | def test_image_tag_should_pick_the_default_image | |||
|
1058 | assert_match 'src="/images/image.png"', image_tag("image.png") | |||
|
1059 | end | |||
|
1060 | ||||
|
1061 | def test_image_tag_sfor_plugin_should_pick_the_plugin_image | |||
|
1062 | assert_match 'src="/plugin_assets/foo/images/image.png"', image_tag("image.png", :plugin => :foo) | |||
|
1063 | end | |||
|
1064 | ||||
1057 | def test_javascript_include_tag_should_pick_the_default_javascript |
|
1065 | def test_javascript_include_tag_should_pick_the_default_javascript | |
1058 | assert_match 'src="/javascripts/scripts.js"', javascript_include_tag("scripts") |
|
1066 | assert_match 'src="/javascripts/scripts.js"', javascript_include_tag("scripts") | |
1059 | end |
|
1067 | end |
General Comments 0
You need to be logged in to leave comments.
Login now