Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/supplejack/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions spec/supplejack/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' => {} })

Expand Down
Loading