@@ -506,10 +506,36 @@ class EditionTest < ActiveSupport::TestCase
506506 assert_equal [ edition_with_first_keyword ] , Edition . with_title_containing ( "klingons" )
507507 end
508508
509- test "should find editions with slug containing keyword" do
510- edition_with_first_keyword = create ( :edition , title : "klingons rule" )
511- _edition_without_first_keyword = create ( :edition , title : "this document is about muppets" )
512- assert_equal [ edition_with_first_keyword ] , Edition . with_title_containing ( "klingons-rule" )
509+ test "should find editions by slug, when given the exact slug" do
510+ edition_with_slug = create ( :edition , title : "New title" , slug_override : "klingons-rule" )
511+ _edition_without_match = create ( :edition , title : "this document is about muppets" )
512+
513+ assert_equal "klingons-rule" , edition_with_slug . slug
514+ assert_equal [ edition_with_slug ] , Edition . with_title_containing ( "klingons-rule" )
515+ end
516+
517+ test "should find editions by slug, when given a full path ending in a slug" do
518+ edition_with_slug = create ( :edition , title : "New title" , slug_override : "klingons-rule" )
519+ _edition_without_match = create ( :edition , title : "this document is about muppets" )
520+
521+ assert_equal "klingons-rule" , edition_with_slug . slug
522+ assert_equal [ edition_with_slug ] , Edition . with_title_containing ( "/government/news/klingons-rule" )
523+ end
524+
525+ test "should find editions by slug, when given a full URL ending in a slug" do
526+ edition_with_slug = create ( :edition , title : "New title" , slug_override : "klingons-rule" )
527+ _edition_without_match = create ( :edition , title : "this document is about muppets" )
528+
529+ assert_equal "klingons-rule" , edition_with_slug . slug
530+ assert_equal [ edition_with_slug ] , Edition . with_title_containing ( "https://www.gov.uk/government/news/klingons-rule" )
531+ end
532+
533+ test "should find editions by slug, when given a full URL, including query string and fragment" do
534+ edition_with_slug = create ( :edition , title : "New title" , slug_override : "klingons-rule" )
535+ _edition_without_match = create ( :edition , title : "this document is about muppets" )
536+
537+ assert_equal "klingons-rule" , edition_with_slug . slug
538+ assert_equal [ edition_with_slug ] , Edition . with_title_containing ( "https://www.gov.uk/government/news/klingons-rule?foo=bar#details" )
513539 end
514540
515541 test "should find editions with title containing regular expression characters" do
0 commit comments