mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-21 18:42:29 +01:00
Handle circular conversions (#51)
This commit is contained in:
parent
9bd9e4dd95
commit
30cda9b048
@ -1,9 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# FIXME: Validations are all over. Clean up!
|
||||
class Query
|
||||
class << self
|
||||
def build(params)
|
||||
new(params).to_h
|
||||
query = new(params).to_h
|
||||
raise ArgumentError, "bad currency pair" if [query[:base]] == query[:symbols]
|
||||
|
||||
query
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -53,4 +53,11 @@ describe "the server" do
|
||||
raise Sequel::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
it "will not process circular conversions" do
|
||||
get "/latest?from=EUR&to=EUR"
|
||||
_(last_response).must_be(:unprocessable?)
|
||||
get "/latest?from=USD&to=USD"
|
||||
_(last_response).must_be(:unprocessable?)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user