[ARVADOS] updated: 9290961beb18476f71aa0ae12478fe50493e8ad9

git at public.curoverse.com git at public.curoverse.com
Tue Oct 27 11:39:25 EDT 2015


Summary of changes:
 apps/workbench/app/assets/javascripts/add_group.js | 10 +++++++++-
 apps/workbench/app/models/user.rb                  |  4 ++++
 .../app/views/users/_add_group_modal.html.erb      |  4 ++--
 apps/workbench/test/integration/errors_test.rb     | 12 ------------
 apps/workbench/test/integration/users_test.rb      | 22 ++++++++++++++++++++++
 .../test/integration/virtual_machines_test.rb      | 14 --------------
 6 files changed, 37 insertions(+), 29 deletions(-)

       via  9290961beb18476f71aa0ae12478fe50493e8ad9 (commit)
      from  2b43b263f8cd5cbd931d884bfa961a7dba7a4b9a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9290961beb18476f71aa0ae12478fe50493e8ad9
Author: radhika <radhika at curoverse.com>
Date:   Tue Oct 27 11:35:28 2015 -0400

    7453: Disable submit button in add group dialog until a name is entered.
    Observed that the "Add a new user" button is offered in /users page even to non-admin users. Corrected this bug.
    Deleted one test in errors_test that was trying to access the "Add new group" button in /groups page.
    Also, deleted the one test in virtual_machines_test that were trying to click the "Add new" button.
    Added a new test in users_test that clicks the "Add new group" button and verifies the group is added.

diff --git a/apps/workbench/app/assets/javascripts/add_group.js b/apps/workbench/app/assets/javascripts/add_group.js
index 7023b1e..16d9c2d 100644
--- a/apps/workbench/app/assets/javascripts/add_group.js
+++ b/apps/workbench/app/assets/javascripts/add_group.js
@@ -1,11 +1,19 @@
 $(document).on('shown.bs.modal', '#add-group-modal', function(event) {
+    // Disable the submit button on modal loading
+    $submit = $('#add-group-submit');
+    $submit.prop('disabled', true);
+
     $('input[type=text]', event.target).val('');
     $('#add-group-error', event.target).hide();
+}).on('input propertychange', '#group_name_input', function(event) {
+    group_name = $(event.target).val();
+    $submit = $('#add-group-submit');
+    $submit.prop('disabled', (group_name === null || group_name === ""));
 }).on('submit', '#add-group-form', function(event) {
     var $form = $(event.target),
     $submit = $(':submit', $form),
     $error = $('#add-group-error', $form),
-    group_name = $('input[name="group_name"]', $form).val();
+    group_name = $('input[name="group_name_input"]', $form).val();
 
     $submit.prop('disabled', true);
 
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index 3b5b308..8df16f2 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -63,4 +63,8 @@ class User < ArvadosBase
   def deletable?
     false
   end
+
+   def self.creatable?
+    current_user and current_user.is_admin
+   end
 end
diff --git a/apps/workbench/app/views/users/_add_group_modal.html.erb b/apps/workbench/app/views/users/_add_group_modal.html.erb
index 77c41bb..8230e56 100644
--- a/apps/workbench/app/views/users/_add_group_modal.html.erb
+++ b/apps/workbench/app/views/users/_add_group_modal.html.erb
@@ -8,10 +8,10 @@
         </div>
         <div class="modal-body form-horizontal">
           <div class="form-group">
-            <label for="group_name" class="col-sm-1 control-label">Name</label>
+            <label for="group_name_input" class="col-sm-1 control-label">Name</label>
             <div class="col-sm-9">
               <div class="input-group-name">
-                <input type="text" class="form-control" id="group_name" name="group_name">
+                <input type="text" class="form-control" id="group_name_input" name="group_name_input" placeholder="Enter group name"/>
               </div>
             </div>
           </div>
diff --git a/apps/workbench/test/integration/errors_test.rb b/apps/workbench/test/integration/errors_test.rb
index f2067a9..32f6e02 100644
--- a/apps/workbench/test/integration/errors_test.rb
+++ b/apps/workbench/test/integration/errors_test.rb
@@ -46,18 +46,6 @@ class ErrorsTest < ActionDispatch::IntegrationTest
     page.html =~ /\b(#{matching_stamps})\+[0-9A-Fa-f]{8}\b/
   end
 
-  # We use API tokens with limited scopes as the quickest way to get the API
-  # server to return an error.  If Workbench gets smarter about coping when
-  # it has a too-limited token, these tests will need to be adjusted.
-  test "API error page includes error token" do
-    start_stamp = now_timestamp
-    visit(page_with_token("active_readonly", "/groups"))
-    click_on "Add a new group"
-    assert(page.has_text?(/fiddlesticks/i),
-           "Not on an error page after making a group out of scope")
-    assert(page_has_error_token?(start_stamp), "no error token on 404 page")
-  end
-
   test "showing a bad UUID returns 404" do
     visit(page_with_token("active", "/pipeline_templates/zzz"))
     assert(page.has_no_text?(/fiddlesticks/i),
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index 1ae302c..90a3eb2 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -197,4 +197,26 @@ class UsersTest < ActionDispatch::IntegrationTest
     click_link 'Metadata'
     assert page.has_text? 'VirtualMachine: testvm.shell'
   end
+
+  test "test add group button" do
+    need_javascript
+
+    user_url = "/users/#{api_fixture('users')['active']['uuid']}"
+    visit page_with_token('admin_trustedclient', user_url)
+
+    # Setup user
+    click_link 'Admin'
+    assert page.has_text? 'As an admin, you can setup'
+
+    click_link 'Add new group'
+
+    within '.modal-content' do
+      fill_in "group_name_input", :with => "test-group-added-in-modal"
+      click_button "Create"
+    end
+    wait_for_ajax
+
+    # Back in the user "Admin" tab
+    assert page.has_text? 'test-group-added-in-modal'
+  end
 end
diff --git a/apps/workbench/test/integration/virtual_machines_test.rb b/apps/workbench/test/integration/virtual_machines_test.rb
index 1d398a5..a22337b 100644
--- a/apps/workbench/test/integration/virtual_machines_test.rb
+++ b/apps/workbench/test/integration/virtual_machines_test.rb
@@ -1,18 +1,4 @@
 require 'integration_helper'
 
 class VirtualMachinesTest < ActionDispatch::IntegrationTest
-  test "make and name a new virtual machine" do
-    need_javascript
-    visit page_with_token('admin_trustedclient')
-    find('#system-menu').click
-    click_link 'Virtual machines'
-    assert page.has_text? 'testvm.shell'
-    click_on 'Add a new virtual machine'
-    find('tr', text: 'hostname').
-      find('a[data-original-title=edit]').click
-    assert page.has_text? 'Edit hostname'
-    fill_in 'editable-text', with: 'testname'
-    click_button 'editable-submit'
-    assert page.has_text? 'testname'
-  end
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list