1 ## Copyright 2004-2007 Castle Project - http://www.castleproject.org/
\r
3 ## Licensed under the Apache License, Version 2.0 (the "License");
\r
4 ## you may not use this file except in compliance with the License.
\r
5 ## You may obtain a copy of the License at
\r
7 ## http://www.apache.org/licenses/LICENSE-2.0
\r
9 ## Unless required by applicable law or agreed to in writing, software
\r
10 ## distributed under the License is distributed on an "AS IS" BASIS,
\r
11 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 ## See the License for the specific language governing comments and
\r
13 ## limitations under the License.
\r
21 include Test::Unit::Assertions
\r
23 def create(ie, name, type_id, *comments)
\r
25 ie.goto("#{$base_url}/condition/new.castle")
\r
27 ie.text_field(:id, "condition_name").set(name)
\r
28 ie.select_list(:id, "condition_ConditionType_id").select_value(type_id.to_s)
\r
30 comments.each { |value|
\r
31 ie.checkbox(:id, 'condition_comments', value.to_s).set
\r
34 ie.button(:id, 'insertbutton').click
\r
38 fail('There were databind errors') if ie.contains_text('binding error')
\r
39 fail('Unexpected exception') if ie.contains_text('Exception')
\r
41 assert_equal(name, ie.span(:id, 'name').text)
\r
42 assert_equal(type_id, ie.span(:id, 'type').text) unless type_id == "0"
\r
43 assert_equal(comments.sort!, ie.span(:id, 'comments').text.split(',').sort!)
\r
45 # returns new created id
\r
47 ie.span(:id, 'newid').text
\r
50 def edit(ie, id, name, type_id, *comments)
\r
52 ie.goto("#{$base_url}/condition/edit.castle?id=#{id}")
\r
54 ie.text_field(:id, "condition_name").set(name)
\r
55 ie.select_list(:id, "condition_ConditionType_id").select_value(type_id.to_s)
\r
57 # ie.checkboxes.each { |check| check.clear() }
\r
59 # comments.each { |value|
\r
60 # ie.checkbox(:id, 'condition_comments', value.to_s).set
\r
63 ie.button(:id, 'updatebutton').click
\r
67 fail('There were databind errors') if ie.contains_text('binding error')
\r
68 fail('Unexpected exception') if ie.contains_text('Exception')
\r
70 assert_equal(name, ie.span(:id, 'name').text)
\r
71 assert_equal(type_id, ie.span(:id, 'type').text) unless type_id == "0"
\r
72 assert_equal(comments.sort!, ie.span(:id, 'comments').text.split(',').sort!)
\r