Skip to content
Browse files

Merge commit 'f8a6146194795fce3a36fcef6d64718cc32fe6ca' into HEAD

  • Loading branch information...
2 parents 52d154f + f8a6146 commit a9ee009f279b19bf899eb281643337ca45b293cf Jenkins committed
Showing with 8 additions and 0 deletions.
  1. +2 −0 app/models/artefact.rb
  2. +6 −0 test/unit/artefact_test.rb
View
2 app/models/artefact.rb
@@ -92,5 +92,7 @@ def as_json(options={})
def self.from_param(slug_or_id)
# FIXME: A hack until the Publisher has panopticon ids for every article
find_by_slug(slug_or_id) || find(slug_or_id)
+ rescue BSON::InvalidObjectId
+ raise Mongoid::Errors::DocumentNotFound.new(self, slug_or_id)
end
end
View
6 test/unit/artefact_test.rb
@@ -42,4 +42,10 @@ class ArtefactTest < ActiveSupport::TestCase
assert_equal [b, c], a.related_artefacts
end
+
+ test "should raise a not found exception if the slug doesn't match" do
+ assert_raise 'Mongoid::Errors::DocumentNotFound' do
+ Artefact.from_param('something-fake')
+ end
+ end
end

0 comments on commit a9ee009

Please sign in to comment.
Something went wrong with that request. Please try again.