mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 21:56:55 -04:00
Merge branch 'dev' into awesomecode-factorybot/createlist-12138
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user