<commit_before>require 'test_helper'
class SoftwareRenderTest < ActionDispatch::IntegrationTest


  ## Tests for show.
  test "should display software page that exists without being logged in" do 
    software = software(:one)

    get software_path(software.id)
    assert_template "software/show"
    assert_select ".name", software.name
    assert_select ".summary", software.summary
    assert_select ".description", software.description

    assert_select "a[href=?]", edit_software_path(software.id), count: 0
    assert_select "a[href=?][data-method=delete]", software_path(software.id), 
      count: 0
  end

  test "should display edit option on a software page when logged in" do
    log_in_as users(:foo)
    software = software(:one)

    get software_path(software.id)
    assert_template "software/show"
    assert_select ".name", software.name
    assert_select ".summary", software.summary
    assert_select ".description", software.description

    assert_select "a[href=?]", edit_software_path(software.id), count: 1
    assert_select "a[href=?][data-method=delete]", software_path(software.id), 
      count: 1
  end

  test "should display a 404 page if id isn't valid" do 
    response = get software_path(-1)<commit_msg>Fixed integration test for the software page. All tests passing.<commit_after>require 'test_helper'
require 'erb'
class SoftwareRenderTest < ActionDispatch::IntegrationTest


  ## Tests for show.
  test "should display software page that exists without being logged in" do 
    software = software(:one)

    get software_path(software.id)
    assert_template "software/show"
    assert_select ".name", software.name
    assert_select ".summary", software.summary
    assert_select "iframe.description[data-html=?]", 
      ERB::Util.url_encode(software.description)

    assert_select "a[href=?]", edit_software_path(software.id), count: 0
    assert_select "a[href=?][data-method=delete]", software_path(software.id), 
      count: 0
  end

  test "should display edit option on a software page when logged in" do
    log_in_as users(:foo)
    software = software(:one)

    get software_path(software.id)
    assert_template "software/show"
    assert_select ".name", software.name
    assert_select ".summary", software.summary
    assert_select "iframe.description[data-html=?]", 
      ERB::Util.url_encode(software.description)

    assert_select "a[href=?]", edit_software_path(software.id), count: 1
    assert_select "a[href=?][data-method=delete]", software_path(software.id), 
      count: 1
  end

  test "should display a 404 page if id isn't valid" do 
    response = get software_path(-1)
{'fraction_non_alphanumeric': 0.10804684548545523, 'fraction_numerical': 0.006044578768417076, 'mean_word_length': 4.233201581027668, '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': '7545246', 'n_tokens_mistral': 815, 'n_tokens_neox': 747, 'n_words': 212}