<commit_before>Feature: I want to be able to edit static pages
  As a site admin
  So that I can update my website
  I want to be able to edit static pages via markdown
  Tracker story ID: https://www.pivotaltracker.com/story/show/52536437

  Background: organizations have been added to database
    Given the following pages exist:
      | name         | permalink  | content |
      | About Us     | about      | abc123  |
    And the following users are registered:
      | email                         | password | admin | confirmed_at         |  organization |
      | <EMAIL> | pppppppp | true  | 2007-01-01  10:00:00 |  Friendly     |
      | <EMAIL> | pppppppp | false | 2007-01-01  10:00:00 |               |
    And cookies are approved
    And a static page named "Contact Info" with permalink "contact" and markdown content:
      """
      This is a *significant* word

      This is **important** text

      1.  Numbered list

      *  Bullet list

      ### This is an h3 header

      Here is a [link to relishapp](http://relishapp.com)
      and another link: www.relishapp.com

      This _message_ is important too.
      """

  Scenario: Admin can edit
    Given I am signed in as a admin
    And I am on the home page
    When I follow "About Us"
    Then I should see a link with text "Edit"
    And I follow "Edit"
    Then I should be on the edit page for "about"

  Scenario: Non-admin cannot edit
    Given I am signed in as a non-admin
    And I am on the home page
    When I follow "About Us"
    Then I should not see a link with text "Edit"

  Scenario: Admin can see pages index
    Given I am signed in as a admin
    And I am on the home page
    When I follow "About Us"
    And I follow "Pages"
    Then the URL should contain "pages"

  Scenario: Non-admin cannot see pages index
    Given I am signed in as a non-admin
    And I visit "/pages"
    Then I should see "unauthorized access"
    And I should be on the home page

  Scenario: Static pages are editable
    Given I am signed in as a admin
    And I am on the edit page with the "about" permalink
    And I fill in "page_name" with "new name"
    And I fill in "page_permalink" with "new_link"
    And I fill in "page_content" with "xyz789"
    And I press "Update Page"
    And the URL should contain "new_link"
    And I should see "xyz789"
<commit_msg>pulled authorize logic out to application controller<commit_after>Feature: I want to be able to edit static pages
  As a site admin
  So that I can update my website
  I want to be able to edit static pages via markdown
  Tracker story ID: https://www.pivotaltracker.com/story/show/52536437

  Background: organizations have been added to database
    Given the following pages exist:
      | name         | permalink  | content |
      | About Us     | about      | abc123  |
    And the following users are registered:
      | email                         | password | <PASSWORD> | confirmed_at         |  organization |
      | <EMAIL> | pppppppp | true  | 2007-01-01  10:00:00 |  Friendly     |
      | <EMAIL> | pppppppp | false | 2007-01-01  10:00:00 |               |
    And cookies are approved
    And a static page named "Contact Info" with permalink "contact" and markdown content:
      """
      This is a *significant* word

      This is **important** text

      1.  Numbered list

      *  Bullet list

      ### This is an h3 header

      Here is a [link to relishapp](http://relishapp.com)
      and another link: www.relishapp.com

      This _message_ is important too.
      """

  Scenario: Admin can edit
    Given I am signed in as a admin
    And I am on the home page
    When I follow "About Us"
    Then I should see a link with text "Edit"
    And I follow "Edit"
    Then I should be on the edit page for "about"

  Scenario: Non-admin cannot edit
    Given I am signed in as a non-admin
    And I am on the home page
    When I follow "About Us"
    Then I should not see a link with text "Edit"

  Scenario: Admin can see pages index
    Given I am signed in as a admin
    And I am on the home page
    When I follow "About Us"
    And I follow "Pages"
    Then the URL should contain "pages"

  Scenario: Non-admin cannot see pages index
    Given I am signed in as a non-admin
    And I visit "/pages"
    Then I should see "You must be signed in as an admin to perform this action!"
    And I should be on the home page

  Scenario: Static pages are editable
    Given I am signed in as a admin
    And I am on the edit page with the "about" permalink
    And I fill in "page_name" with "new name"
    And I fill in "page_permalink" with "new_link"
    And I fill in "page_content" with "xyz789"
    And I press "Update Page"
    And the URL should contain "new_link"
    And I should see "xyz789"

{'fraction_non_alphanumeric': 0.05903212348769295, 'fraction_numerical': 0.0196078431372549, 'mean_word_length': 2.3183391003460208, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '405818', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1391, 'n_words': 698}