Skip to content

Fix naming in handler and tests#241

Merged
Skiper29 merged 1 commit into
devfrom
fix/232/fix-repository-naming
Sep 23, 2025
Merged

Fix naming in handler and tests#241
Skiper29 merged 1 commit into
devfrom
fix/232/fix-repository-naming

Conversation

@Skiper29

@Skiper29 Skiper29 commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

dev

Code reviewers

Summary of issue

Summary of change

This pull request standardizes the naming of the "FavouriteStreetcode" entity and related repository across both the application logic and unit tests. It replaces the inconsistent "FavoriteStreetcode" naming with the correct "FavouriteStreetcode" spelling throughout the codebase, ensuring consistency and reducing the risk of errors.

CHECK LIST

  • СI passed
  • Сode coverage >=95%
  • PR is reviewed manually again (to make sure you have 100% ready code)
  • All reviewers agreed to merge the PR
  • I've checked new feature as logged in and logged out user if needed
  • PR meets all conventions

Summary by CodeRabbit

  • Refactor
    • Standardized naming to British English spelling for “favourite” across the favourite-street content feature. No changes to functionality or user experience.
  • Tests
    • Updated unit tests to align with the new naming conventions and verified existing behaviour remains unchanged.

No user-facing changes in this release.

@Skiper29 Skiper29 self-assigned this Sep 23, 2025
@Skiper29 Skiper29 added the bug Something isn't working label Sep 23, 2025
@coderabbitai

coderabbitai Bot commented Sep 23, 2025

Copy link
Copy Markdown

Walkthrough

Renames Favorite→Favourite across handler and tests, updating repository property references and the entity’s namespace/type to DAL.Entities.Favourite.FavouriteStreetcode. No control-flow or business-logic changes.

Changes

Cohort / File(s) Change Summary
Handler update
Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandler.cs
Switched repository property from FavoriteStreetcodeRepository to FavouriteStreetcodeRepository; updated entity instantiation to DAL.Entities.Favourite.FavouriteStreetcode; adjusted GetFirstOrDefaultAsync and CreateAsync targets accordingly.
Unit tests update
Streetcode/Streetcode.XUnitTest/BLL/MediatR/StreetCode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandlerTests.cs
Introduced alias FavouriteStreetcodeEntity; updated mocks, expressions, and verifications to use FavouriteStreetcodeEntity; renamed repository access to FavouriteStreetcodeRepository; adjusted method signatures in setups for new entity type.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

task

Suggested reviewers

  • oleksandrhofner
  • denys-pavskyi
  • weazy12
  • Markian-Grybok

Poem

I hop through code with nimble feet,
From Favorite to Favourite—spelled so neat.
Repos aligned, tests in a row,
Names now match wherever we go.
Thump-thump! says QA, carrots in sight—
Consistency’s crisp, and everything’s right. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description includes reviewers, a linked GitHub issue, a summary of the change, and a checklist, but it does not fully follow the repository template: it is missing the required "## JIRA" ticket entry, lacks a "Testing approach" section, and omits the "Second Level Review" block that appears in the template. Please update the description to include the main JIRA ticket URL under "## JIRA", add a "Testing approach" section describing how the change was tested (unit tests and any manual verification steps), and add or complete the "Second Level Review" section and reviewer checkboxes; also mark CI and coverage status in the checklist when available.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Fix naming in handler and tests" is a concise, single-sentence summary that accurately reflects the main change in the PR (standardizing the Favourite/Favorite naming in handler code and unit tests) and is clear enough for a reviewer scanning the history.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/232/fix-repository-naming

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandler.cs (2)

51-55: Entity construction updated to the new type.

Optional: since the namespace is already imported, you can drop the fully-qualified name for brevity.

-        var favouriteStreetcode = new DAL.Entities.Favourite.FavouriteStreetcode
+        var favouriteStreetcode = new FavouriteStreetcode

31-42: Consider hardening claims parsing (optional).

Using int.Parse can throw; guarding null User/Claims would avoid exceptions in edge cases.

-        var userIdString = _httpContextAccessor.HttpContext?.User.Claims
+        var userIdString = _httpContextAccessor.HttpContext?.User?.Claims
             .FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;

-        var userId = int.Parse(userIdString);
+        if (!int.TryParse(userIdString, out var userId))
+        {
+            var errorMsg = Errors_Jwt.UserNotFound;
+            _logger.LogError(request, errorMsg);
+            return Result.Fail(errorMsg);
+        }

Note: updating this would require adjusting the test that currently expects ArgumentNullException when Claims is null.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4e102a and b991ed6.

📒 Files selected for processing (2)
  • Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandler.cs (1 hunks)
  • Streetcode/Streetcode.XUnitTest/BLL/MediatR/StreetCode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandlerTests.cs (11 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandler.cs (2)
Streetcode/Streetcode.BLL/Util/Extensions/ResourceExtensions.cs (1)
  • FormatWith (5-8)
Streetcode/Streetcode.BLL/Services/Logging/LoggerService.cs (1)
  • LogError (35-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build and analyze
🔇 Additional comments (16)
Streetcode/Streetcode.XUnitTest/BLL/MediatR/StreetCode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandlerTests.cs (14)

16-17: Alias introduction is clear and consistent.

Keeps generics readable and unifies type usage across tests.


35-36: Repository property rename wired correctly.

Mocks now target FavouriteStreetcodeRepository as intended.


53-56: Updated repository method setup matches new type.

Generics now use FavouriteStreetcodeEntity; setup looks correct.


64-65: CreateAsync verification updated to new type.

Argument predicate matches expected user and streetcode IDs.


81-81: No creation when HttpContext is null — verification OK.


95-95: No creation when claims are null — verification OK.


132-132: Existing favourite instantiation uses the alias — OK.


136-138: GetFirstOrDefaultAsync setup generics updated — OK.


145-145: CreateAsync not called when favourite exists — verification OK.


158-161: Null-return setup for absence of favourite — OK.


169-169: CreateAsync called once on failure path — verification OK.


183-186: No-existing-favourite setup uses alias — OK.


204-207: Parameterized setup with alias — OK.


213-216: Expression verification compiles against alias — OK.

Streetcode/Streetcode.BLL/MediatR/Streetcode/Streetcode/CreateFavourite/CreateFavouriteStreetcodeHandler.cs (2)

43-49: Repository property rename usage is correct.

Duplicate check now calls FavouriteStreetcodeRepository consistently.


57-58: Create and save flow remains unchanged and correct.

CreateAsync on the renamed repo followed by SaveChangesAsync is consistent.

@oleksandrhofner oleksandrhofner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, I have the same bugs. Fix this asap

@weazy12

weazy12 commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

My bad. Sorry about that.

@Skiper29 Skiper29 merged commit a95caf3 into dev Sep 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants