Minor changes to improve testability of helpers
[castle.git] / MonoRail / WatirTestCases / ARSupport / accountpermission.rb
blobe6caff4598146525b99f6763d9bac7897c24b251
1 ## Copyright 2004-2007 Castle Project - http://www.castleproject.org/\r
2 ## \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
6 ## \r
7 ##     http://www.apache.org/licenses/LICENSE-2.0\r
8 ## \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
15 require '../common'\r
17 class AccountPermission\r
19         class << self\r
21                 include Test::Unit::Assertions\r
23                 def create(ie, name)\r
25                         ie.goto("#{$base_url}/accountpermission/new.castle")\r
27                         ie.text_field(:id, "apermission_name").set(name)\r
28                         \r
29                         ie.button(:id, 'insertbutton').click\r
31                         # Check for errors\r
32                         \r
33                         fail('There were databind errors') if ie.contains_text('binding error')\r
34                         fail('Unexpected exception') if ie.contains_text('Exception')\r
35                         \r
36                         assert_equal(name, ie.span(:id, 'name').text, 'Insert: Name was not set')\r
38                         # returns new created id\r
39                         \r
40                         ie.span(:id, 'newid').text\r
41                         \r
42                 end\r
43                 \r
44                 def edit(ie, id, new_name)\r
46                         ie.goto("#{$base_url}/accountpermission/edit.castle?id=#{id}")\r
48                         ie.text_field(:id, "apermission_name").set(new_name)\r
49                         \r
50                         ie.button(:id, 'updatebutton').click\r
52                         # Check for errors\r
53                         \r
54                         fail('There were databind errors') if ie.contains_text('binding error')\r
55                         fail('Unexpected exception') if ie.contains_text('Exception')\r
56                         \r
57                         assert_equal(new_name, ie.span(:id, 'name').text, 'Edit: Name was not set')\r
58                         \r
59                 end\r
60                 \r
61                 def delete(ie, id)\r
63                         ie.goto("#{$base_url}/accountpermission/removeconfirm.castle?id=#{id}")\r
65                         fail('Looks like removeConfirm.castle didnt load instance') unless ie.contains_text("Confirm removal of #{id}?")\r
66                         \r
67                         ie.button(:id, 'button').click\r
69                         fail('Error removing instance') unless ie.contains_text('Removed')\r
70                         fail('Unexpected exception') if ie.contains_text('Exception')\r
71                         \r
72                 end\r
74         end\r
76 end\r