Skip to content

Commit d8d3acc

Browse files
committed
TD-3885 Making use of environment variables.
1 parent 72eaf10 commit d8d3acc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/AllDelegatesControllerTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.AspNetCore.Http;
1818
using NUnit.Framework;
1919
using Microsoft.Extensions.Configuration;
20+
using Microsoft.AspNetCore.Hosting;
2021

2122
public class AllDelegatesControllerTests
2223
{
@@ -32,6 +33,7 @@ public class AllDelegatesControllerTests
3233
private IUserDataService userDataService = null!;
3334
private IGroupsService groupsService = null!;
3435
private IConfiguration? configuration;
36+
private IWebHostEnvironment? env;
3537

3638
[SetUp]
3739
public void Setup()
@@ -46,6 +48,7 @@ public void Setup()
4648
configuration = A.Fake<IConfiguration>();
4749
httpRequest = A.Fake<HttpRequest>();
4850
httpResponse = A.Fake<HttpResponse>();
51+
env = A.Fake<IWebHostEnvironment>();
4952

5053
const string cookieValue = "ActiveStatus|Active|false";
5154

@@ -56,7 +59,8 @@ public void Setup()
5659
jobGroupsDataService,
5760
paginateService,
5861
groupsService,
59-
configuration
62+
configuration,
63+
env
6064
)
6165
.WithMockHttpContext(httpRequest, CookieName, cookieValue, httpResponse)
6266
.WithMockUser(true)

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Delegates/AllDelegatesController.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using Microsoft.FeatureManagement.Mvc;
1919
using Microsoft.Extensions.Configuration;
2020
using DigitalLearningSolutions.Data.Extensions;
21-
using Microsoft.AspNetCore.Http.Extensions;
21+
using Microsoft.AspNetCore.Hosting;
2222

2323
[FeatureGate(FeatureFlags.RefactoredTrackingSystem)]
2424
[Authorize(Policy = CustomPolicies.UserCentreAdmin)]
@@ -35,6 +35,7 @@ public class AllDelegatesController : Controller
3535
private readonly IUserDataService userDataService;
3636
private readonly IGroupsService groupsService;
3737
private readonly IConfiguration configuration;
38+
private readonly IWebHostEnvironment env;
3839

3940
public AllDelegatesController(
4041
IDelegateDownloadFileService delegateDownloadFileService,
@@ -43,7 +44,8 @@ public AllDelegatesController(
4344
IJobGroupsDataService jobGroupsDataService,
4445
IPaginateService paginateService,
4546
IGroupsService groupsService,
46-
IConfiguration configuration
47+
IConfiguration configuration,
48+
IWebHostEnvironment env
4749
)
4850
{
4951
this.delegateDownloadFileService = delegateDownloadFileService;
@@ -53,6 +55,7 @@ IConfiguration configuration
5355
this.paginateService = paginateService;
5456
this.groupsService = groupsService;
5557
this.configuration = configuration;
58+
this.env = env;
5659
}
5760

5861
[NoCaching]
@@ -77,7 +80,8 @@ public IActionResult Index(
7780

7881
sortBy ??= DefaultSortByOptions.Name.PropertyName;
7982
sortDirection ??= GenericSortingHelper.Ascending;
80-
if (HttpContext.Request.GetDisplayUrl().ToString().ToLower().Contains("uat"))
83+
84+
if (string.Equals(env.EnvironmentName, "UAT", StringComparison.OrdinalIgnoreCase))
8185
{
8286
DelegateFilterCookieName = "DelegateFilterUat";
8387
}

0 commit comments

Comments
 (0)