public void Can_Get_Content_Type_Permission_For_Node()
        {
            IContentType type = _contentTypeService.GetContentType("textpage");
            IContent     node = Scaffold.Node(_contentService);

            Dictionary <int, List <UserGroupPermissionsPoco> > perms = Scaffold.Permissions(0, 2, 0, type.Id);

            _configService.UpdateContentTypeConfig(perms);

            Assert.NotNull(_configService.GetPermissionsForNode(node.Id));
        }
示例#2
0
        public async void Can_Get_Paged_Node_Tasks()
        {
            // get an error if the node doesn't exist
            //object response = await _tasksController.GetNodeTasks(666, -1, -1).GetContent();
            //Assert.Equal("NullReferenceException", (string)response.Get("ExceptionType"));
            //Assert.Equal(MagicStrings.ErrorGettingPendingTasksForNode.Replace("{id}", "666"), (string)response.Get("ExceptionMessage"));

            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id));
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));

            // needs flow or function exits
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 2);

            _configService.UpdateNodeConfig(config);

            JObject content = await _tasksController.GetNodeTasks(node.Id, 10, 1).GetContent();

            Assert.Equal(1, content.Value <int>("totalPages"));
            Assert.Equal(10, content.Value <int>("count"));
            Assert.Equal(3, content.Value <JArray>("items").Count);

            // when 3 tasks, 1 per page, page 2 should be 1 item
            content = await _tasksController.GetNodeTasks(node.Id, 1, 2).GetContent();

            Assert.Equal(3, content.Value <int>("totalPages"));
            Assert.Equal(1, content.Value <int>("count"));
            Assert.Single(content.Value <JArray>("items"));

            // when 5 tasks, and 2 per page, page 2 should be 2 items
            _tasksService.InsertTask(Scaffold.Task(guid));
            _tasksService.InsertTask(Scaffold.Task(guid));

            content = await _tasksController.GetNodeTasks(node.Id, 2, 2).GetContent();

            Assert.Equal(3, content.Value <int>("totalPages"));
            Assert.Equal(2, content.Value <int>("count"));
            Assert.Equal(2, content.Value <JArray>("items").Count);
        }
示例#3
0
        public void Can_Get_Ancestor_Permissions()
        {
            // scaffold
            Scaffold.ContentType(_contentTypeService);
            IContent root       = Scaffold.Node(_contentService);
            IContent child      = Scaffold.Node(_contentService, root.Id);
            IContent childChild = Scaffold.Node(_contentService, child.Id);

            // set permissions on root
            // mock some data
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(root.Id, 3, 2);

            _configService.UpdateNodeConfig(config);

            bool hasFlow = _utility.HasFlow(childChild.Id);

            Assert.True(hasFlow);
        }
        public async void Can_Get_Node_Pending_Tasks()
        {
            Scaffold.ContentType(_contentTypeService);
            IContent node = Scaffold.Node(_contentService);

            Scaffold.Config();

            Guid guid = Guid.NewGuid();

            _instancesService.InsertInstance(Scaffold.Instance(guid, 1, node.Id));
            _tasksService.InsertTask(Scaffold.Task(guid));

            // needs flow or function exits
            Dictionary <int, List <UserGroupPermissionsPoco> > config = Scaffold.Permissions(node.Id, 3, 0);

            _configService.UpdateNodeConfig(config);

            JObject content = await _tasksController.GetNodePendingTasks(node.Id).GetContent();

            Assert.Single(content.Value <JArray>("items"));
        }