2044: Add share_with permission denied test.
[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   test "sharing a project with a user and group" do
14     uuid_list = [api_fixture("groups")["future_project_viewing_group"]["uuid"],
15                  api_fixture("users")["future_project_user"]["uuid"]]
16     post(:share_with, {
17            id: api_fixture("groups")["asubproject"]["uuid"],
18            uuids: uuid_list,
19            format: "json"},
20          session_for(:active))
21     assert_response :success
22     json_response = Oj.load(@response.body)
23     assert_equal(uuid_list, json_response["success"])
24   end
25
26   test "user with project read permission can't add permissions" do
27     post(:share_with, {
28            id: api_fixture("groups")["aproject"]["uuid"],
29            uuids: [api_fixture("users")["spectator"]["uuid"]],
30            format: "json"},
31          session_for(:project_viewer))
32     assert_response 422
33   end
34 end