3214: "New project" link in top nav dropdown create a new project at top level, inste...
[arvados.git] / apps / workbench / test / functional / projects_controller_test.rb
1 require 'test_helper'
2
3 class ProjectsControllerTest < ActionController::TestCase
4   test "inactive user is asked to sign user agreements on front page" do
5     get :index, {}, session_for(:inactive)
6     assert_response :success
7     assert_not_empty assigns(:required_user_agreements),
8     "Inactive user did not have required_user_agreements"
9     assert_template 'user_agreements/index',
10     "Inactive user was not presented with a user agreement at the front page"
11   end
12
13   [[:active, true],
14    [:project_viewer, false]].each do |which_user, should_show|
15     test "create subproject button #{'not ' unless should_show} shown to #{which_user}" do
16       readonly_project_uuid = api_fixture('groups')['aproject']['uuid']
17       get :show, {
18         id: readonly_project_uuid
19       }, session_for(which_user)
20       buttons = css_select('[data-method=post]').select do |el|
21         el.attributes['href'].match /project.*owner_uuid.*#{readonly_project_uuid}/
22       end
23       if should_show
24         assert_not_empty(buttons, "did not offer to create a subproject")
25       else
26         assert_empty(buttons.collect(&:to_s),
27                      "offered to create a subproject in a non-writable project")
28       end
29     end
30   end
31 end