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

Feat/job application show #35

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

kylomite
Copy link
Collaborator

@kylomite kylomite commented Dec 9, 2024

Type of Change

  • feature ⛲
  • documentation update 📃
  • testing 🧪

Description

  • Show user's job application
  • Testing for job application Show method
  • Updated seed file
  • Updated Readme.md

Motivation and Context

  • This PR creates an endpoint for viewing a user's specific job applications based on its ID.
  • It handles SAD paths by returning an error response if

Related Tickets

Screenshots (if appropriate):

Added Test?

  • Yes 🫡

    • request tests for HAPPY and SAD paths in job_application_show_spec
  • All previous tests still pass 🥳

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Collaborator

@Sgalvin36 Sgalvin36 left a comment

Choose a reason for hiding this comment

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

Very nice work! Its clear and easy to work through

db/seeds.rb Outdated
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 that you added a seed of the job application. That way you can use it as like default values for the front end and do some testing in the development and testing stages. And you didn't create a bunch of seeds either which would populate even the production database with a bunch of dummy data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you, I think once we have company seeds this will be very useful for viewing responses with tools like postman.

user = User.find(params[:user_id])
job_application = JobApplication.find_by(id: params[:id])

if job_application.nil? || job_application.user_id != user.id
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we want a different error if the user doesn't match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Kinda torn on this, Im not sure if the effort is worth the result, but i'm willing to hear out justifications. Feel free to post some in this thread if anyone is interested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not 100% one way or the other, but clearer messages to the front is helpful and since a lack of job application is a slightly different error than an incorrect user id. They both result in the job application not working as intended, so I also see why one error for each does the job.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another potential edge case would be a lack of parameters being sent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is worth doing. I will incorporate this edge case in the testing, if it requires reworking the method, I will incorporate that as well. Thank you :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Edge case has been addressed and read me has been updated accordingly, If the change is suitable, feel free to resolve conversation and/or resolve conflict to merge :) Reach out if there Is anything I can help clarify

@reneemes
Copy link
Collaborator

reneemes commented Dec 9, 2024

Excellent job Kyle! I pulled your branch down to my local to run the tests and everything seems to be running smoothly. I also noticed that you have 100% test coverage of your controller and model with SimpleCov.
One thought, if sad path testing for invalid authorization tokens is handled elsewhere in the codebase, it might not need duplication here. Otherwise, it’s a detail that could further strengthen the tests for this endpoint. Just something to consider. I know Shane mentioned testing with missing parameters, and I agree this could be a useful variable to cover. Overall, this is fantastic work!

Comment on lines +112 to +123

it "returns error serializer if no params are passed in URL for job application id" do
get "/api/v1/users/#{@user.id}/job_applications/"

expect(response).to_not be_successful
expect(response.status).to eq(400)

json = JSON.parse(response.body, symbolize_names: true)

expect(json[:message]).to eq("Job application ID is missing")
expect(json[:status]).to eq(400)
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding this test and being very through with your work. I like your error message here, as I feel it is very informative and user-friendly.

Comment on lines +15 to +18
if params[:id].blank?
render json: ErrorSerializer.format_error(ErrorMessage.new("Job application ID is missing", 400)), status: :bad_request
return
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a nice addition to the show action. I noticed that you are grabbing the ID from the params, and not from the authentication token. I'm curious about this decision, as both the companies and contacts are collecting it from the token.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed that the JobApplications controller is not utilizing the authentication tokens or the authenticate_user method that has been defined in the ApplicationController. Other controllers in the application are using these for authentication, so I wanted to flag this for consistency and security purposes.

Could you clarify if this was intentional or an oversight? If it's an oversight, it might be worth adding the necessary authentication logic to ensure this controller aligns with the others. I'm curious to hear your thoughts!

Comment on lines +15 to +18
if params[:id].blank?
render json: ErrorSerializer.format_error(ErrorMessage.new("Job application ID is missing", 400)), status: :bad_request
return
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noticed that the JobApplications controller is not utilizing the authentication tokens or the authenticate_user method that has been defined in the ApplicationController. Other controllers in the application are using these for authentication, so I wanted to flag this for consistency and security purposes.

Could you clarify if this was intentional or an oversight? If it's an oversight, it might be worth adding the necessary authentication logic to ensure this controller aligns with the others. I'm curious to hear your thoughts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

Job Application Show Page BE
3 participants