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

feature: create wallet api #14

Open
wants to merge 2 commits into
base: feature/authentication-api
Choose a base branch
from

Conversation

tranducminh
Copy link
Owner

Requirement

  • Require login before
  • Any user can create your own wallet
  • Allowed user can get information of the wallet (include owner manager observer)
  • Only owner of the wallet can update or delete it

Comment on lines +7 to +9
current_user.user_wallets.each do |user_wallet|
@wallets.push(user_wallet.wallet)
end
Copy link

Choose a reason for hiding this comment

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

Suggested change
current_user.user_wallets.each do |user_wallet|
@wallets.push(user_wallet.wallet)
end
@wallets = user_wallet.wallet

だけでいいかも

UserWallet.create(
user_id: current_user.id,
wallet_id: @wallet.id,
user_role: User::roles[:OWNER]
Copy link

Choose a reason for hiding this comment

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

Suggested change
user_role: User::roles[:OWNER]
user_role: User.roles[:OWNER]

https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/ColonMethodCall

end

def find_wallet
@wallet = Wallet.find_by(id: params[:id])
Copy link

Choose a reason for hiding this comment

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

idの時はfindの時の方がシンプル


def show
if accessible?
render :show, status: :ok
Copy link

Choose a reason for hiding this comment

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

省略可


private
def http_token
@http_token = request.headers['Authorization'].split(' ').last if request.headers['Authorization'].present?
Copy link

Choose a reason for hiding this comment

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

indentずれてる?

@SaSa-sa
Copy link

SaSa-sa commented Nov 18, 2021

ちなみに、MFではユニットテストにrspecを使ってます。
発表までに時間があれば、requestのテストを書いても良いかもしれませんね。

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.

2 participants