Permalink
Browse files

Merge pull request #138 from alphagov/feedex-handle-invalid-urls

Feedex: handle invalid URLs
  • Loading branch information...
2 parents 5716a73 + 10d2c1d commit 5735b3a57172fce41921099730ed99ce34478972 @bradwright bradwright committed Feb 18, 2014
@@ -31,7 +31,7 @@ def path
end
def self.find_all_starting_with_path(path)
- where("url is not null and url like ?", "%" + path + "%").free_of_personal_info.order("created_at desc").select { |pr| pr.path.start_with?(path) }
+ where("url is not null and url like ?", "%" + path + "%").free_of_personal_info.order("created_at desc").select { |pr| pr.path && pr.path.start_with?(path) }
end
private
@@ -60,6 +60,12 @@ def path_for(url)
assert result.include?(b)
end
+ should "ignore feedback with invalid URLs" do
+ contact(url: "https://www.gov.uk/abc def")
+
+ assert_equal [], TestContact.find_all_starting_with_path("/abc")
+ end
+
should "return the results in reverse chronological order" do
a, b, c = contact, contact, contact
a.created_at = Time.now - 1.hour

0 comments on commit 5735b3a

Please sign in to comment.