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 permissions and
\r
13 ## limitations under the License.
\r
21 include Test::Unit::Assertions
\r
23 def create(ie, first, middle, last, username, password)
\r
25 ie.goto("#{$base_url}/personuser/new.castle")
\r
27 send_create(ie, first, middle, last, username, password)
\r
30 def edit(ie, id, first, middle, last, username, password)
\r
32 ie.goto("#{$base_url}/personuser/edit.castle?id=#{id}")
\r
34 send_edit(ie, id, first, middle, last, username, password)
\r
39 ie.goto("#{$base_url}/personuser/removeconfirm.castle?id=#{id}")
\r
41 fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")
\r
43 ie.button(:id, 'button').click
\r
45 fail('Error removing instance') unless ie.contains_text('Removed')
\r
46 fail('Unexpected exception') if ie.contains_text('Exception')
\r
52 def send_create(ie, first, middle, last, username, password)
\r
54 ie.text_field(:id, "user_first").set(first)
\r
55 ie.text_field(:id, "user_middle").set(middle)
\r
56 ie.text_field(:id, "user_last").set(last)
\r
57 ie.text_field(:id, "user_username").set(username)
\r
58 ie.text_field(:id, "user_password").set(password)
\r
60 ie.button(:id, 'insertbutton').click
\r
64 fail('There were databind errors') if ie.contains_text('binding error')
\r
65 fail('Unexpected exception') if ie.contains_text('Exception')
\r
67 assert_equal(first, ie.span(:id, 'first').text)
\r
68 assert_equal(middle, ie.span(:id, 'middle').text)
\r
69 assert_equal(last, ie.span(:id, 'last').text)
\r
70 assert_equal(username, ie.span(:id, 'username').text)
\r
71 assert_equal(password, ie.span(:id, 'password').text)
\r
73 # returns new created id
\r
75 ie.span(:id, 'newid').text
\r
78 def send_edit(ie, id, first, middle, last, username, password)
\r
80 ie.text_field(:id, "user_first").set(first)
\r
81 ie.text_field(:id, "user_middle").set(middle)
\r
82 ie.text_field(:id, "user_last").set(last)
\r
83 ie.text_field(:id, "user_username").set(username)
\r
84 ie.text_field(:id, "user_password").set(password)
\r
86 ie.button(:id, 'updatebutton').click
\r
90 fail('There were databind errors') if ie.contains_text('binding error')
\r
91 fail('Unexpected exception') if ie.contains_text('Exception')
\r
93 assert_equal(first, ie.span(:id, 'first').text)
\r
94 assert_equal(middle, ie.span(:id, 'middle').text)
\r
95 assert_equal(last, ie.span(:id, 'last').text)
\r
96 assert_equal(username, ie.span(:id, 'username').text)
\r
97 assert_equal(password, ie.span(:id, 'password').text)
\r