Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 15
- Log:
Attempt to update Typo to a Typo SVN HEAD release from around the
time the prototype installation was set up on the RISC OS Open Limited
web site. Timestamps place this at 04-Jul so a revision from 05-Jul or
earlier was pulled and copied over the 2.6.0 tarball stable code.
- Author:
- adh
- Date:
- Sat Jul 22 23:27:35 +0100 2006
- Size:
- 6292 Bytes
1 | require File.dirname(__FILE__) + 'action_view/helpers/date_helper' |
2 | require File.dirname(__FILE__) + 'action_view/helpers/number_helper' |
3 | require File.dirname(__FILE__) + 'action_view/helpers/asset_tag_helper' |
4 | require File.dirname(__FILE__) + 'action_view/helpers/form_tag_helper' |
5 | require File.dirname(__FILE__) + 'action_view/helpers/tag_helper' |
6 | require File.dirname(__FILE__) + 'action_view/helpers/javascript_helper' |
7 | require File.dirname(__FILE__) + 'action_view/helpers/upload_progress_helper' |
8 | require File.dirname(__FILE__) + 'activesupport/lib/active_support/core_ext/hash' #for stringify keys |
9 | |
10 | class MockProgress |
11 | def initialize(started, finished) |
12 | @started, @finished = [started, finished] |
13 | end |
14 | |
15 | def started? |
16 | @started |
17 | end |
18 | |
19 | def finished? |
20 | @finished |
21 | end |
22 | |
23 | def message |
24 | "A message" |
25 | end |
26 | |
27 | def method_missing(meth, *args) |
28 | # Just return some consitant number |
29 | meth.to_s.hash.to_i.abs + args.hash.to_i.abs |
30 | end |
31 | end |
32 | |
33 | class UploadProgressHelperTest < Test::Unit::TestCase |
34 | include ActionView::Helpers::DateHelper |
35 | include ActionView::Helpers::NumberHelper |
36 | include ActionView::Helpers::AssetTagHelper |
37 | include ActionView::Helpers::FormTagHelper |
38 | include ActionView::Helpers::TagHelper |
39 | include ActionView::Helpers::UrlHelper |
40 | include ActionView::Helpers::JavaScriptHelper |
41 | include ActionView::Helpers::UploadProgressHelper |
42 | |
43 | def next_upload_id; @upload_id = last_upload_id.succ; end |
44 | def last_upload_id; @upload_id ||= 0; end |
45 | def current_upload_id; last_upload_id; end |
46 | def upload_progress(upload_id = nil); @upload_progress ||= MockProgress.new(false, true); end |
47 | |
48 | def setup |
49 | @controller = Class.new do |
50 | def url_for(options, *parameters_for_method_reference) |
51 | "http://www.example.com" |
52 | end |
53 | end |
54 | @controller = @controller.new |
55 | end |
56 | |
57 | def test_upload_status_tag |
58 | assert_dom_equal( |
59 | '<div class="progressBar" id="UploadProgressBar0"><div class="border"><div class="background"><div class="foreground"></div></div></div></div><div class="uploadStatus" id="UploadStatus0"></div>', |
60 | upload_status_tag |
61 | ) |
62 | end |
63 | |
64 | def test_upload_status_text_tag |
65 | assert_dom_equal( |
66 | '<div class="my-upload" id="my-id">Starting</div>', |
67 | upload_status_text_tag('Starting', :class => 'my-upload', :id => 'my-id') |
68 | ) |
69 | end |
70 | |
71 | |
72 | def test_upload_progress_text |
73 | @upload_progress = MockProgress.new(false, false) |
74 | assert_equal( |
75 | "Upload starting...", |
76 | upload_progress_text |
77 | ) |
78 | |
79 | @upload_progress = MockProgress.new(true, false) |
80 | assert_equal( |
81 | "828.7 MB of 456.2 MB at 990.1 MB/s; 10227 days remaining", |
82 | upload_progress_text |
83 | ) |
84 | |
85 | @upload_progress = MockProgress.new(true, true) |
86 | assert_equal( |
87 | "A message", |
88 | upload_progress_text |
89 | ) |
90 | end |
91 | |
92 | def test_upload_progress_update_bar_js |
93 | assert_equal( |
94 | "if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='0%'}", |
95 | upload_progress_update_bar_js |
96 | ) |
97 | |
98 | assert_equal( |
99 | "if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='50%'}", |
100 | upload_progress_update_bar_js(50) |
101 | ) |
102 | end |
103 | |
104 | def test_finish_upload_status |
105 | assert_dom_equal( |
106 | "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\n }\n }</script></head><body onload=\"finish()\"></body></html>", |
107 | finish_upload_status |
108 | ) |
109 | |
110 | assert_dom_equal( |
111 | "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop(123);\n }\n }</script></head><body onload=\"finish()\"></body></html>", |
112 | finish_upload_status(:client_js_argument => 123) |
113 | ) |
114 | |
115 | assert_dom_equal( |
116 | "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\nparent.location.replace('/redirected/');\n }\n }</script></head><body onload=\"finish()\"></body></html>", |
117 | finish_upload_status(:redirect_to => '/redirected/') |
118 | ) |
119 | end |
120 | |
121 | def test_form_tag_with_upload_progress |
122 | assert_dom_equal( |
123 | "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') < 0){ this.action += '?upload_id=1'; }this.target = 'UploadTarget1';$('UploadStatus1').innerHTML='Upload starting...'; if($('UploadProgressBar1')){$('UploadProgressBar1').firstChild.firstChild.style.width='0%'}; if (document.uploadStatus1) { document.uploadStatus1.stop(); }document.uploadStatus1 = new Ajax.PeriodicalUpdater('UploadStatus1','http://www.example.com', Object.extend({asynchronous:true, evalScripts:true, onComplete:function(request){$('UploadStatus1').innerHTML='A message';if($('UploadProgressBar1')){$('UploadProgressBar1').firstChild.firstChild.style.width='100%'};document.uploadStatus1 = null}},{decay:1.8,frequency:2.0})); return true\"><iframe id=\"UploadTarget1\" name=\"UploadTarget1\" src=\"\" style=\"width:0px;height:0px;border:0\"></iframe>", |
124 | form_tag_with_upload_progress |
125 | ) |
126 | end |
127 | |
128 | def test_form_tag_with_upload_progress_custom |
129 | assert_dom_equal( |
130 | "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') < 0){ this.action += '?upload_id=5'; }this.target = 'awindow';$('UploadStatus0').innerHTML='Upload starting...'; if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='0%'}; alert('foo'); if (document.uploadStatus0) { document.uploadStatus0.stop(); }document.uploadStatus0 = new Ajax.PeriodicalUpdater('UploadStatus0','http://www.example.com', Object.extend({asynchronous:true, evalScripts:true, onComplete:function(request){$('UploadStatus0').innerHTML='A message';if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='100%'};document.uploadStatus0 = null; alert('bar')}},{decay:7,frequency:6})); return true\" target=\"awindow\">", |
131 | form_tag_with_upload_progress({:upload_id => 5}, {:begin => "alert('foo')", :finish => "alert('bar')", :frequency => 6, :decay => 7, :target => 'awindow'}) |
132 | ) |
133 | end |
134 | end |