Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add api for profile update#442

Merged
supriya3105 merged 8 commits intodevelopfrom
profile-settings-api
Jun 9, 2022
Merged

add api for profile update#442
supriya3105 merged 8 commits intodevelopfrom
profile-settings-api

Conversation

@apoorv1316
Copy link
Collaborator

@apoorv1316 apoorv1316 commented Jun 6, 2022

Notion card

https://www.notion.so/saeloun/6afc9500b2cc42af86be55f37894fb09?v=185bd45b9dc24dfcad9c57c07d32a7c0&p=1e983c2b00964a228c9ceabc2157b6d8

Summary

Preview

Added profile settings API to update first_name, last_name, password, and remove avatar of the user.

Screenshot 2022-06-06 at 9 44 14 AM

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • I have manually tested all workflows
  • I have performed a self-review of my own code
  • I have added automated tests for my code

@github-actions
Copy link

github-actions bot commented Jun 6, 2022

Current Code Coverage Percent of this PR:

87.7 %

Files having coverage below 100%

Impacted Files Coverage
/app/controllers/users/invitations_controller.rb 86.36 %
/app/policies/payments/provider_policy.rb 85.71 %
/app/services/invoice_payment/checkout.rb 44.0 %
/app/services/invoice_payment/pdf_generation.rb 70.97 %
/app/services/report/filters.rb 87.1 %
/app/controllers/internal_api/v1/profile_controller.rb 96.88 %
/app/controllers/internal_api/v1/payment_settings_controller.rb 93.33 %
/app/controllers/internal_api/v1/payments/providers_controller.rb 94.74 %
/lib/benchmarking/benchmarker.rb 0.0 %


class ProfilePolicy < ApplicationPolicy
def remove_avatar?
true
Copy link
Member

Choose a reason for hiding this comment

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

can you add the user

end

def update?
true
Copy link
Member

Choose a reason for hiding this comment

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

here also


def update?
true
end
Copy link
Member

Choose a reason for hiding this comment

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

please fix the alignment

Comment on lines 40 to 41
delete "profile/remove_avatar", to: "profile#remove_avatar"
put "profile", to: "profile#update"
Copy link
Member

Choose a reason for hiding this comment

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

can we use a resourceful route

def index
authorize :index, policy_class: ProfilePolicy
render json: { user: current_user }
if current_user.avatar.attached?
Copy link
Member

Choose a reason for hiding this comment

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

this will return 500 error if the avatar is not attaches. because avatar_url is not defined in that case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nah it returns null

else
render json: { error: "something went wrong" }, status: :unprocessable_entity
end
rescue Exception => e
Copy link
Member

Choose a reason for hiding this comment

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

align the rescue with def

@apoorv1316 apoorv1316 requested a review from akhilgkrishnan June 8, 2022 08:42
@apoorv1316
Copy link
Collaborator Author

@akhilgkrishnan Can you please re-review it?

Comment on lines 40 to 43
resource :profile, only: [:update], controller: "profile" do
delete "/remove_avatar", to: "profile#remove_avatar"
get "/", to: "profile#index"
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
resource :profile, only: [:update], controller: "profile" do
delete "/remove_avatar", to: "profile#remove_avatar"
get "/", to: "profile#index"
end
resource :profile, only: [:update, :show], controller: "profile" do
delete "/remove_avatar", to: "profile#remove_avatar"
end

Use show action instead of index in singular route

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@akhilgkrishnan Then should I also change the action from "index" to "show" in the profile controller?

Copy link
Member

@akhilgkrishnan akhilgkrishnan left a comment

Choose a reason for hiding this comment

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

LGTM

@supriya3105 supriya3105 merged commit 1935b14 into develop Jun 9, 2022
@supriya3105 supriya3105 deleted the profile-settings-api branch June 9, 2022 08:21
vipulnsward pushed a commit that referenced this pull request Feb 15, 2026
* add api for profile update

* add index action

* send avatar in index action

* add request specs

* fix review comments

* use show action instead of index

* update spec notice

Co-authored-by: “Apoorv <“[email protected]”>
Co-authored-by: Akhil G Krishnan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants