Permalink
Browse files

Merge branch 'Release-0.8.1'

  • Loading branch information...
2 parents 1dd71fc + e10be71 commit 45bff4de0e03c1a2d9c45928718f269dc7c088d4 @randomcoder randomcoder committed Jun 19, 2012
View
@@ -12,3 +12,6 @@ alias clean-test-db = ;project db;clean;test;project root
alias clean-test-lift = ;project lift;clean;test;project root
alias setup-eclipse = ;project root;eclipse skip-root;
+
+alias clean-package = ;project root;clean;package
+
@@ -39,15 +39,20 @@ object AddressParser {
* @return An Option[[[uk.co.randomcoding.partsdb.core.address.Address]]] if the input string matches
*/
def unapply(nameAndAddress: (String, Seq[String], String)): Option[Address] = {
- val addressLines = nameAndAddress._2 map (_.replaceAll("""[,\.]$""", "") trim) filter (_ nonEmpty) //addressString.split("""[,\.]+""") map (_ trim)
- val shortName = nameAndAddress._1.trim match {
- case "" => addressLines(0)
- case s => s
- }
+ nameAndAddress match {
+ case (_, Nil, _) => None
+ case _ => {
+ val addressLines = nameAndAddress._2 map (_.replaceAll("""[,\.]$""", "") trim) filter (_ nonEmpty) //addressString.split("""[,\.]+""") map (_ trim)
+ val shortName = nameAndAddress._1.trim match {
+ case "" => addressLines(0)
+ case s => s
+ }
- identifyCountry(nameAndAddress._3) match {
- case Some(code) if (addressLines.size >= 1) => Some(Address(shortName, addressLines.mkString("\n"), code.countryName))
- case _ => None
+ identifyCountry(nameAndAddress._3) match {
+ case Some(code) if (addressLines.size >= 1) => Some(Address(shortName, addressLines.mkString("\n"), code.countryName))
+ case _ => None
+ }
+ }
}
}
@@ -97,6 +97,18 @@ class AddressParserTest extends FunSuite with ShouldMatchers {
}
}
+ test("Passing an empty list as the address text correctly returns None") {
+ ("", Nil, "") match {
+ case AddressParser(addr) => fail("No match expected for an empty list address text with empty short name and country")
+ case _ => // passed
+ }
+
+ ("Short", Nil, "United Kingdom") match {
+ case AddressParser(addr) => fail("No match expected for an empty list address text")
+ case _ => // passed
+ }
+ }
+
private val verifyAddress = (expectedAddress: String, addr: Address, shortName: String, country: String) => {
addr.shortName.get should be(shortName)
addr.addressText.get should be(expectedAddress)
@@ -1,3 +1,3 @@
mongo.db=MainDb
-app.version.number=0.8.0
+app.version.number=0.8.1
current.db.version=3
@@ -36,7 +36,7 @@ object DeliveryNoteDetailDisplay extends DocumentTotalsDisplay with PrintDocumen
"#billingAddressCountry" #> styledText(addressCountry, (s: String) => (), readonly) &
"#lineItems" #> LineItemDisplay(deliveryNote.lineItems.get) &
renderDocumentTotals(deliveryNote) &
- "#raiseInvoice" #> buttonLink("Raise Invoice", "/app/invoice?transactionId=%s&deliveryId=%s".format(transactionId, deliveryNote.id.get.toString)) &
+ "#raiseInvoice" #> (if (deliveryNote.editable.get) buttonLink("Raise Invoice", "/app/invoice?transactionId=%s&deliveryId=%s".format(transactionId, deliveryNote.id.get.toString)) else Text("")) &
renderPrintDocument(deliveryNote)
})
}
@@ -34,7 +34,7 @@ object InvoiceDetailDisplay extends DocumentTotalsDisplay with PrintDocumentSnip
"#billingAddressCountry" #> styledText(addressCountry, (s: String) => (), readonly) &
"#lineItems" #> LineItemDisplay(invoice.lineItems.get) &
renderDocumentTotals(invoice) &
- "#payInvoice" #> buttonLink("Pay Invoice", "/app/payInvoice?transactionId=%s&invoiceId=%s".format(transactionId, invoice.id.get.toString)) &
+ "#payInvoice" #> (if (invoice.editable.get) buttonLink("Pay Invoice", "/app/payInvoice?transactionId=%s&invoiceId=%s".format(transactionId, invoice.id.get.toString)) else Text("")) &
renderPrintDocument(invoice)
})
}
@@ -3,6 +3,8 @@
*/
package uk.co.randomcoding.partsdb.lift.util.snippet.display
+import scala.xml.Text
+
import uk.co.randomcoding.partsdb.core.document.Document
import uk.co.randomcoding.partsdb.lift.util.DateHelpers._
import uk.co.randomcoding.partsdb.lift.util.TransformHelpers._
@@ -23,7 +25,7 @@ object OrderDetailDisplay extends DocumentTotalsDisplay with PrintDocumentSnippe
"#orderedOn" #> dateString(order.createdOn.get) &
"#lineItems" #> LineItemDisplay(order.lineItems.get) &
renderDocumentTotals(order) &
- "#raiseDelivery" #> buttonLink("Raise Delivery Note", "/app/delivery?transactionId=%s".format(transactionId)) &
+ "#raiseDelivery" #> (if (order.editable.get) buttonLink("Raise Delivery Note", "/app/delivery?transactionId=%s".format(transactionId)) else Text("")) &
renderPrintDocument(order)
})
}
@@ -3,6 +3,8 @@
*/
package uk.co.randomcoding.partsdb.lift.util.snippet.display
+import scala.xml.Text
+
import org.joda.time.DateTime
import uk.co.randomcoding.partsdb.core.document.Document
@@ -26,9 +28,9 @@ object QuoteDetailDisplay extends DocumentTotalsDisplay with PrintDocumentSnippe
"#quotedOn" #> new DateTime(quote.createdOn.get).toString("dd/MM/yyyy") &
"#lineItems" #> LineItemDisplay(quote.lineItems.get) &
renderDocumentTotals(quote) &
- "#raiseOrder" #> buttonLink("Raise Order", "/app/order?transactionId=%s".format(transactionId)) &
+ "#raiseOrder" #> (if (quote.editable.get) buttonLink("Raise Order", "/app/order?transactionId=%s".format(transactionId)) else Text("")) &
renderPrintDocument(quote) &
- "#editQuoteButton" #> buttonLink("Edit Quote", "/app/quote?id=%s".format(quote.id.get))
+ "#editQuoteButton" #> (if (quote.editable.get) buttonLink("Edit Quote", "/app/quote?id=%s".format(quote.id.get)) else Text(""))
})
}
}
@@ -9,7 +9,7 @@ import Keys._
object BuildSettings {
val buildOrganization = "uk.co.randomcoding"
- val buildVersion = "0.8.0"
+ val buildVersion = "0.8.1"
val buildScalaVersion = "2.9.1"
val buildSettings = Defaults.defaultSettings ++ Seq(

0 comments on commit 45bff4d

Please sign in to comment.