diff --git a/database/test/test.sql b/database/test/test.sql index 4b1a9a2..ead1e7f 100644 --- a/database/test/test.sql +++ b/database/test/test.sql @@ -54,7 +54,7 @@ INSERT INTO violation(inspection_id, violation_id) VALUES (3, 14); INSERT INTO location(id, name, address, postcode, city, rha) - VALUES (2, 'Water Front Lodge', 'Unknown', 'Unknown', '#1 Johnson Street', 'Northern Health - Mamaw/Keewa/Athab'); + VALUES (2, 'Water Front Lodge', null, null, '#1 Johnson Street', 'Northern Health - Mamaw/Keewa/Athab'); INSERT INTO inspection(id, location_id, inspection_date, inspection_type, reinspection_priority) VALUES (4, 2, '2014-09-23', 'Routine', 'Low'); @@ -78,7 +78,7 @@ INSERT INTO violation(inspection_id, violation_id) VALUES (6, 12); INSERT INTO location(id, name, address, postcode, city, rha) - VALUES (3, 'Robinson Country Cookhouse & Saloon', 'Cupar', 'Unknown', 'Cupar', 'Regina QuAppelle Health Authority'); + VALUES (3, 'Robinson Country Cookhouse & Saloon', 'Cupar', null, 'Cupar', 'Regina QuAppelle Health Authority'); INSERT INTO inspection(id, location_id, inspection_date, inspection_type, reinspection_priority) VALUES (7, 3, '2014-02-14', 'Routine', 'Low'); diff --git a/test/ApplicationSpecMainTest.scala b/test/ApplicationSpecMainTest.scala index aaa7a0c..c3a5144 100644 --- a/test/ApplicationSpecMainTest.scala +++ b/test/ApplicationSpecMainTest.scala @@ -63,7 +63,7 @@ class ApplicationSpecMainTest extends Specification { "give error page when an invalid city url is requested" in new WithApplication { val error = route(FakeRequest(GET, "/find/octavia")).get - assert(status(error) must equalTo(OK)) + assert(status(error) must equalTo(404)) assert(contentAsString(error) must contain(Messages("errors.emptyCityDesc"))) } @@ -90,7 +90,8 @@ class ApplicationSpecMainTest extends Specification { typeahead.click typeahead.sendKeys("SASKATOON") typeahead.sendKeys(Keys.ENTER) - assert(browser.url must contain("/find/Saskatoon")) + assert(browser.url must contain("/find/SASKATOON")) + browser.title() must contain(Messages("locations.selectLocation.title"))//made it to not an aerror page } "display choose location page when location is typed in all lowercase" in new WithBrowser { @@ -99,7 +100,8 @@ class ApplicationSpecMainTest extends Specification { typeahead.click typeahead.sendKeys("saskatoon") typeahead.sendKeys(Keys.ENTER) - assert(browser.url must contain("/find/Saskatoon")) + assert(browser.url must contain("/find/saskatoon")) + browser.title() must contain(Messages("locations.selectLocation.title")) } "display choose location page when location is fully typed and submitted with enter" in new WithBrowser { @@ -153,7 +155,7 @@ class ApplicationSpecMainTest extends Specification { "display location page" should { "display show map page when address is clicked" in new WithBrowser { - browser.goTo("/view/1") + browser.goTo("/view/3675") val action = new Actions(browser.getDriver) action.moveToElement(browser.webDriver.findElement(By.tagName("a"))).perform action.click.perform @@ -191,7 +193,7 @@ class ApplicationSpecMainTest extends Specification { "display map page" should { "render a map on the page with a header" in new WithBrowser { //Navigate to a page with a map (uses previously tested navigation) - browser.goTo("/view/1") + browser.goTo("/view/3675")//this page needs to have a map link val action = new Actions(browser.getDriver) action.moveToElement(browser.webDriver.findElement(By.tagName("a"))).perform action.click.perform diff --git a/test/IntegrationSpecMainTest.scala b/test/IntegrationSpecMainTest.scala index b1d7085..12f73f2 100644 --- a/test/IntegrationSpecMainTest.scala +++ b/test/IntegrationSpecMainTest.scala @@ -64,7 +64,7 @@ class IntegrationSpecMainTest extends Specification { "display error for incorrect city but remain on current page" in new WithApplication { val result = controllers.LocationController.findLocation("#DOESNTEXIST")(FakeRequest()) - assert(status(result) == OK) + assert(status(result) must beEqualTo (404)) } } diff --git a/test/LocationSpecMainTest.scala b/test/LocationSpecMainTest.scala index 072074f..afe18b4 100644 --- a/test/LocationSpecMainTest.scala +++ b/test/LocationSpecMainTest.scala @@ -45,8 +45,8 @@ class LocationSpecMainTest extends Specification with Mockito { location.id must beEqualTo(7) // Ignore space due to trailing whitespace location.name must beEqualTo("Hogwarts Dining Hall").ignoreSpace - location.address must beEqualTo("Hogwarts Place").ignoreSpace - location.postalCode must beEqualTo("S0G 2J0").ignoreSpace + location.address.get must beEqualTo("Hogwarts Place").ignoreSpace + location.postalCode.get must beEqualTo("S0G 2J0").ignoreSpace } "return a failure if there is a bad database" in new WithApplication { @@ -79,7 +79,7 @@ class LocationSpecMainTest extends Specification with Mockito { "listCities" should { "list all cities with resteraunts in saskatchewan" in new WithApplication { val listOfCities = Location.listCities(); - listOfCities.get.length must beEqualTo(6) + listOfCities.get.length must beEqualTo(6+1)//the plus 1 is for Unknown City } "list should be in alphabetical order" in new WithApplication { val listOfCities = Location.listCities(); diff --git a/test/ParserSpecMainTest.scala b/test/ParserSpecMainTest.scala index 67e5662..7686e79 100644 --- a/test/ParserSpecMainTest.scala +++ b/test/ParserSpecMainTest.scala @@ -143,17 +143,17 @@ class ParserSpecMainTest extends Specification { robinsonRow[String]("name") must beEqualTo("Robinson Country Cookhouse & Saloon") robinsonRow[String]("address") must beEqualTo("Cupar") robinsonRow[String]("city") must beEqualTo("Cupar") - robinsonRow[String]("postcode") must beEqualTo("Unknown") + robinsonRow[Option[String]]("postcode") must beEqualTo(None) robinsonRow[String]("rha") must beEqualTo("Regina QuAppelle Health Authority") tastyRow[String]("name") must beEqualTo("Tasty J's") tastyRow[String]("address") must beEqualTo("305 Pacific Avenue") tastyRow[String]("city") must beEqualTo("Luseland") - tastyRow[String]("postcode") must beEqualTo("S0L 2A0") + tastyRow[Option[String]]("postcode").get must beEqualTo("S0L 2A0") tastyRow[String]("rha") must beEqualTo("Heartland Health Authority") waterRow[String]("name") must beEqualTo("Water Front Lodge") - waterRow[String]("address") must beEqualTo("Unknown") + waterRow[Option[String]]("address") must beEqualTo(None) waterRow[String]("city") must beEqualTo("#1 Johnson Street") - waterRow[String]("postcode") must beEqualTo("Unknown") + waterRow[Option[String]]("postcode") must beEqualTo(None) waterRow[String]("rha") must beEqualTo("Northern Health - Mamaw/Keewa/Athab") } }