/wheels/tests/view/assets/assetDomain.cfc

http://cfwheels.googlecode.com/ · ColdFusion CFScript · 55 lines · 47 code · 8 blank · 0 comment · 1 complexity · 96f2077695e44c95ec03682ce779ad1d MD5 · raw file

  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cfscript>
  4. loc.controller = controller(name="dummy");
  5. application.wheels.assetPaths = {http="asset0.localhost, asset2.localhost", https="secure.localhost"};
  6. </cfscript>
  7. </cffunction>
  8. <cffunction name="teardown">
  9. <cfscript>
  10. application.wheels.assetPaths = false;
  11. </cfscript>
  12. </cffunction>
  13. <cffunction name="test_returns_protocol">
  14. <cfscript>
  15. loc.assetPath = "/javascripts/path/to/my/asset.js";
  16. loc.e = loc.controller.$assetDomain(loc.assetPath);
  17. assert('FindNoCase("http://", loc.e) or FindNoCase("https://", loc.e)');
  18. </cfscript>
  19. </cffunction>
  20. <cffunction name="test_returns_secure_protocol">
  21. <cfscript>
  22. request.cgi.server_port_secure = true;
  23. loc.assetPath = "/javascripts/path/to/my/asset.js";
  24. loc.e = loc.controller.$assetDomain(loc.assetPath);
  25. assert('FindNoCase("https://", loc.e)');
  26. request.cgi.server_port_secure = "";
  27. </cfscript>
  28. </cffunction>
  29. <cffunction name="test_returns_same_domain_for_asset">
  30. <cfscript>
  31. loc.assetPath = "/javascripts/path/to/my/asset.js";
  32. loc.e = loc.controller.$assetDomain(loc.assetPath);
  33. loc.iEnd = 100;
  34. for (loc.i = 1; loc.i lte loc.iEnd; loc.i++)
  35. assert('loc.e eq loc.controller.$assetDomain(loc.assetPath)');
  36. </cfscript>
  37. </cffunction>
  38. <cffunction name="test_returns_asset_path_when_set_false">
  39. <cfscript>
  40. application.wheels.assetPaths = false;
  41. loc.assetPath = "/javascripts/path/to/my/asset.js";
  42. loc.e = loc.controller.$assetDomain(loc.assetPath);
  43. assert('loc.e eq loc.assetPath');
  44. application.wheels.assetPaths = {http="asset0.localhost, asset2.localhost", https="secure.localhost"};
  45. </cfscript>
  46. </cffunction>
  47. </cfcomponent>