From 3e9576ef93a4d86882147b34ef9a28016375b865 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 5 May 2014 06:32:27 -0400 Subject: [PATCH] Fix tests, make model.editable? work for new records. --- apps/workbench/app/models/arvados_base.rb | 7 +++++-- apps/workbench/test/integration/folders_test.rb | 7 +++---- apps/workbench/test/integration/users_test.rb | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb index 0418267fae..1a0da6424a 100644 --- a/apps/workbench/app/models/arvados_base.rb +++ b/apps/workbench/app/models/arvados_base.rb @@ -266,7 +266,8 @@ class ArvadosBase < ActiveRecord::Base def editable? (current_user and current_user.is_active and (current_user.is_admin or - current_user.uuid == self.owner_uuid)) + current_user.uuid == self.owner_uuid or + new_record?)) end def attribute_editable?(attr) @@ -277,7 +278,9 @@ class ArvadosBase < ActiveRecord::Base elsif "uuid owner_uuid".index(attr.to_s) or current_user.is_admin current_user.is_admin else - current_user.uuid == self.owner_uuid or current_user.uuid == self.uuid + current_user.uuid == self.owner_uuid or + current_user.uuid == self.uuid or + new_record? end end diff --git a/apps/workbench/test/integration/folders_test.rb b/apps/workbench/test/integration/folders_test.rb index da3d4c0675..c8753ac3e9 100644 --- a/apps/workbench/test/integration/folders_test.rb +++ b/apps/workbench/test/integration/folders_test.rb @@ -8,8 +8,7 @@ class FoldersTest < ActionDispatch::IntegrationTest Capybara.current_driver = Capybara.javascript_driver visit page_with_token 'active', '/' find('nav a', text: 'Folders').click - find('.side-nav', text: 'A Folder'). - find('a,button', text: 'Show'). + find('.side-nav a,button', text: 'A Folder'). click within('.panel', text: api_fixture('groups')['afolder']['name']) do find('span', text: api_fixture('groups')['afolder']['name']).click @@ -26,8 +25,8 @@ class FoldersTest < ActionDispatch::IntegrationTest folder_uuid = api_fixture('groups')['afolder']['uuid'] specimen_uuid = api_fixture('specimens')['owned_by_afolder_with_no_name_link']['uuid'] visit page_with_token 'active', '/folders/' + folder_uuid - within('.panel', text: 'Contents') do - find('.tr[data-object-uuid="'+specimen_uuid+'"] .editable[data-name="name"]').click + within('.panel tr', text: specimen_uuid) do + find(".editable[data-name='name']").click find('.editable-input input').set('Now I have a name.') find('.glyphicon-ok').click find('.editable', text: 'Now I have a name.').click diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb index bd69f997a3..3bedc6dc56 100644 --- a/apps/workbench/test/integration/users_test.rb +++ b/apps/workbench/test/integration/users_test.rb @@ -166,7 +166,7 @@ class UsersTest < ActionDispatch::IntegrationTest click # Verify that is_active is set - click_link 'Attributes' + find('a,button', text: 'Attributes').click assert page.has_text? 'modified_by_user_uuid' page.within(:xpath, '//span[@data-name="is_active"]') do assert_equal "true", text, "Expected user's is_active to be true" -- 2.30.2