test and removed tests from users_test.
test "project viewer can't see project sharing tab" do
project = api_fixture('groups')['aproject']
get(:show, {id: project['uuid']}, session_for(:project_viewer))
- refute_includes @response.body, '<div id ="Sharing"'
+ refute_includes @response.body, '<div id="Sharing"'
assert_includes @response.body, '<div id="Data_collections"'
end
+ [
+ 'admin',
+ 'active',
+ ].each do |username|
+ test "#{username} can see project sharing tab" do
+ project = api_fixture('groups')['aproject']
+ get(:show, {id: project['uuid']}, session_for(username))
+ assert_includes @response.body, '<div id="Sharing"'
+ assert_includes @response.body, '<div id="Data_collections"'
+ end
+ end
end
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
+
test "valid token works in controller test" do
get :index, {}, session_for(:active)
assert_response :success
end
assert_equal 1, found_email, "Expected 1 email after requesting shell access"
end
+
+ [
+ 'admin',
+ 'active',
+ ].each do |username|
+ test "access users page as #{username} and verify show button is available" do
+ admin_user = api_fixture('users','admin')
+ active_user = api_fixture('users','active')
+ get :index, {}, session_for(username)
+ if username == 'admin'
+ assert_match /<a href="\/projects\/#{admin_user['uuid']}">Home<\/a.*./, @response.body
+ assert_match /<a href="\/projects\/#{active_user['uuid']}">Home<\/a.*./, @response.body
+ assert_match /<a.*href="\/users\/#{admin_user['uuid']}".*Show<\/a.*./, @response.body
+ assert_match /<a.*href="\/users\/#{active_user['uuid']}".*Show<\/a.*./, @response.body
+ assert_includes @response.body, admin_user['email']
+ assert_includes @response.body, active_user['email']
+ else
+ refute_match /a href=.*Home<.*\/a.*./, @response.body
+ refute_match /<a.*href="\/users\/#{admin_user['uuid']}".*Show<\/a.*./, @response.body
+ assert_match /<a.*href="\/users\/#{active_user['uuid']}".*Show<\/a.*./, @response.body
+ assert_includes @response.body, active_user['email']
+ end
+ end
+ end
+
+ [
+ 'admin',
+ 'active',
+ ].each do |username|
+ test "access settings drop down menu as #{username}" do
+ admin_user = api_fixture('users','admin')
+ active_user = api_fixture('users','active')
+ get :show, {
+ id: api_fixture('users')[username]['uuid']
+ }, session_for(username)
+ if username == 'admin'
+ assert_includes @response.body, admin_user['email']
+ refute_empty css_select('[id="system-menu"]')
+ else
+ assert_includes @response.body, active_user['email']
+ assert_empty css_select('[id="system-menu"]')
+ end
+ end
+ end
end
click_link 'Metadata'
assert page.has_text? 'VirtualMachine: testvm.shell'
end
-
- [
- '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')
-
- within('tr', text: user['uuid']) do
- assert_text user['email']
- if username == 'admin'
- assert_selector 'a', text: 'Home'
- else
- assert_no_selector 'a', text: 'Home'
- end
- 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[href=\"/projects/#{active_user['uuid']}\"]", text: 'Home'
- assert_selector 'a', text: 'Show'
- find('a', text: 'Show').click
- end
- assert_selector 'a', text:'Attributes'
- end
end