[ARVADOS] updated: 566649e5561e10dabfac6cd4387d5dc197644d6a

git at public.curoverse.com git at public.curoverse.com
Sun Mar 30 18:08:57 EDT 2014


Summary of changes:
 .../app/assets/javascripts/application.js          |    1 +
 apps/workbench/app/controllers/users_controller.rb |    9 +++-
 apps/workbench/app/models/user.rb                  |    6 ++
 .../app/views/users/_setup_popup.html.erb          |   15 +++++
 .../workbench/app/views/users/_show_admin.html.erb |   11 +++
 apps/workbench/app/views/users/setup_popup.js.erb  |    1 +
 apps/workbench/config/routes.rb                    |    1 +
 apps/workbench/test/integration/users_test.rb      |   67 ++++++++++++++++---
 8 files changed, 99 insertions(+), 12 deletions(-)
 create mode 100644 apps/workbench/app/views/users/_setup_popup.html.erb
 create mode 100644 apps/workbench/app/views/users/setup_popup.js.erb

       via  566649e5561e10dabfac6cd4387d5dc197644d6a (commit)
      from  949c7305691c7003296a1185697bb7318a975403 (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 566649e5561e10dabfac6cd4387d5dc197644d6a
Author: radhika chippada <radhika at radhika.curoverse>
Date:   Sun Mar 30 18:07:46 2014 -0400

    Add a setup action to users controller and user model

diff --git a/apps/workbench/app/assets/javascripts/application.js b/apps/workbench/app/assets/javascripts/application.js
index e7884b9..3ad7944 100644
--- a/apps/workbench/app/assets/javascripts/application.js
+++ b/apps/workbench/app/assets/javascripts/application.js
@@ -18,6 +18,7 @@
 //= require bootstrap/tooltip
 //= require bootstrap/popover
 //= require bootstrap/collapse
+//= require bootstrap/modal
 //= require bootstrap3-editable/bootstrap-editable
 //= require_tree .
 
diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index fc4953e..5396702 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -1,7 +1,7 @@
 class UsersController < ApplicationController
   skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity]
   skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
-  before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup]
+  before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup, :setup]
 
   def welcome
     if current_user
@@ -145,4 +145,11 @@ class UsersController < ApplicationController
     show
   end
 
+  def setup
+    if current_user.andand.is_admin
+      @object.setup
+    end
+    show
+  end
+
 end
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index 6c889e6..6009b19 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -45,4 +45,10 @@ class User < ArvadosBase
                                                 {}))
   end
 
+  def setup
+    $arvados_api_client.api(self.class,
+                            "/setup",
+                            {uuid: self.uuid})
+  end
+
 end
diff --git a/apps/workbench/app/views/users/_setup_popup.html.erb b/apps/workbench/app/views/users/_setup_popup.html.erb
new file mode 100644
index 0000000..fb119c3
--- /dev/null
+++ b/apps/workbench/app/views/users/_setup_popup.html.erb
@@ -0,0 +1,15 @@
+
+<div id="modal-window" class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-header">
+    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+    <h3 id="myModalLabel">Modal header</h3>
+  </div>
+  <div class="modal-body">
+    **here comes whatever you want to show!**
+  </div>
+  <div class="modal-footer">
+    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
+    <button class="btn btn-primary">Save changes</button>
+  </div>
+</div>
+
diff --git a/apps/workbench/app/views/users/_show_admin.html.erb b/apps/workbench/app/views/users/_show_admin.html.erb
index 90afd11..b63f41c 100644
--- a/apps/workbench/app/views/users/_show_admin.html.erb
+++ b/apps/workbench/app/views/users/_show_admin.html.erb
@@ -11,3 +11,14 @@ account.</p>
 <blockquote>
 <%= button_to "Deactivate #{@object.full_name}", unsetup_user_url(id: @object.uuid), class: 'btn btn-primary', confirm: "Are you sure you want to deactivate #{@object.full_name}?"%>
 </blockquote>
+
+<p>As an admin, you can setup this user. Please input a VM and repository for the user. If you had previously provided any of these items, they are pre-filled for you and you can leave them as is if you would like to reuse them.</p>
+
+<blockquote>
+
+<div>
+<%= button_to "Setup #{@object.full_name}", setup_user_url(id: @object.uuid), {class: 'btn btn-primary',  'data-toggle' => 'modal', 'data-target' => '#modal-window'}  %>
+ <%= render :partial => 'setup_popup' %>
+</div>
+
+</blockquote>
diff --git a/apps/workbench/app/views/users/setup_popup.js.erb b/apps/workbench/app/views/users/setup_popup.js.erb
new file mode 100644
index 0000000..a928e96
--- /dev/null
+++ b/apps/workbench/app/views/users/setup_popup.js.erb
@@ -0,0 +1 @@
+$("#modal-window").html("<%= escape_javascript(render 'setup_popup') %>");
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 6504df0..7b73346 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -23,6 +23,7 @@ ArvadosWorkbench::Application.routes.draw do
     get 'welcome', :on => :collection
     get 'activity', :on => :collection
     post 'sudo', :on => :member
+    post 'setup', :on => :member
     post 'unsetup', :on => :member
   end
   resources :logs
diff --git a/apps/workbench/test/integration/users_test.rb b/apps/workbench/test/integration/users_test.rb
index c7769ca..39374e7 100644
--- a/apps/workbench/test/integration/users_test.rb
+++ b/apps/workbench/test/integration/users_test.rb
@@ -1,7 +1,45 @@
 require 'integration_helper'
+#require "selenium-webdriver"
+#require 'headless'
 
 class UsersTest < ActionDispatch::IntegrationTest
 
+  test "login as active user but not admin" do
+    Capybara.current_driver = Capybara.javascript_driver
+    visit page_with_token('active_trustedclient')
+
+    assert page.has_no_link? 'Users' 'Found Users link for non-admin user'
+  end
+
+  test "login as admin user and verify active user data" do
+    Capybara.current_driver = Capybara.javascript_driver
+    visit page_with_token('admin_trustedclient')
+
+    # go to Users list page
+    click_link 'Users'
+
+    # check active user attributes in the list page
+    page.within(:xpath, '//tr[@data-object-uuid="zzzzz-tpzed-xurymjxw79nv3jz"]') do
+      assert (text.include? 'true false'), 'Expected is_active'
+    end
+
+    click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
+    assert page.has_text? 'Attributes'
+    assert page.has_text? 'Metadata'
+    assert page.has_text? 'Admin'
+
+    # go to the Attributes tab
+    click_link 'Attributes'
+    assert page.has_text? 'modified_by_user_uuid'
+    page.within(:xpath, '//a[@data-name="is_active"]') do
+      assert_equal "true", text, "Expected user's is_active to be true"
+    end
+    page.within(:xpath, '//a[@data-name="is_admin"]') do
+      assert_equal "false", text, "Expected user's is_admin to be false"
+    end
+
+  end
+
   test "create a new user" do
     Capybara.current_driver = Capybara.javascript_driver
     visit page_with_token('admin_trustedclient')
@@ -16,8 +54,11 @@ class UsersTest < ActionDispatch::IntegrationTest
     assert page.has_text? 'zzzzz-tpzed-d9tiejq69daie8f'
   end
 
+  #@headless
   test "unsetup active user" do
     Capybara.current_driver = Capybara.javascript_driver
+    #Capybara.current_driver = :selenium
+
     visit page_with_token('admin_trustedclient')
 
     click_link 'Users'
@@ -26,11 +67,8 @@ class UsersTest < ActionDispatch::IntegrationTest
 
     # click on active user
     click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
-    assert page.has_text? 'Attributes'
-    assert page.has_text? 'Metadata'
-    assert page.has_text? 'Admin'
 
-    # go to the Attributes tab
+    # Verify that is_active is set
     click_link 'Attributes'
     assert page.has_text? 'modified_by_user_uuid'
     page.within(:xpath, '//a[@data-name="is_active"]') do
@@ -46,12 +84,23 @@ class UsersTest < ActionDispatch::IntegrationTest
 
     # Click Ok in the confirm dialog
 =begin
+#use with selenium
+    page.driver.browser.switch_to.alert.accept
     sleep(0.1)
-    popup = page.driver.window_handles.last
+    popup = page.driver.browser.window_handles.last
+    #popup = page.driver.browser.window_handle
     page.within_window popup do
-      assert has_text? 'Are you sure you want to deactivate Active User'
-      click_button "Ok"
+      assert has_text? 'Are you sure you want to deactivate'
+      click_button "OK"
     end
+
+# use with poltergeist driver
+popup = page.driver.window_handles.last
+page.within_window popup do
+  #fill_in "email", :with => "my_email"
+  assert has_text? 'Are you sure you want to deactivate'
+  click_button "OK"
+end
 =end
 
     # Should now be back in the Attributes tab for the user
@@ -59,7 +108,6 @@ class UsersTest < ActionDispatch::IntegrationTest
     page.within(:xpath, '//a[@data-name="is_active"]') do
       assert_equal "false", text, "Expected user's is_active to be false after unsetup"
     end
-
   end
 
   test "setup the active user" do
@@ -72,9 +120,6 @@ class UsersTest < ActionDispatch::IntegrationTest
 
     # click on active user
     click_link 'zzzzz-tpzed-xurymjxw79nv3jz'
-    assert page.has_text? 'Attributes'
-    assert page.has_text? 'Metadata'
-    assert page.has_text? 'Admin'
 
     # go to Admin tab
     click_link 'Admin'

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list