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, name, email, password, confirmation, prod_lic_id, *permissions)
\r
25 ie.goto("#{$base_url}/account/new.castle")
\r
27 send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)
\r
30 def create2(ie, name, email, password, confirmation, prod_lic_id, *permissions)
\r
32 ie.goto("#{$base_url}/account/new2.castle")
\r
34 send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)
\r
37 def edit(ie, id, name, email, password, confirmation, prod_lic_id, *permissions)
\r
39 ie.goto("#{$base_url}/account/edit.castle?id=#{id}")
\r
41 send_edit(ie, id, name, email, password, confirmation, prod_lic_id, permissions)
\r
46 ie.goto("#{$base_url}/account/removeconfirm.castle?id=#{id}")
\r
48 fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")
\r
50 ie.button(:id, 'button').click
\r
52 fail('Error removing instance') unless ie.contains_text('Removed')
\r
53 fail('Unexpected exception') if ie.contains_text('Exception')
\r
59 def send_create(ie, name, email, password, confirmation, prod_lic_id, permissions)
\r
61 ie.text_field(:id, "account_name").set(name)
\r
62 ie.text_field(:id, "account_email").set(email)
\r
63 ie.text_field(:id, "account_password").set(password)
\r
64 ie.text_field(:id, "account_confirmationpassword").set(confirmation)
\r
65 ie.select_list(:id, "account_ProductLicense_id").select_value(prod_lic_id.to_s)
\r
67 permissions.each { |value|
\r
68 ie.checkbox(:id, 'account_permissions', value.to_s).set
\r
71 ie.button(:id, 'insertbutton').click
\r
75 fail('There were databind errors') if ie.contains_text('binding error')
\r
76 fail('Unexpected exception') if ie.contains_text('Exception')
\r
78 assert_equal(name, ie.span(:id, 'name').text)
\r
79 assert_equal(email, ie.span(:id, 'email').text)
\r
80 assert_equal(password, ie.span(:id, 'password').text)
\r
81 assert_equal(prod_lic_id, ie.span(:id, 'pl').text) unless prod_lic_id == "0"
\r
82 assert_equal(permissions.sort!, ie.span(:id, 'permissions').text.split(',').sort!)
\r
84 # returns new created id
\r
86 ie.span(:id, 'newid').text
\r
89 def send_edit(ie, id, name, email, password, confirmation, prod_lic_id, permissions)
\r
91 ie.text_field(:id, "account_name").set(name)
\r
92 ie.text_field(:id, "account_email").set(email)
\r
93 ie.text_field(:id, "account_password").set(password)
\r
94 ie.text_field(:id, "account_confirmationpassword").set(confirmation)
\r
95 ie.select_list(:id, "account_ProductLicense_id").select_value(prod_lic_id.to_s)
\r
97 ie.checkboxes.each { |check| check.clear() }
\r
99 permissions.each { |value|
\r
100 ie.checkbox(:id, 'account_permissions', value.to_s).set
\r
103 ie.button(:id, 'updatebutton').click
\r
107 fail('There were databind errors') if ie.contains_text('binding error')
\r
108 fail('Unexpected exception') if ie.contains_text('Exception')
\r
110 assert_equal(name, ie.span(:id, 'name').text)
\r
111 assert_equal(email, ie.span(:id, 'email').text)
\r
112 assert_equal(password, ie.span(:id, 'password').text)
\r
113 assert_equal(prod_lic_id, ie.span(:id, 'pl').text) unless prod_lic_id == "0"
\r
114 assert_equal(permissions.sort!, ie.span(:id, 'permissions').text.split(',').sort!)
\r