Commits

Luke Plant  committed 19635b7

Removed 'iter' argument from makeSlugGeneric, since it is an implementation detail

  • Participants
  • Parent commits b0a875f

Comments (0)

Files changed (7)

File src/Blog/Category.hs

                        [[newid]] <- quickQuery cn "SELECT last_insert_rowid();" [];
                        return c2 { uid = fromSql $ newid }
 
-makeCategorySlug cn cat = makeSlugGeneric cn (name cat) "categories" 1
+makeCategorySlug cn cat = makeSlugGeneric cn (name cat) "categories"

File src/Blog/DBUtils.hs

                       regexReplace (B.pack "-+$") (B.pack "") $
                       regexReplace (B.pack "[^A-Za-z0-9]+") (B.pack "-") (B.pack title)
 
-makeSlugGeneric cn title table iter = makeSlugGeneric' cn (slugFromTitle title) table iter
+makeSlugGeneric cn title table = makeSlugGeneric' cn (slugFromTitle title) table 1
 makeSlugGeneric' cn slugBase table iter = do
   let slugAttempt =  (slugBase ++ makeSuffix iter);
   [[SqlString c]] <- quickQuery cn ("SELECT count(slug) FROM " ++ table ++ " WHERE slug = ?") [toSql slugAttempt];

File src/Blog/Post.hs

                     return p2 { uid = fromSql $ newid } ;
                   }
 
-makePostSlug cn p = makeSlugGeneric cn (title p) "posts" 1
+makePostSlug cn p = makeSlugGeneric cn (title p) "posts"
 
 addPostCategory cn pc = do { DB.doInsert cn "post_categories"
                              ["post_id",

File testsuite/tests/Test/Blog/DBUtils.hs

-module Tests.Blog.DBUtils
-
-where
-
-import Blog.DBUtils
-import Database.HDBC
-import Test.HUnit
-import qualified Test.Blog.TestDB as TestDB
-
-makeTestSlugTable cn = do
-  quickQuery cn "CREATE TABLE slugs (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, slug TEXT);" []
-
-insertSlug cn title slug = do
-  quickQuery cn "INSERT INTO slugs (title, slug) VALUES (?, ?);" [toSql title, toSql slug]
-
-slugFromTitle1 =  "this-is-a-title" ~=? (slugFromTitle "This is a % $ /title ^£$")
-makeSlugGeneric1 = do
-  cn <- TestDB.connect;
-  makeTestSlugTable cn
-  slug1 <- makeSlugGeneric cn "This is a title" "slugs" 1
-  assertEqual "" "this-is-a-title" slug1
-  insertSlug cn "This is a title" slug1
-  slug2 <- makeSlugGeneric cn "This is a title" "slugs" 1
-  insertSlug cn "This is a title" slug2
-  assertEqual "" "this-is-a-title2" slug2
-
-tests = test [
-         slugFromTitle1,
-         TestCase makeSlugGeneric1
-        ]

File testsuite/tests/Test/Blog/TestDB.hs

-module Test.Blog.TestDB where
-
-import Database.HDBC.Sqlite3 (connectSqlite3)
-import qualified Blog.Settings as Settings
-
-connect = connectSqlite3 Settings.testdb_sqlite_path

File testsuite/tests/Tests/Blog/DBUtils.hs

+module Tests.Blog.DBUtils
+
+where
+
+import Blog.DBUtils
+import Database.HDBC
+import Test.HUnit
+import qualified Tests.Blog.TestDB as TestDB
+
+makeTestSlugTable cn = do
+  quickQuery cn "CREATE TABLE slugs (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, slug TEXT);" []
+
+insertSlug cn title slug = do
+  quickQuery cn "INSERT INTO slugs (title, slug) VALUES (?, ?);" [toSql title, toSql slug]
+
+slugFromTitle1 =  "this-is-a-title" ~=? (slugFromTitle "This is a % $ /title ^£$")
+makeSlugGeneric1 = do
+  cn <- TestDB.connect;
+  makeTestSlugTable cn
+  slug1 <- makeSlugGeneric cn "This is a title" "slugs"
+  assertEqual "" "this-is-a-title" slug1
+  insertSlug cn "This is a title" slug1
+  slug2 <- makeSlugGeneric cn "This is a title" "slugs"
+  insertSlug cn "This is a title" slug2
+  assertEqual "" "this-is-a-title2" slug2
+
+tests = test [
+         slugFromTitle1,
+         TestCase makeSlugGeneric1
+        ]

File testsuite/tests/Tests/Blog/TestDB.hs

+module Tests.Blog.TestDB where
+
+import Database.HDBC.Sqlite3 (connectSqlite3)
+import qualified Blog.Settings as Settings
+
+connect = connectSqlite3 Settings.testdb_sqlite_path