Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 1567 Bytes
- Properties:
- Property svn:executable is set to *
1 | module ValidationTestHelper |
2 | def assert_valid(field, *values) |
3 | __model_check__ |
4 | values.flatten.each do |value| |
5 | o = __setup_model__(field, value) |
6 | if o.valid? |
7 | assert_block { true } |
8 | else |
9 | messages = [o.errors[field]].flatten |
10 | assert_block("unexpected invalid field <#{o.class}##{field}>, value: <#{value.inspect}>, errors: <#{o.errors[field].inspect}>.") { false } |
11 | end |
12 | end |
13 | end |
14 | |
15 | def assert_invalid(field, message, *values) |
16 | __model_check__ |
17 | values.flatten.each do |value| |
18 | o = __setup_model__(field, value) |
19 | if o.valid? |
20 | assert_block("field <#{o.class}##{field}> should be invalid for value <#{value.inspect}> with message <#{message.inspect}>") { false } |
21 | else |
22 | messages = [o.errors[field]].flatten |
23 | assert_block("field <#{o.class}##{field}> with value <#{value.inspect}> expected validation error <#{message.inspect}>, but got errors <#{messages.inspect}>") { messages.include?(message) } |
24 | end |
25 | end |
26 | end |
27 | |
28 | def __model_check__ |
29 | raise "@model must be assigned in order to use validation assertions" if @model.nil? |
30 | |
31 | o = @model.dup |
32 | raise "@model must be valid before calling a validation assertion, instead @model contained the following errors #{o.errors.instance_variable_get('@errors').inspect}" unless o.valid? |
33 | end |
34 | |
35 | def __setup_model__(field, value) |
36 | o = @model.dup |
37 | attributes = o.instance_variable_get('@attributes') |
38 | o.instance_variable_set('@attributes', attributes.dup) |
39 | o.send("#{field}=", value) |
40 | o |
41 | end |
42 | end |