Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 4756 Bytes
1 | ENV["RAILS_ENV"] = "test" |
2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
3 | require 'test_help' |
4 | |
5 | $TESTING = true |
6 | |
7 | User.salt = 'change-me' |
8 | |
9 | class Test::Unit::TestCase |
10 | # Turn off transactional fixtures if you're working with MyISAM tables in MySQL |
11 | self.use_transactional_fixtures = true |
12 | |
13 | # Instantiated fixtures are slow, but give you @david where you otherwise would need people(:david) |
14 | self.use_instantiated_fixtures = false |
15 | |
16 | def run(result) |
17 | yield(STARTED, name) |
18 | @_result = result |
19 | begin |
20 | CachedModel.cache_reset |
21 | setup |
22 | __send__(@method_name) |
23 | rescue Test::Unit::AssertionFailedError => e |
24 | add_failure(e.message, e.backtrace) |
25 | rescue StandardError, ScriptError |
26 | add_error($!) |
27 | ensure |
28 | begin |
29 | teardown |
30 | rescue Test::Unit::AssertionFailedError => e |
31 | add_failure(e.message, e.backtrace) |
32 | rescue StandardError, ScriptError |
33 | add_error($!) |
34 | end |
35 | end |
36 | result.add_run |
37 | yield(FINISHED, name) |
38 | end |
39 | |
40 | |
41 | # Add more helper methods to be used by all tests here... |
42 | def assert_xml(xml) |
43 | assert_nothing_raised do |
44 | assert REXML::Document.new(xml) |
45 | end |
46 | end |
47 | |
48 | # Add more helper methods to be used by all tests here... |
49 | def find_tag_in(source, conditions) |
50 | HTML::Document.new(source).find(conditions) |
51 | end |
52 | |
53 | def assert_tag_in(source, opts) |
54 | tag = find_tag_in(source, opts) |
55 | assert tag, "expected tag, but no tag found matching #{opts.inspect} in:\n#{source.inspect}" |
56 | end |
57 | |
58 | def assert_no_tag_in(source, opts) |
59 | tag = find_tag_in(source, opts) |
60 | assert !tag, "expected no tag, but tag found matching #{opts.inspect} in:\n#{source.inspect}" |
61 | end |
62 | |
63 | def get_xpath(xpath) |
64 | rexml = REXML::Document.new(@response.body) |
65 | assert rexml |
66 | |
67 | REXML::XPath.match(rexml, xpath) |
68 | end |
69 | |
70 | def assert_xpath(xpath, msg=nil) |
71 | assert !(get_xpath(xpath).empty?), msg |
72 | end |
73 | |
74 | def assert_not_xpath(xpath, msg=nil) |
75 | assert get_xpath(xpath).empty?, msg |
76 | end |
77 | |
78 | def this_blog |
79 | Blog.default || Blog.create! |
80 | end |
81 | |
82 | def assert_template_has(key=nil, message=nil) |
83 | msg = build_message(message, "<?> is not a template object", key) |
84 | assert_block(msg) { @response.has_template_object?(key) } |
85 | end |
86 | |
87 | def assert_template_has_no(key=nil, message=nil) |
88 | msg = build_message(message, "<?> is a template object <?>", |
89 | key, @response.template_objects[key]) |
90 | assert_block(msg) { !@response.has_template_object?(key) } |
91 | end |
92 | |
93 | def assert_session_has(key=nil, message=nil) |
94 | msg = build_message(message, "<?> is not in the session <?>", |
95 | key, @response.session) |
96 | assert_block(msg) { @response.has_session_object?(key) } |
97 | end |
98 | |
99 | def assert_session_has_no(key=nil, message=nil) |
100 | msg = build_message(message, "<?> is in the session <?>", |
101 | key, @response.session) |
102 | assert_block(msg) { !@response.has_session_object?(key) } |
103 | end |
104 | |
105 | def assert_invalid_column_on_record(key = nil, columns = "", message = nil) #:nodoc: |
106 | record = find_record_in_template(key) |
107 | record.send(:validate) |
108 | |
109 | cols = glue_columns(columns) |
110 | cols.delete_if { |col| record.errors.invalid?(col) } |
111 | msg = build_message(message, "Active Record has valid columns <?>)", cols.join(",") ) |
112 | assert_block(msg) { cols.empty? } |
113 | end |
114 | |
115 | def glue_columns(columns) |
116 | cols = [] |
117 | cols << columns if columns.class == String |
118 | cols += columns if columns.class == Array |
119 | cols |
120 | end |
121 | |
122 | def find_record_in_template(key = nil) |
123 | assert_not_nil assigns(key) |
124 | record = @response.template_objects[key] |
125 | |
126 | assert_not_nil(record) |
127 | assert_kind_of ActiveRecord::Base, record |
128 | |
129 | return record |
130 | end |
131 | end |
132 | |
133 | # Extend HTML::Tag to understand URI matching |
134 | begin |
135 | require 'html/document' |
136 | rescue LoadError |
137 | require 'action_controller/vendor/html-scanner/html/document' |
138 | end |
139 | require 'uri' |
140 | |
141 | class HTML::Tag |
142 | private |
143 | |
144 | alias :match_condition_orig :match_condition unless private_method_defined? :match_condition_orig |
145 | def match_condition(value, condition) |
146 | case condition |
147 | when URI |
148 | compare_uri(URI.parse(value), condition.dup) rescue nil |
149 | else |
150 | match_condition_orig(value, condition) |
151 | end |
152 | end |
153 | |
154 | def compare_uri(value, condition) |
155 | valQuery = value.query |
156 | condQuery = condition.query |
157 | value.query = nil |
158 | condition.query = nil |
159 | value == condition && compare_query(valQuery, condQuery) |
160 | end |
161 | |
162 | def compare_query(value, condition) |
163 | def create_query_hash(str) |
164 | str.split('&').inject({}) do |h,v| |
165 | key, value = v.split('=') |
166 | h[key] = value |
167 | h |
168 | end |
169 | end |
170 | create_query_hash(value) == create_query_hash(condition) |
171 | end |
172 | end |