public void WhenApplicationMethodIsThroughFaaVacancy_ShouldOverwriteApplicationInstructionsAsNull()
        {
            var user    = VacancyOrchestratorTestData.GetVacancyUser();
            var vacancy = VacancyOrchestratorTestData.GetPart1CompleteVacancy();

            _mockVacancyClient.Setup(x => x.GetVacancyAsync(vacancy.Id))
            .ReturnsAsync(vacancy);
            _mockVacancyClient.Setup(x => x.Validate(vacancy, VacancyRuleSet.ApplicationMethod))
            .Returns(new EntityValidationResult());
            _mockVacancyClient.Setup(x => x.UpdateDraftVacancyAsync(It.IsAny <Vacancy>(), user));

            var sut = new ApplicationProcessOrchestrator(_mockClient.Object, _mockVacancyClient.Object, Options.Create(new ExternalLinksConfiguration()), Mock.Of <ILogger <ApplicationProcessOrchestrator> >(), Mock.Of <IReviewSummaryService>());

            var applicationProcessEditModel = new ApplicationProcessEditModel
            {
                EmployerAccountId       = vacancy.EmployerAccountId,
                VacancyId               = vacancy.Id,
                ApplicationMethod       = ApplicationMethod.ThroughFindAnApprenticeship,
                ApplicationInstructions = "just do it"
            };

            var result = sut.PostApplicationProcessEditModelAsync(applicationProcessEditModel, user);

            vacancy.ApplicationMethod.HasValue.Should().BeTrue();
            vacancy.ApplicationMethod.Value.Should().Be(ApplicationMethod.ThroughFindAnApprenticeship);
            vacancy.ApplicationInstructions.Should().BeNull();
            _mockVacancyClient.Verify(x => x.UpdateDraftVacancyAsync(vacancy, user), Times.Once);
        }
예제 #2
0
        public async Task <IActionResult> ApplicationProcess(ApplicationProcessEditModel m)
        {
            var vm = await _orchestrator.GetApplicationProcessViewModelAsync(m);

            var response = await _orchestrator.PostApplicationProcessEditModelAsync(m, User.ToVacancyUser());

            if (!response.Success)
            {
                response.AddErrorsToModelState(ModelState);
            }


            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            if (_feature.IsFeatureEnabled(FeatureNames.EmployerTaskList))
            {
                if (vm.IsTaskListCompleted)
                {
                    return(RedirectToRoute(RouteNames.EmployerCheckYourAnswersGet));
                }

                return(RedirectToRoute(RouteNames.EmployerTaskListGet));
            }

            return(RedirectToRoute(RouteNames.Vacancy_Preview_Get));
        }
        public async Task <IActionResult> ApplicationProcess(ApplicationProcessEditModel m)
        {
            var response = await _orchestrator.PostApplicationProcessEditModelAsync(m, User.ToVacancyUser());

            if (!response.Success)
            {
                response.AddErrorsToModelState(ModelState);
            }

            if (!ModelState.IsValid)
            {
                var vm = await _orchestrator.GetApplicationProcessViewModelAsync(m);

                return(View(vm));
            }

            return(RedirectToRoute(RouteNames.Vacancy_Preview_Get));
        }
        public async Task WhenApplicationMethodIsThroughFaaVacancy_ShouldCallUpdateDraftVacancy()
        {
            _fixture
            .WithApplicationMethod(ApplicationMethod.ThroughExternalApplicationSite)
            .WithApplicationInstructions("has a value")
            .WithApplicationUrl("has a value")
            .Setup();

            var applicationProcessEditModel = new ApplicationProcessEditModel
            {
                EmployerAccountId       = _fixture.Vacancy.EmployerAccountId,
                VacancyId               = _fixture.Vacancy.Id,
                ApplicationMethod       = ApplicationMethod.ThroughFindAnApprenticeship,
                ApplicationInstructions = "has a value",
            };

            await _fixture.PostApplicationProcessEditModelAsync(applicationProcessEditModel);

            _fixture.VerifyUpdateDraftVacancyAsyncIsCalled();
        }
        public async Task WhenApplicationMethodIsThroughFaaVacancy_ShouldOverwriteApplicationUrlAsNull()
        {
            _fixture
            .WithApplicationMethod(ApplicationMethod.ThroughExternalApplicationSite)
            .WithApplicationInstructions("has a value")
            .WithApplicationUrl("has a value")
            .Setup();

            var applicationProcessEditModel = new ApplicationProcessEditModel
            {
                EmployerAccountId = _fixture.Vacancy.EmployerAccountId,
                VacancyId         = _fixture.Vacancy.Id,
                ApplicationMethod = ApplicationMethod.ThroughFindAnApprenticeship,
                ApplicationUrl    = "has a value"
            };

            await _fixture.PostApplicationProcessEditModelAsync(applicationProcessEditModel);

            _fixture.VerifyApplicationMethod(ApplicationMethod.ThroughFindAnApprenticeship);
            _fixture.VerifyOverwriteApplicationUrlAsNull();
        }
        public async Task WhenApplicationUrlIsUpdated_ShouldFlagApplicationInstructionsFieldIndicator()
        {
            _fixture
            .WithApplicationMethod(ApplicationMethod.ThroughExternalApplicationSite)
            .WithApplicationInstructions("has a value")
            .WithApplicationUrl("has a value")
            .Setup();

            var applicationProcessEditModel = new ApplicationProcessEditModel
            {
                EmployerAccountId       = _fixture.Vacancy.EmployerAccountId,
                VacancyId               = _fixture.Vacancy.Id,
                ApplicationMethod       = ApplicationMethod.ThroughExternalApplicationSite,
                ApplicationInstructions = "has a value",
                ApplicationUrl          = "has a new value"
            };

            await _fixture.PostApplicationProcessEditModelAsync(applicationProcessEditModel);

            _fixture.VerifyEmployerReviewFieldIndicators(FieldIdentifiers.ApplicationMethod, false);
            _fixture.VerifyEmployerReviewFieldIndicators(FieldIdentifiers.ApplicationInstructions, false);
            _fixture.VerifyEmployerReviewFieldIndicators(FieldIdentifiers.ApplicationUrl, true);
        }
        public async Task WhenApplicationMethodIsThroughFaaVacancy_ShouldFlagAllApplicationFieldIndicators()
        {
            _fixture
            .WithApplicationMethod(ApplicationMethod.ThroughExternalApplicationSite)
            .WithApplicationInstructions("has a value")
            .WithApplicationUrl("has a value")
            .Setup();

            var applicationProcessEditModel = new ApplicationProcessEditModel
            {
                Ukprn                   = _fixture.Vacancy.TrainingProvider.Ukprn.Value,
                VacancyId               = _fixture.Vacancy.Id,
                ApplicationMethod       = ApplicationMethod.ThroughFindAnApprenticeship,
                ApplicationInstructions = "has a value",
                ApplicationUrl          = "has a value"
            };

            await _fixture.PostApplicationProcessEditModelAsync(applicationProcessEditModel);

            _fixture.VerifyProviderReviewFieldIndicators(FieldIdentifiers.ApplicationMethod, true);
            _fixture.VerifyProviderReviewFieldIndicators(FieldIdentifiers.ApplicationInstructions, true);
            _fixture.VerifyProviderReviewFieldIndicators(FieldIdentifiers.ApplicationUrl, true);
        }
 public async Task PostApplicationProcessEditModelAsync(ApplicationProcessEditModel model)
 {
     await Sut.PostApplicationProcessEditModelAsync(model, User);
 }