Sha256: 15c5d4bc21644c1f2e8813252a029cc2d74baadef8c741d0f052d061bc660162
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
require File.expand_path '../helper', __FILE__ require 'projectlocker_errata/rails/javascript_notifier' require 'ostruct' class JavascriptNotifierTest < Test::Unit::TestCase module FakeRenderer def javascript_tag(text) "<script>#{text}</script>" end def escape_javascript(text) "ESC#{text}ESC" end end class FakeController def self.helper_method(*args) end include ProjectlockerErrata::Rails::JavascriptNotifier def action_name "action" end def controller_name "controller" end def request @request ||= OpenStruct.new end def render_to_string(options) context = OpenStruct.new(options[:locals]) context.extend(FakeRenderer) context.instance_eval do erb = ERB.new(IO.read(options[:file])) erb.result(binding) end end end should "make sure escape_javacript is called on the request.url" do ProjectlockerErrata.configure do end controller = FakeController.new controller.request.url = "bad_javascript" assert controller.send(:projectlocker_errata_javascript_notifier)['"ESCbad_javascriptESC"'] assert ! controller.send(:projectlocker_errata_javascript_notifier)['"bad_javascript"'] end end
Version data entries
4 entries across 4 versions & 1 rubygems