File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def apply_pending_changes_to_new_record!
5656
5757 def normalised ( value )
5858 if value . is_a? ( String )
59- value . downcase . presence
59+ value . downcase . normalise_whitespace &. presence
6060 elsif value . is_a? ( Time )
6161 value . round
6262 else
Original file line number Diff line number Diff line change 6262 end
6363
6464 describe "#normalised" do
65- it "downcases strings and returns presence " do
65+ it "downcases strings" do
6666 expect ( model . send ( :normalised , "HELLO WORLD" ) ) . to eq ( "hello world" )
6767 expect ( model . send ( :normalised , "Mixed Case" ) ) . to eq ( "mixed case" )
6868 expect ( model . send ( :normalised , "lowercase" ) ) . to eq ( "lowercase" )
6969 end
7070
71+ it "normalises whitespace in strings" do
72+ expect ( model . send ( :normalised , " Hello World " ) ) . to eq ( "hello world" )
73+ expect ( model . send ( :normalised , "Hello\t World" ) ) . to eq ( "hello world" )
74+ end
75+
7176 it "returns nil for empty strings" do
7277 expect ( model . send ( :normalised , "" ) ) . to be_nil
7378 expect ( model . send ( :normalised , " " ) ) . to be_nil
You can’t perform that action at this time.
0 commit comments