mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-25 04:22:28 +01:00
Handle circular conversions (#51)
This commit is contained in:
parent
9bd9e4dd95
commit
30cda9b048
@ -1,9 +1,13 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# FIXME: Validations are all over. Clean up!
|
||||||
class Query
|
class Query
|
||||||
class << self
|
class << self
|
||||||
def build(params)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -53,4 +53,11 @@ describe "the server" do
|
|||||||
raise Sequel::Rollback
|
raise Sequel::Rollback
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user