mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-22 02:52:49 +01:00
parent
b35d1e4420
commit
be1dcce266
@ -8,7 +8,7 @@ class Quote
|
||||
|
||||
values do
|
||||
attribute :base, String, default: DEFAULT_BASE
|
||||
attribute :date, Date, default: Currency.current_date
|
||||
attribute :date, Date, default: proc { Currency.current_date }
|
||||
end
|
||||
|
||||
def rates
|
||||
|
@ -6,6 +6,7 @@ describe 'the API' do
|
||||
include Rack::Test::Methods
|
||||
|
||||
let(:app) { Sinatra::Application }
|
||||
let(:json) { Yajl::Parser.new.parse last_response.body }
|
||||
|
||||
it 'handles unfound pages' do
|
||||
get '/foo'
|
||||
@ -31,4 +32,14 @@ describe 'the API' do
|
||||
get '/latest?base=USD?callback=?'
|
||||
last_response.must_be :unprocessable?
|
||||
end
|
||||
|
||||
it 'returns fresh dates' do
|
||||
Currency.db.transaction do
|
||||
new_date = Currency.current_date + 1
|
||||
Currency.create(date: new_date, iso_code: 'FOO', rate: 1)
|
||||
get '/latest'
|
||||
json['date'].must_equal new_date.to_s
|
||||
raise Sequel::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user