[ARVADOS] updated: b3e2782f72e0ca381f3f8c508227ebd7a2ef0c92

git at public.curoverse.com git at public.curoverse.com
Tue May 26 18:55:12 EDT 2015


Summary of changes:
 .../app/controllers/projects_controller.rb         | 10 ++----
 .../{public_projects.html.erb => public.html.erb}  | 19 ++++++-----
 .../test/controllers/projects_controller_test.rb   | 38 ++++++++++++++++++++++
 .../test/integration/anonymous_access_test.rb      |  4 +++
 .../test/integration/application_layout_test.rb    |  2 ++
 apps/workbench/test/integration/projects_test.rb   | 38 ----------------------
 6 files changed, 58 insertions(+), 53 deletions(-)
 rename apps/workbench/app/views/projects/{public_projects.html.erb => public.html.erb} (71%)

       via  b3e2782f72e0ca381f3f8c508227ebd7a2ef0c92 (commit)
      from  1a0ba80d44b4be962f898ee1458faea9d4a59137 (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 b3e2782f72e0ca381f3f8c508227ebd7a2ef0c92
Author: radhika <radhika at curoverse.com>
Date:   Tue May 26 18:54:13 2015 -0400

    6057: if /projects/public is accessed when anonymous config is not enabled, show 404.

diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index dec26c3..c4600f2 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -309,13 +309,9 @@ class ProjectsController < ApplicationController
   end
 
   def public  # Yes 'public' is the name of the action for public projects
-    if Rails.configuration.anonymous_user_token
-      @public_projects = using_specific_api_token Rails.configuration.anonymous_user_token do
-        Group.where(group_class: 'project').order("updated_at DESC")
-      end
-      render 'public_projects'
-    else
-      redirect_to '/projects'
+    return render_not_found if not Rails.configuration.anonymous_user_token
+    @objects = using_specific_api_token Rails.configuration.anonymous_user_token do
+      Group.where(group_class: 'project').order("updated_at DESC")
     end
   end
 end
diff --git a/apps/workbench/app/views/projects/public_projects.html.erb b/apps/workbench/app/views/projects/public.html.erb
similarity index 71%
rename from apps/workbench/app/views/projects/public_projects.html.erb
rename to apps/workbench/app/views/projects/public.html.erb
index fdae70e..9fc9759 100644
--- a/apps/workbench/app/views/projects/public_projects.html.erb
+++ b/apps/workbench/app/views/projects/public.html.erb
@@ -1,4 +1,4 @@
-<table class="table arv-public-projects" style="width: 100%;">
+<table class="table">
   <colgroup>
     <col width="25%" />
     <col width="75%" />
@@ -6,21 +6,24 @@
   <thead>
     <tr class="contain-align-left">
       <th>
-	Name
-      </th><th>
-	Description
+        Name
+      </th>
+      <th>
+        Description
+      </th>
     </tr>
   </thead>
 
-  <% @public_projects.each do |p| %>
+  <tbody>
+  <% @objects.each do |p| %>
     <tr>
       <td style="word-break:break-all;">
         <%= link_to_if_arvados_object p, {friendly_name: true} %>
-      </div></td>
+      </td>
       <td style="word-break:break-all;">
         <%= render_attribute_as_textile(p, "description", p.description, true) %>
-      </div></td>
+      </td>
     </tr>
   <% end %>
+  </tbody>
 </table>
-
diff --git a/apps/workbench/test/controllers/projects_controller_test.rb b/apps/workbench/test/controllers/projects_controller_test.rb
index 119ed8c..b050383 100644
--- a/apps/workbench/test/controllers/projects_controller_test.rb
+++ b/apps/workbench/test/controllers/projects_controller_test.rb
@@ -248,4 +248,42 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_response :redirect
     assert_match /\/users\/welcome/, @response.redirect_url
   end
+
+  [
+    nil,
+    :active,
+  ].each do |user|
+    test "visit public projects page when anon config is enabled, as user #{user}, and expect page" do
+      Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+
+      if user
+        get :public, {}, session_for(user)
+      else
+        get :public
+      end
+
+      assert_response :success
+      assert_not_nil assigns(:objects)
+      project_names = assigns(:objects).collect(&:name)
+      assert_operator 0, :<, project_names.length
+      assert project_names.include?('Unrestricted public data')
+      assert !project_names.include?('A Project')
+    end
+  end
+
+  [
+    nil,
+    :active,
+  ].each do |user|
+    test "visit public projects page when anon config is not enabled, as user #{user}, and expect no such page" do
+      if user
+        get :public, {}, session_for(user)
+        assert_response 404
+      else
+        get :public
+        assert_response :redirect
+        assert_match /\/users\/welcome/, @response.redirect_url
+      end
+    end
+  end
 end
diff --git a/apps/workbench/test/integration/anonymous_access_test.rb b/apps/workbench/test/integration/anonymous_access_test.rb
index a4155fb..8ac3a56 100644
--- a/apps/workbench/test/integration/anonymous_access_test.rb
+++ b/apps/workbench/test/integration/anonymous_access_test.rb
@@ -18,6 +18,10 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
       if user['is_active']
         assert_text 'Unrestricted public data'
         assert_selector 'a', text: 'Projects'
+        page.find("#projects-menu").click
+        assert_selector 'a', text: 'Add a new project'
+        assert_selector 'a', text: 'Browse public projects'
+        assert page.has_text?('Projects shared with me'), 'Not found text - Project shared with me'
       else
         assert_text 'indicate that you have read and accepted the user agreement'
       end
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
index b6a501f..f8984f0 100644
--- a/apps/workbench/test/integration/application_layout_test.rb
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -24,6 +24,8 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
       else
         assert page.has_link?("Projects"), 'Not found link - Projects'
         page.find("#projects-menu").click
+        assert_selector 'a', text: 'Add a new project'
+        assert_no_selector 'a', text: 'Browse public projects'  # anonymous config is not enabled by default
         assert page.has_text?('Projects shared with me'), 'Not found text - Project shared with me'
       end
     elsif invited
diff --git a/apps/workbench/test/integration/projects_test.rb b/apps/workbench/test/integration/projects_test.rb
index 84237ae..9c2842f 100644
--- a/apps/workbench/test/integration/projects_test.rb
+++ b/apps/workbench/test/integration/projects_test.rb
@@ -830,42 +830,4 @@ class ProjectsTest < ActionDispatch::IntegrationTest
       assert_no_selector 'li.disabled', text: 'Copy selected'
     end
   end
-
-  [
-    [true, nil, true],
-    [true, 'active', true],
-    [false, nil, false],
-    [false, 'active', false],
-  ].each do |anon_config, user, expect_page|
-    test "visit public_projects page when anon config enabled #{anon_config}, as user #{user}, and expect page #{expect_page}" do
-      Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token'] if anon_config
-
-      if user
-        visit page_with_token user, '/projects/public'
-      else
-        visit '/public_projects'
-      end
-
-      # verify public projects are listed
-      assert_selector 'a', 'Unrestricted public data'
-
-      if user
-        find("#projects-menu").click
-        if anon_config
-          assert_selector 'a', text: 'Browse public projects'
-        else
-          assert_no_selector 'a', text: 'Browse public projects'
-        end
-      else
-        within('.navbar-fixed-top') do
-          assert_selector 'a', text: 'Log in'
-          if anon_config
-            assert_selector 'a', text: 'Browse public projects'
-          else
-            assert_no_selector 'a', text: 'Browse public projects'
-          end
-        end
-      end
-    end
-  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list