Merge branch 'master' into 3138-wiselinks
[arvados.git] / apps / workbench / test / functional / projects_controller_test.rb
index b338aa818687b92f9cadf5847f30ccd7dacaad35..a991cedd634022777b4d0627643290df66d2b183 100644 (file)
@@ -9,4 +9,23 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_template 'user_agreements/index',
     "Inactive user was not presented with a user agreement at the front page"
   end
+
+  [[:active, true],
+   [:project_viewer, false]].each do |which_user, should_show|
+    test "create subproject button #{'not ' unless should_show} shown to #{which_user}" do
+      readonly_project_uuid = api_fixture('groups')['aproject']['uuid']
+      get :show, {
+        id: readonly_project_uuid
+      }, session_for(which_user)
+      buttons = css_select('[data-method=post]').select do |el|
+        el.attributes['href'].match /project.*owner_uuid.*#{readonly_project_uuid}/
+      end
+      if should_show
+        assert_not_empty(buttons, "did not offer to create a subproject")
+      else
+        assert_empty(buttons.collect(&:to_s),
+                     "offered to create a subproject in a non-writable project")
+      end
+    end
+  end
 end