Skip to content

Commit 263e98d

Browse files
authored
DTR-HOTFIX - updating routing and test to route appropriately (#190)
1 parent 03fb944 commit 263e98d

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

app/controllers/purchaserAgent/SelectPurchaserAgentController.scala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ import javax.inject.Inject
3333
import scala.concurrent.Future
3434

3535
class SelectPurchaserAgentController @Inject()(
36-
override val messagesApi: MessagesApi,
37-
identify: IdentifierAction,
38-
getData: DataRetrievalAction,
39-
requireData: DataRequiredAction,
40-
formProvider: SelectPurchaserAgentFormProvider,
41-
purchaserService: PurchaserService,
42-
purchaserAgentService: PurchaserAgentService,
43-
val controllerComponents: MessagesControllerComponents,
44-
view: SelectPurchaserAgentView
45-
) extends FrontendBaseController with I18nSupport with Logging {
36+
override val messagesApi: MessagesApi,
37+
identify: IdentifierAction,
38+
getData: DataRetrievalAction,
39+
requireData: DataRequiredAction,
40+
formProvider: SelectPurchaserAgentFormProvider,
41+
purchaserService: PurchaserService,
42+
purchaserAgentService: PurchaserAgentService,
43+
val controllerComponents: MessagesControllerComponents,
44+
view: SelectPurchaserAgentView
45+
) extends FrontendBaseController with I18nSupport with Logging {
4646

4747
def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData).async {
4848
implicit request =>
@@ -54,24 +54,24 @@ class SelectPurchaserAgentController @Inject()(
5454

5555
(maybeMainPurchaserName, beforeYouStartYes, maybeStorn) match {
5656
case (None, true, _) =>
57-
Future.successful(Redirect(controllers.purchaser.routes.NameOfPurchaserController.onPageLoad(NormalMode)))
57+
Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode)))
5858

5959
case (Some(purchaser), true, Some(storn)) =>
6060
maybeAgents match {
61-
case None => Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode)))
61+
case None => Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode)))
6262

63-
case Some(agents) =>
64-
agents match {
65-
case Nil => Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode)))
66-
case agents =>
67-
val form: Form[String] = formProvider(agents)
63+
case Some(agents) =>
64+
agents match {
65+
case Nil => Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode)))
66+
case agents =>
67+
val form: Form[String] = formProvider(agents)
6868

69-
val preparedForm = request.userAnswers.get(SelectPurchaserAgentPage) match {
70-
case None => form
71-
case Some(value) => form.fill(value)
72-
}
73-
Future.successful(Ok(view(preparedForm, mode, purchaser, Some(purchaserAgentService.agentSummaryList(agents)))))
74-
}
69+
val preparedForm = request.userAnswers.get(SelectPurchaserAgentPage) match {
70+
case None => form
71+
case Some(value) => form.fill(value)
72+
}
73+
Future.successful(Ok(view(preparedForm, mode, purchaser, Some(purchaserAgentService.agentSummaryList(agents)))))
74+
}
7575
}
7676
case _ =>
7777
Future.successful(Redirect(controllers.routes.ReturnTaskListController.onPageLoad()))
@@ -87,7 +87,7 @@ class SelectPurchaserAgentController @Inject()(
8787

8888
(maybeMainPurchaserName, maybeStorn) match {
8989
case (None, _) =>
90-
Future.successful(Redirect(controllers.purchaser.routes.NameOfPurchaserController.onPageLoad(mode)))
90+
Future.successful(Redirect(controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(mode)))
9191

9292
case (Some(purchaser), Some(storn)) =>
9393
maybeAgents match {

test/controllers/purchaserAgent/SelectPurchaserAgentControllerSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SelectPurchaserAgentControllerSpec extends SpecBase with MockitoSugar {
6161
email: Option[String] = Some("test@example.com"),
6262
dxAddress: Option[String] = Some("yes"),
6363
agentResourceReference: Option[String] = Some("REF001")
64-
) : Agent =
64+
): Agent =
6565
Agent(
6666
storn = Some(testStorn),
6767
agentId = agentId,
@@ -265,7 +265,7 @@ class SelectPurchaserAgentControllerSpec extends SpecBase with MockitoSugar {
265265
val result = route(application, request).value
266266

267267
status(result) mustEqual SEE_OTHER
268-
redirectLocation(result).value mustEqual controllers.purchaser.routes.NameOfPurchaserController.onPageLoad(NormalMode).url
268+
redirectLocation(result).value mustEqual controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode).url
269269
}
270270
}
271271

@@ -349,7 +349,7 @@ class SelectPurchaserAgentControllerSpec extends SpecBase with MockitoSugar {
349349
val result = route(application, request).value
350350

351351
status(result) mustEqual SEE_OTHER
352-
redirectLocation(result).value mustEqual controllers.purchaser.routes.NameOfPurchaserController.onPageLoad(NormalMode).url
352+
redirectLocation(result).value mustEqual controllers.purchaserAgent.routes.PurchaserAgentNameController.onPageLoad(NormalMode).url
353353
}
354354
}
355355

0 commit comments

Comments
 (0)