Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
get(:show, {id: api_fixture('groups')['aproject']['uuid']})
assert_response 404
- assert_includes @response.inspect, 'you are not logged in'
+ assert_match(/log ?in/i, @response.body)
end
test "visit home page as anonymous when anonymous browsing is enabled and expect login" do
assert_includes @response.body, '<div id="Data_collections"'
end
end
+
+ [
+ ['admin',true],
+ ['active',true],
+ ['project_viewer',false],
+ ].each do |user, can_move|
+ test "#{user} can move subproject from project #{can_move}" do
+ get(:show, {id: api_fixture('groups')['aproject']['uuid']}, session_for(user))
+ if can_move
+ assert_includes @response.body, 'Move project...'
+ else
+ refute_includes @response.body, 'Move project...'
+ end
+ end
+ end
+
+ [
+ ["jobs", "/jobs"],
+ ["pipelines", "/pipeline_instances"],
+ ["collections", "/collections"],
+ ].each do |target,path|
+ test "test dashboard button all #{target}" do
+ get :index, {}, session_for(:active)
+ assert_includes @response.body, "href=\"#{path}\""
+ assert_includes @response.body, "All #{target}"
+ end
+ end
+
+ test "visit a public project and verify the public projects page link exists" do
+ Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+ uuid = api_fixture('groups')['anonymously_accessible_project']['uuid']
+ get :show, {id: uuid}
+ project = assigns(:object)
+ assert_equal uuid, project['uuid']
+ refute_empty css_select("[href=\"/projects/#{project['uuid']}\"]")
+ assert_includes @response.body, "<a href=\"/projects/public\">Public Projects</a>"
+ end
+
+ test 'all_projects unaffected by params after use by ProjectsController (#6640)' do
+ @controller = ProjectsController.new
+ project_uuid = api_fixture('groups')['aproject']['uuid']
+ get :index, {
+ filters: [['uuid', '<', project_uuid]].to_json,
+ limit: 0,
+ offset: 1000,
+ }, session_for(:active)
+ assert_select "#projects-menu + ul li.divider ~ li a[href=/projects/#{project_uuid}]"
+ end
end