# test the search box
def verify_search_box user
if user && user['is_active']
- # let's search for a valid uuid
+ aproject_uuid = api_fixture('groups')['aproject']['uuid']
+ # let's search for aproject by uuid
within('.navbar-fixed-top') do
page.has_field?('search')
- page.find_field('search').set user['uuid']
+ page.find_field('search').set aproject_uuid
page.find('.glyphicon-search').click
end
- # we should now be in the user's home project as a result of search
- assert_selector "#Data_collections[data-object-uuid='#{user['uuid']}']", "Expected to be in user page after search click"
+ # we should now be in aproject as a result of search
+ assert_selector 'a', text:'Data collections'
+ click_link 'Data collections'
+ assert_selector "#Data_collections[data-object-uuid='#{aproject_uuid}']", "Expected to be in user page after search click"
- # let's search again for an invalid valid uuid
+ # let's search again for an invalid uuid
within('.navbar-fixed-top') do
search_for = String.new user['uuid']
search_for[0]='1'
end
[
- ['admin', false],
- ['active', true],
- ].each do |username, expect_show_button|
- test "login as #{username} and access show button #{expect_show_button}" do
+ 'admin',
+ 'active',
+ ].each do |username|
+ test "login as #{username} and access show button" do
need_javascript
user = api_fixture('users', username)
visit page_with_token(username, '/users')
- if expect_show_button
- within('tr', text: user['uuid']) do
- assert_text user['email']
- assert_selector 'a', text: 'Show'
- find('a', text: 'Show').click
- end
- assert_selector 'a', 'Data collections'
- else
- # no 'Show' button in the admin user's own row
- within('tr', text: user['uuid']) do
- assert_text user['email']
- assert_no_selector 'a', text: 'Show'
- end
-
- # but the admin user can access 'Show' button for other users
- active_user = api_fixture('users', 'active')
- within('tr', text: active_user['uuid']) do
- assert_text active_user['email']
- assert_selector 'a', text: 'Show'
- find('a', text: 'Show').click
- assert_selector 'a', 'Attributes'
- end
+ within('tr', text: user['uuid']) do
+ assert_text user['email']
+ assert_selector 'a', text: 'Show'
+ find('a', text: 'Show').click
end
+ assert_selector 'a', text:'Attributes'
end
end
+
+ test "admin user can access another user page" do
+ need_javascript
+
+ visit page_with_token('admin', '/users')
+
+ active_user = api_fixture('users', 'active')
+ within('tr', text: active_user['uuid']) do
+ assert_text active_user['email']
+ assert_selector 'a', text: 'Show'
+ find('a', text: 'Show').click
+ end
+ assert_selector 'a', text:'Attributes'
+ end
end