PageRenderTime 101ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 39ms app.codeStats 0ms

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