NCIOCPL / cgov-digital-platform

The Cancer.gov Digital Communications Platform
GNU General Public License v2.0
11 stars 33 forks source link

Meta: Enforce URL uniqueness rules #4442

Open blairlearn opened 2 months ago

blairlearn commented 2 months ago

Enforce URL uniqueness rules across entity types: node, taxonomy, media, blog

The purpose of this ticket is to gather all the URL uniqueness validation rules and acceptance criteria in one place and verify that the code follows them.

Entity types to be covered include

The general validation logic is along the lines of

  1. Fetch the parent cgov_site_section
  2. Get the parent's computed_path
  3. Append the proposed field_pretty_url value
  4. Check for the existence of any other cgov_site_section with that same computed_path

Related Tickets:

Related Resources

Acceptance Criteria

Node:

Scenario: System does not allow the user to create a node item where the site section path + pretty URL matches another site section's path
  Given the Research site section with path /research exists
    And the Areas site section with path /research/areas exists
    And the user is creating a new node item within Research site section
  When the user sets the node item's pretty URL to "areas" and tries to save
  Then the system will not allow the user to save the content item

Scenario: System does not allow the user to create a node item where the site section path + pretty URL matches another node item's site section path + pretty URL
  Given the Training site section with path /grants-training/training exists
    And a node item exists within Training site section and pretty URL set to "funding"
    And the user is creating a new node item within Training site section
  When the user sets the node item's pretty URL to "funding" and tries to save
  Then the system will not allow the user to save the content item

Scenario: System allows the user to create a node item where the pretty URL matches another node item's pretty URL, but with a different parent
  Given the Research site section with path /research exists
    And a node item within Research site section with pretty URL set to "funding" exists
    And the Training site section with path /grants-training/training exists
    And the user is creating a new node item within Training site section
  When the user sets the pretty URL to "funding" and tries to save
  Then the system will allow the user to save the content item

Blog Series/Post:

Scenario: System does not allow the user to create a blog post where the blog series path + pretty URL matches another blog post's
  Given the Cancer Currents blog series with path /news-events/cancer-currents-blog exists
    And a blog post exists within Cancer Currents blog series and has pretty URL set to "blog-post-1"
    And the user is creating a new blog post within Cancer Currents blog series
  When the user sets the pretty URL to "blog-post-1" and tries to save
  Then the system will not allow the user to save the blog post

Scenario: System allows the user to create a blog post where the pretty URL matches another blog post's pretty URL, but with a different parent
  Given the Cancer Currents blog series with path /news-events/cancer-currents-blog exists
    And a blog post exists within Cancer Currents blog series and has pretty URL set to "blog-post-1"
    And the NCI Bottom Line blog series with path /grants-training/nci-bottom-line exists
    And the user is creating a new blog post within NCI Bottom Line blog series
  When the user sets the pretty URL to "blog-post-1" and tries to save
  Then the system will allow the user to save the blog post

Scenario: System does not allow the user to create a new blog series with the same name as another blog series
  Given the Cancer Currents blog series with path /news-events/cancer-currents-blog exists
    And the user is creating a new blog series with path /news-events/cancer-currents-blog-2
  When the user sets the blog series name to "Cancer Currents" and tries to save
  Then the system will not allow the user to save the blog series

Site Section:

Scenario: System does not allow the user to create a site section where the pretty URL matches another site section's pretty URL under the same parent
  Given the Research site section with path /research exists
    And the Test site section with path /research/test exists
    And the user is creating a new site section within Research
  When the user sets the name to "Test 1" pretty URL to "test" and tries to save
  Then the system will not allow the user to save the taxonomy term

Scenario: System does not allow the user to create a site section where the Name matches another site section's Name under the same parent 
( name field should be case insensitive, e.g. About cancer and About Cancer site section name should be treated the same, when purl and parent section are the same)
  Given the Research site section with path /research exists
    And the Test site section with path /research/test exists
    And the user is creating a new site section within Research site section
  When the user sets the name to "Test" and pretty URL to "test-1" and tries to save
  Then the system will not allow the user to save the taxonomy term

  Given the Research site section with path /research exists
    And the Test site section with path /research/test exists
    And the user is creating a new site section within Research site section
  When the user sets the name to "Test" and pretty URL to "test-1" and tries to save
  Then the system will not allow the user to save the taxonomy term

Scenario: System does not allow the user to create a site section where the site section pretty URL matches another node item's site section path + pretty URL
  Given the Research site section with path /research exists 
    And a node item within Research site section with pretty URL set to "areas" exists
    And the user is creating a new site section within Research site section
  When the user sets the site section pretty URL to "areas" and tries to save
  Then the system will not allow the user to save the site section

Scenario: System allows the user to create a site section where the site section pretty URL matches another site section's pretty URL with a different parent
  Given the Research site section with path /research exists 
    And the Funding site section with path /grants-training/training/funding exists
    And the user is creating a new site section within Research site section
  When the user sets the name to "Funding" and pretty URL to "funding" and tries to save
  Then the system will allow the user to save the site section

Taxonomy Term Names:

Blog Topics:

Scenario: System does not allow the user to create a blog topic where the name matches another blog topic's name under the same blog series
  Given a blog topic with name "Careers & Training" under CGH News & Announcements blog series exists
    And the user is creating a new blog topic within CGH News & Announcements blog series
  When the user sets the name to "Careers & Training" and tries to save
  Then the system will not allow the user to save the blog topic

Scenario: System allows the user to create a blog topic where the name does not match another blog topic's name under the same blog series
  Given a blog topic with name "Careers & Training" under CGH News & Announcements blog series exists
    And the user is creating a new blog topic within CGH News & Announcements blog series
  When the user sets the name to "Careers & Training 2" and tries to save
  Then the system will allow the user to save the blog topic

Scenario: System does not allow the user to create a blog topic where the pretty URL matches another blog topic's pretty URL under the same blog series
  Given a blog topic with name "Careers & Training" and pretty URL "careers-training" under CGH News & Announcements blog series exists
    And the user is creating a new blog topic within CGH News & Announcements blog series
  When the user sets the name to "Careers & Training 2" and pretty URL to "careers-training" and tries to save
  Then the system will not allow the user to save the blog topic

Scenario: System does not allow the user to create a blog topic where the name matches another blog topic's name even with different pretty URL under the same blog series
  Given a blog topic with name "Careers & Training" and pretty URL "careers-training" under CGH News & Announcements blog series exists
    And the user is creating a new blog topic within CGH News & Announcements blog series
  When the user sets the name to "Careers & Training 2" and pretty URL to "careers-training" and tries to save
  Then the system will not allow the user to save the blog topic

Media:

Scenario: System does not allow the user to create an infographic media item where the site section path + pretty URL is the same as another media item's
  Given the Research site section with path /research exists
    And an infographic media item under Research site section with pretty URL set to "research-infographic" exists
    And the user is creating a new infographic media item under Research site section
  When the user sets the pretty URL to "research-infographic" and tries to save
  Then the system will not allow the user to save the content item

Scenario: System does not allow the user to create a video media item where the site section path + pretty URL is the same as another media item's
  Given the Research site section with path /research exists
    And a video media item under Research site section with pretty URL set to "research-video" exists
    And the user is creating a new video media item at /research
  When the user sets the pretty URL to "research-video"
  Then the system will not allow the user to save the content item