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

Get gifts #75

Merged
merged 22 commits into from Jun 24, 2021
Merged

Get gifts #75

merged 22 commits into from Jun 24, 2021

Conversation

mdotvasylenchuk
Copy link
Collaborator

@mdotvasylenchuk mdotvasylenchuk commented Jun 24, 2021

Get button

Changes description

Add posibility to get rewards and rspec

Screnshots of the added pages

image
image
image
image
image

Check list:

  • Integration Tests
  • Functional
  • Unit
  • Factories
  • Updated seed file
  • в тестах я виводжу тестові дані а не просто викликає get index, expect - success
  • у мене правильні відступи в файлі
  • у мене немає непотрібних коментарів в коді
  • CSS код який я написав не впливає на інші файли і може бути перевикористаний якщо десь буде схожий функціонал
  • я прописую повний шлях до паршалів
  • я називаю змінні так як треба і вони означають те що в них є, і якщо масив то в множині наприклад
  • я памятаю про те що є active record relations та асоціації і їх використовую
  • я переглянув що нема лишньо-видалених файлів
  • я переглянув що нема конфліктів в ПР
  • я переглянув ПР сам і готовий до штрафу якщо будуть якісь проблеми перелічені вище

@gift = current_organization.gifts.find(params[:id])
@result = current_user.purchase_gift(@gift)
respond_to do |format|
if @result == "Gift successfully added"
Copy link
Collaborator

Choose a reason for hiding this comment

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

не гуд, має бути true/false в резалті бути а не строка


def purchase_gift(gift)
if (balance - gift.price).negative?
return "There are not enough points on your balance"
Copy link
Collaborator

Choose a reason for hiding this comment

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

а якщо не true/false

то повертати якусь константу а не строку і залежно від неї вже робити що треба

if amount == 0
return :no_more_gifts

@@ -5,6 +5,9 @@
.col-lg-4.col-md-12.mb-4.text-center.btn
.card.shadow.p-3.mb-5.bg-white.border-0.gifts-card
= render partial: 'account/organization_gifts/gift', locals: { gift: gift }
.d-flex.justify-content-start
= button_to 'Get', receive_account_my_gift_path(id: gift.id), class:"button btn btn-outline-success nav-btn posts__card-button me-1 w-100", remote: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

заміни просто на receive_account_my_gift_path(gift)

p.fs-5.mb-4.lead.p-3
= @gift.description
.d-flex.flex-row.justify-content-center
= button_to 'Get', receive_account_my_gift_path(id: @gift.id), class:"button btn btn-outline-success nav-btn posts__card-button ms-1", remote: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

і тут

@mdotvasylenchuk mdotvasylenchuk merged commit fc8bdab into main Jun 24, 2021
@mdotvasylenchuk mdotvasylenchuk deleted the get_gifts branch June 24, 2021 20:16
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.

None yet

3 participants