Add user credit warning for sofia_account provider#1167
Conversation
|
Warning Rate limit exceeded@lodewiges has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 39 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe pull request expands the credit insufficiency check in the user model to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
public/images/alphalogonotextwhite.pngis excluded by!**/*.png
📒 Files selected for processing (2)
app/models/user.rb(1 hunks)app/views/users/show.html.erb(1 hunks)
⏰ 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). (2)
- GitHub Check: Agent
- GitHub Check: Build
🔇 Additional comments (1)
app/views/users/show.html.erb (1)
155-159: Implementation is correct, but clarify connection to PR objective.The conditional rendering based on Amber API URL configuration is well-implemented and provides better UX. However, this change appears to address role configuration guidance rather than user credit warnings mentioned in the PR title and objectives.
Could you clarify how this view change relates to adding credit warnings for sofia_account users? If this is an additional improvement for sofia_account provider support, consider mentioning it in the PR description for better traceability.
There was a problem hiding this comment.
Pull request overview
This PR extends the credit warning system to support the sofia_account authentication provider, ensuring that users authenticating via sofia_account receive the same credit notifications as amber_oauth2 users.
Key Changes:
- Extended the
insufficient_creditmethod to include sofia_account provider alongside amber_oauth2 - Updated UI text to be provider-agnostic when amber_api_url is not configured
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/models/user.rb | Modified insufficient_credit method to include 'sofia_account' provider and changed and to && for better precedence |
| app/views/users/show.html.erb | Made role description text conditional based on amber_api_url presence to support multiple authentication providers |
| public/images/alphalogonotextwhite.png | Binary image file added (no review needed) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def insufficient_credit | ||
| provider == 'amber_oauth2' and credit.negative? | ||
| (provider == 'amber_oauth2' || provider == 'sofia_account') && credit.negative? | ||
| end |
There was a problem hiding this comment.
The insufficient_credit method has been updated to include the 'sofia_account' provider, but there are no tests covering this new behavior. Consider adding test cases to verify that:
- Users with provider 'sofia_account' and negative credit return true
- Users with provider 'sofia_account' and positive credit return false
- Users with other providers and negative credit return false
This would ensure the credit warning functionality works correctly for sofia_account users.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## staging #1167 +/- ##
===========================================
+ Coverage 77.27% 77.68% +0.41%
===========================================
Files 54 54
Lines 1351 1340 -11
===========================================
- Hits 1044 1041 -3
+ Misses 307 299 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR is needed so manual added users also need a saldo when order