Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE ContactsController #show #73

Merged
merged 3 commits into from
Jan 6, 2025
Merged

BE ContactsController #show #73

merged 3 commits into from
Jan 6, 2025

Conversation

stefanjbloom
Copy link
Collaborator

Type of Change

  • feature β›²
  • documentation update πŸ“ƒ
  • refactor πŸ§‘β€πŸ’»
  • testing πŸ§ͺ

Description

By adding, in routes.rb, :show to the :users(not :companies) nested :contacts resource and adding corresponding #show action to ContactsController, the FE can now access and render a users individual contacts. This is fully tested in Postman and green in RSpec.

Motivation and Context

Issue #17 was affected by a prior refactor of the BE ContactsController that removed the #show action because of how the routes are now being nested. While building my ShowContact component on the FE, I was getting a mystery 500 error which led me to see that BE's main had been refactored.

Related Tickets

closes #66

Screenshots (if appropriate):

Added Test?

  • Yes 🫑
  • All previous tests still pass πŸ₯³

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

@@ -46,6 +46,25 @@ def create
end
end

def show
if params[:id].blank?
render json: ErrorSerializer.format_error(ErrorMessage.new("Contact ID is missing", 400)), status: :bad_request
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like how you’re using ErrorSerializer to handle errorsβ€”keeps the responses consistent and user-friendly.

@@ -0,0 +1,73 @@
require "rails_helper"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great job on the tests here. You’ve covered both happy and sad paths well, especially with cases for missing, invalid, and expired tokens.

@@ -697,6 +697,43 @@ raw json body with all fields:
]
},
```
#### Show a Contact that belongs to a User (not company contact)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The README update is super clear and helpful. The sample request and response are a great addition for anyone using this endpoint and makes it clear what route and endpoint you are using.

Copy link
Collaborator

@jimmacur jimmacur left a comment

Choose a reason for hiding this comment

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

You are making this look like clockwork. Everything is nice and tidy! Great use of the serializers and thorough testing.

@jimmacur jimmacur merged commit 5336adb into main Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BE Show Contact
3 participants