Skip to content

Commit d7ece18

Browse files
committed
lint
1 parent 98858da commit d7ece18

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

app/controllers/admin/currency_conversions_controller.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ class CurrencyConversionsController < Admin::BaseController
77

88
# GET /currency_conversions
99
def index
10-
#todo: rescue currency that doesnt exist
10+
# TODO: rescue currency that doesnt exist
1111
currency_conversions_with_symbols = @conference.currency_conversions.map do |conversion|
1212
{
1313
from_currency: conversion.from_currency,
14-
to_currency: conversion.to_currency,
15-
rate: conversion.rate,
16-
symbol: Money::Currency.new(conversion.to_currency).symbol
14+
to_currency: conversion.to_currency,
15+
rate: conversion.rate,
16+
symbol: Money::Currency.new(conversion.to_currency).symbol
1717
}
1818
end
1919

app/controllers/payments_controller.rb

+9-11
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ def index
1212
end
1313

1414
def new
15-
# todo: use "base currency"
15+
# TODO: use "base currency"
1616
session[:selected_currency] = params[:currency] if params[:currency].present?
1717
selected_currency = session[:selected_currency] || 'USD'
18-
from_currency = "USD"
18+
from_currency = 'USD'
1919

2020
@total_amount_to_pay = convert_currency(Ticket.total_price(@conference, current_user, paid: false).amount, from_currency, selected_currency)
2121
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) if @total_amount_to_pay.zero?
2222

2323
@has_registration_ticket = params[:has_registration_ticket]
2424
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
25-
#a way to display the currency values in the view, but there might be a better way to do this.
25+
# a way to display the currency values in the view, but there might be a better way to do this.
2626
@converted_prices = {}
2727
@unpaid_ticket_purchases.each do |ticket_purchase|
28-
#hardcoded
28+
# hardcoded
2929
@converted_prices[ticket_purchase.id] = convert_currency(ticket_purchase.price.amount, 'USD', selected_currency)
3030
end
3131
@currency = selected_currency
3232
end
3333

3434
def create
35-
@payment = Payment.new (payment_params)
35+
@payment = Payment.new(payment_params)
3636

3737
if @payment.purchase && @payment.save
3838
update_purchased_ticket_purchases
@@ -80,20 +80,18 @@ def load_currency_conversions
8080

8181
def convert_currency(amount, from_currency, to_currency)
8282
update_rate(from_currency, to_currency)
83-
83+
8484
money_amount = Money.from_amount(amount, from_currency)
85-
converted_amount = money_amount.exchange_to(to_currency)
86-
converted_amount
85+
money_amount.exchange_to(to_currency)
8786
end
88-
87+
8988
def update_rate(from_currency, to_currency)
9089
conversion = @currency_conversions.find_by(from_currency: from_currency, to_currency: to_currency)
9190
if conversion
9291
Money.add_rate(from_currency, to_currency, conversion.rate)
9392
else
94-
#If no conversion is found. Typically only possible if base to base. Maybe make this error out.
93+
# If no conversion is found. Typically only possible if base to base. Maybe make this error out.
9594
Money.add_rate(from_currency, to_currency, 1) unless from_currency == to_currency
9695
end
9796
end
98-
9997
end

app/models/ticket_purchase.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def self.purchase_ticket(conference, quantity, ticket, user, currency)
7171
user_id: user.id,
7272
quantity: quantity,
7373
amount_paid: ticket.price,
74-
currency: currency)
74+
currency: currency)
7575
purchase.pay(nil) if ticket.price_cents.zero?
7676
end
7777
purchase

app/views/payments/_payment.html.haml

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
%td
1818
= humanized_money_with_symbol @converted_prices[ticket.id]
1919
%td
20-
= humanized_money_with_symbol (@converted_prices[ticket.id] * ticket.quantity)
21-
20+
= humanized_money_with_symbol (@converted_prices[ticket.id] * ticket.quantity)
2221
= form_tag conference_payments_path(@conference.short_title, :has_registration_ticket => @has_registration_ticket) do
2322
%script.stripe-button{ src: "https://checkout.stripe.com/checkout.js",
2423
data: { amount: @total_amount_to_pay.cents,

0 commit comments

Comments
 (0)