Filter symbols

This commit is contained in:
Hakan Ensari 2012-11-23 14:27:09 +00:00
parent 631d42207b
commit 15092bce7b
2 changed files with 11 additions and 2 deletions

View File

@ -6,10 +6,20 @@ require 'yajl'
set :root, File.expand_path('..', File.dirname(__FILE__))
helpers do
# Ugly as fuck.
def snapshot
Snapshot
symbols = params.delete('symbols') || params.delete('currencies')
quote = Snapshot
.new(params)
.quote
if symbols
symbols = symbols.split ','
quote[:rates].keep_if { |k, v| symbols.include? k }
end
quote
end
end

View File

@ -20,7 +20,6 @@ describe 'the application' do
end
it 'filters symbols' do
skip 'enterprise feature'
get '/latest?symbols=USD'
json['rates'].keys.must_equal %w(USD)
end