Skip to content

Commit

Permalink
AP-5177: Update SAML session tests
Browse files Browse the repository at this point in the history
* Reduce the stubbed API data to make it simpler to read, while still
containing the required data and leaving a comment so future Devs
don't think it's representative of a full data response
* Simplify the creation tests to be clear what is being looked for
  • Loading branch information
colinbruce committed Nov 21, 2024
1 parent fec1668 commit c3aabb0
Showing 1 changed file with 11 additions and 49 deletions.
60 changes: 11 additions & 49 deletions spec/requests/saml_sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@

it "updates the record with firm and offices" do
post_request
firm = Firm.find_by(ccms_id: raw_details_response.dig(:firm, :ccmsFirmId))
expect(provider.firm_id).to eq firm.id
expect(firm.offices.size).to eq 1
expect(firm.offices.first.ccms_id).to eq raw_details_response[:officeCodes].first[:ccmsFirmOfficeId].to_s
expect(provider.firm.ccms_id).to eq "10835831"
expect(provider.firm.offices.size).to eq 1
expect(provider.firm.offices.first.ccms_id).to eq "34406595"
end

context "when mock_saml is activated" do
Expand Down Expand Up @@ -181,10 +180,9 @@

it "updates the record with firm and offices" do
post_request
firm = Firm.find_by(ccms_id: raw_details_response.dig(:firm, :ccmsFirmId))
expect(provider.firm_id).to eq firm.id
expect(firm.offices.size).to eq 1
expect(firm.offices.first.ccms_id).to eq raw_details_response[:officeCodes].first[:ccmsFirmOfficeId].to_s
expect(provider.firm.ccms_id).to eq "10835831"
expect(provider.firm.offices.size).to eq 1
expect(provider.firm.offices.first.ccms_id).to eq "34406595"
end

it "displays the start page" do
Expand Down Expand Up @@ -226,25 +224,17 @@ def raw_details_response
{
firm: {
firmId: 3_959_183,
firmNumber: "50736",
ccmsFirmId: 10_835_831,
firmName: "DT SCRIPT PROVIDER 1",
# trimmed for stub usage
},
user: {
userId: 454_031,
ccmsContactId: 0,
userLogin: "DT_SCRIPT_USER1",
name: "Dts User1",
emailAddress: "[email protected]",
portalStatus: "Active",
# trimmed for stub usage
},
officeCodes: [
{
firmOfficeId: 145_434,
ccmsFirmOfficeId: 34_406_595,
firmOfficeCode: "2Q242F",
officeName: "2Q242F,1 Skyscraper",
officeCodeAlt: "DT Script Office 1",
# trimmed for stub usage
},
],
}
Expand All @@ -254,42 +244,14 @@ def firm_response
{
firm: {
firmId: 3_959_183,
firmNumber: "50736",
ccmsFirmId: 10_835_831,
firmName: "DT SCRIPT PROVIDER 1",
# trimmed for stub usage
},
offices: [
{
firmOfficeId: 145_434,
ccmsFirmOfficeId: 34_406_595,
firmOfficeCode: "2Q242F",
officeName: "2Q242F,1 Skyscraper",
officeCodeAlt: "DT Script Office 1",
addressLine1: "1 Skyscraper",
addressLine2: "1 Some Road",
addressLine3: "",
addressLine4: "",
city: "Metropolis",
county: "",
postCode: "LE1 1AA",
dxCentre: "",
dxNumber: "",
telephoneAreaCode: "01162",
telephoneNumber: "555124",
faxAreaCode: "",
faxNumber: "",
emailAddress: "[email protected]",
vatRegistrationNumber: "",
type: "Legal Services Provider",
headOffice: "N/A",
creationDate: "2023-11-10",
lscRegion: "Midlands",
lscBidZone: "Leicester",
lscAreaOffice: "Nottingham",
cjsForceName: "Leicestershire",
localAuthority: "City of Leicester",
policeStationAreaName: "Leicester",
dutySolicitorAreaName: "Leicester",
# trimmed for stub usage
},
],
}
Expand Down

0 comments on commit c3aabb0

Please sign in to comment.