diff --git a/lib/supplejack/record.rb b/lib/supplejack/record.rb index f5e9d5a..5a886bc 100644 --- a/lib/supplejack/record.rb +++ b/lib/supplejack/record.rb @@ -130,10 +130,6 @@ def find(id_or_array, options = {}) response['records'].map { |attributes| new(attributes) } else begin - # handle malformed id's before requesting anything. - id = id_or_array.to_i - raise(Supplejack::MalformedRequest, "'#{id_or_array}' is not a valid record id") if id <= 0 - # Do not send any parameters in the :search key when the user didn't specify any options # And also always send the :fields parameter # @@ -150,7 +146,7 @@ def find(id_or_array, options = {}) options[:fields] = options[:search].delete(:fields) options.delete(:search) unless any_options - response = get("/records/#{id}", options) + response = get("/records/#{id_or_array}", options) new(response['record']) rescue RestClient::ResourceNotFound raise Supplejack::RecordNotFound, "Record with ID #{id_or_array} was not found" diff --git a/spec/supplejack/record_spec.rb b/spec/supplejack/record_spec.rb index 3aa2896..7748187 100644 --- a/spec/supplejack/record_spec.rb +++ b/spec/supplejack/record_spec.rb @@ -185,10 +185,6 @@ module Supplejack expect { SupplejackRecord.find(1) }.to raise_error(Supplejack::RecordNotFound) end - it 'raises a Supplejack::MalformedRequest' do - expect { SupplejackRecord.find('replace_this') }.to raise_error(Supplejack::MalformedRequest) - end - it 'requests the record from the API' do allow(SupplejackRecord).to receive(:get).with('/records/1', { fields: 'default' }).and_return({ 'record' => {} })