<commit_before>require 'test_helper'

class BrowseStoriesSignedOutTest < ActionDispatch::IntegrationTest
  fixtures :all

  # setup do 
  #   sign_out
  # end

  # test "Member sees published post on index" do
  #   get "/news"
  #   assert response.body =~ /MyPublishedPost/ 
  # end

  # test "Member doesn't see non-published post on index" do
  #   get "/news"
  #   assert response.body !~ /MyHiddenPost/ 
  # end


  # test "Member can access the published posts" do
  #   get "/news/1"
  #   assert_response :success
  # end

  # test "Member can't access the non-published posts" do
  #   assert_raise ActiveRecord::RecordNotFound do
  #     get "/news/2"
  #   end
  # end
  
end<commit_msg>Expanding story integration tests to cover logged out users.<commit_after>require 'test_helper'

class BrowseStoriesSignedOutTest < ActionDispatch::IntegrationTest
  fixtures :all

  setup do 
    sign_out
  end


  # Other user's published story

  test "Guest sees other user's published story on index" do
    get "/stories"
    assert_response 200
    assert response.body =~ /MembersStory/ 
  end

  test "Guest sees other user's published story on other user's homepage" do
    story = stories(:members_story)
    user = story.user
    get "/users/#{user.id}"
    assert_response 200
    assert response.body =~ /MembersStory/ 
  end

  test "Guest sees user's published story" do
    story = stories(:members_story)
    get "/stories/#{story.id}"
    assert_response 200
    assert response.body =~ /MembersStory/ 
  end

  test "Guest can't edit user's published story" do
    story = stories(:members_story)
    get "/stories/#{story.id}/edit"
    assert_response 302
  end


  # User's locked story

  test "Guest doesn't see user's locked story on index" do
    story = stories(:locked)
    get "/stories"
    assert_response 200
    assert response.body !~ /BannedsLockedStory/ 
  end

  test "Guest doesn't see user's locked story on user's homepage" do
    story = stories(:locked)
    user = story.user
    get "/users/#{user.id}"
    assert_response 200
    assert response.body !~ /BannedsLockedStory/ 
  end

  test "Guest doesn't see user's locked story" do
    story = stories(:locked)
    get "/stories/#{story.id}"
    assert_response 403
    assert response.body !~ /BannedsLockedStory/ 
  end


  # User's deleted story

  test "Guest doesn't see user's deleted story on index" do
    get "/stories"
    assert_response 200
    assert response.body !~ /BannedsDeletedStory/ 
  end

  test "Guest doesn't see user's deleted story on user's homepage" do
    story = stories(:deleted)
    user = story.user
    get "/users/#{user.id}"
    assert_response 200
    assert response.body !~ /BannedsDeletedStory/ 
  end

  test "Guest doesn't see user's deleted story but can see the title." do
    story = stories(:deleted)
    get "/stories/#{story.id}"
    assert_response 403
    assert response.body =~ /BannedsDeletedStory/ 
  end

  
end
{'fraction_non_alphanumeric': 0.09253630530226276, 'fraction_numerical': 0.010807159743329957, 'mean_word_length': 3.002702702702703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '6714271', 'n_tokens_mistral': 999, 'n_tokens_neox': 890, 'n_words': 297}