Permalink
Browse files

Fix new bmark page to now throw error.

- Fixes #296
- Add new Bookmark page throws error when a previously existing URL is added
  • Loading branch information...
1 parent e4b3003 commit e40dacda3c4e641748a7be8926864f62590bf0d0 @rishirajsinghjhelumi rishirajsinghjhelumi committed with Feb 26, 2014
Showing with 43 additions and 0 deletions.
  1. +32 −0 bookie/tests/test_webviews/test_webviews.py
  2. +11 −0 bookie/views/bmarks.py
@@ -108,6 +108,38 @@ def test_manual_entry_error(self):
})
self.assertIn('not valid', res.body)
+ def test_existing_url_entry_error(self):
+ """ Verify the User has received error message that URL exists"""
+ self._login_admin()
+
+ test_url = u"http://bmark.us/test"
+ existing_url_message = "URL already Exists"
+
+ # Add The Bookmark Once
+ res = self.app.post(
+ '/admin/new_error',
+ params={
+ 'url': test_url,
+ 'description': '',
+ 'extended': '',
+ 'tags': ''
+ })
+ self.assertEqual(
+ res.status,
+ "302 Found",
+ msg='recent status is 302 Found, ' + res.status)
+
+ # Add the Bookmark Again
+ res = self.app.post(
+ '/admin/new_error',
+ params={
+ 'url': test_url,
+ 'description': '',
+ 'extended': '',
+ 'tags': ''
+ })
+ self.assertIn(existing_url_message, res.body)
+
class TestRSSFeeds(TestViewBase):
"""Verify the RSS feeds function correctly."""
View
@@ -165,6 +165,17 @@ def edit_error(request):
with ReqAuthorize(request, username=rdict['username']):
if 'new' in request.url:
try:
+ try:
+ bmark = BmarkMgr.get_by_url(post['url'])
+ except:
+ bmark = None
+ if bmark:
+ return {
+ 'new': False,
+ 'bmark': bmark,
+ 'message': "URL already Exists",
+ 'user': request.user,
+ }
bmark = BmarkMgr.store(
post['url'],
request.user.username,

0 comments on commit e40dacd

Please sign in to comment.