Merge branch 'dev' into awesomecode-factorybot/createlist-12138

This commit is contained in:
Daniel O'Connor
2018-05-10 21:35:39 +09:30
committed by GitHub
2 changed files with 0 additions and 22 deletions

View File

@@ -1,26 +1,9 @@
module ApplicationHelper
def price_in_dollars(price)
format('%.2f', price / 100.0)
end
# 999 cents becomes 9.99 AUD -- for products/orders/etc
def price_with_currency(price)
format('%.2f %s', price / 100.0, Growstuff::Application.config.currency)
end
def parse_date(str)
str ||= '' # Date.parse barfs on nil
str == '' ? nil : Date.parse(str)
end
def forex_link(price)
pid = price_in_dollars(price)
currency = Growstuff::Application.config.currency
link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}"
link_to "(convert)", link, target: "_blank", rel: "noopener noreferrer"
end
def build_alert_classes(alert_type = :info)
classes = 'alert alert-dismissable '
case alert_type.to_sym

View File

@@ -1,11 +1,6 @@
require 'rails_helper'
describe ApplicationHelper do
it "formats prices" do
price_in_dollars(999).should eq '9.99'
price_with_currency(999).should eq format('9.99 %s', Growstuff::Application.config.currency)
end
it "parses dates" do
parse_date(nil).should eq nil
parse_date('').should eq nil