X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da3017f2d1c4a6838255814a96cbb66acde14d0a..19ae770973482257117fe8ded5619c3018c4b60f:/apps/workbench/test/controllers/projects_controller_test.rb diff --git a/apps/workbench/test/controllers/projects_controller_test.rb b/apps/workbench/test/controllers/projects_controller_test.rb index 6bdab55ddf..58914a84ac 100644 --- a/apps/workbench/test/controllers/projects_controller_test.rb +++ b/apps/workbench/test/controllers/projects_controller_test.rb @@ -447,4 +447,54 @@ class ProjectsControllerTest < ActionController::TestCase assert_nil(tree_nodes[unexpected_project['uuid']]) end end + + [ + ["active", 1], + ["project_viewer", 1], + ["admin", 0], + ].each do |user, size| + test "starred projects for #{user}" do + use_token user + ctrl = ProjectsController.new + current_user = User.find(api_fixture('users')[user]['uuid']) + my_starred_project = ctrl.send :my_starred_projects, current_user + assert_equal(size, my_starred_project.andand.size) + + ctrl2 = ProjectsController.new + current_user = User.find(api_fixture('users')[user]['uuid']) + my_starred_project = ctrl2.send :my_starred_projects, current_user + assert_equal(size, my_starred_project.andand.size) + end + end + + test "unshare project and verify that it is no longer included in shared user's starred projects" do + # remove sharing link + use_token :system_user + Link.find(api_fixture('links')['share_starred_project_with_project_viewer']['uuid']).destroy + + # verify that project is no longer included in starred projects + use_token :project_viewer + current_user = User.find(api_fixture('users')['project_viewer']['uuid']) + ctrl = ProjectsController.new + my_starred_project = ctrl.send :my_starred_projects, current_user + assert_equal(0, my_starred_project.andand.size) + + # share it again + @controller = LinksController.new + post :create, { + link: { + link_class: 'permission', + name: 'can_read', + head_uuid: api_fixture('groups')['starred_and_shared_active_user_project']['uuid'], + tail_uuid: api_fixture('users')['project_viewer']['uuid'], + }, + format: :json + }, session_for(:system_user) + + # verify that the project is again included in starred projects + use_token :project_viewer + ctrl = ProjectsController.new + my_starred_project = ctrl.send :my_starred_projects, current_user + assert_equal(1, my_starred_project.andand.size) + end end