<commit_before>require 'test_helper'

class Admin::CourseControllerTest < ActionDispatch::IntegrationTest
  def setup
    sign_as_admin
    get importar_admin_campus_index_url
  end

  test 'should import courses from suap' do
    post importar_admin_courses_url, params: {id_campus: 39, ano_letivo: 2017, periodo_letivo: 1}
    assert_not_nil Course.find_by(campus: 39)

    assert_redirected_to admin_courses_url
  end

  test 'should not duplicate courses in import stage' do
    post importar_admin_courses_url(id_campus: 39, ano_letivo: 2017, periodo_letivo: 1)

    count = Course.count
    post importar_admin_courses_url(id_campus: 39, ano_letivo: 2017, periodo_letivo: 1)

    assert_equal count, Course.count
  end

  test "should filter courses by campus" do
    get admin_campus_courses_path(39)
    assert_not_equal Course.all, assigns(:courses)
  end

end<commit_msg>Adicionado testes ao controller dos cursos<commit_after>require 'test_helper'

class Admin::CourseControllerTest < ActionDispatch::IntegrationTest
  def setup
    sign_as_admin
    get importar_admin_campus_index_url
  end

  test 'should import courses from suap' do
    post importar_admin_courses_url, params: {id_campus: 39, ano_letivo: 2017, periodo_letivo: 1}
    assert_not_nil Course.find_by(campus: 39)

    assert_redirected_to admin_courses_url
  end

  test 'should not duplicate courses in import stage' do
    post importar_admin_courses_url(id_campus: 39, ano_letivo: 2017, periodo_letivo: 1)

    count = Course.count
    post importar_admin_courses_url(id_campus: 39, ano_letivo: 2017, periodo_letivo: 1)

    assert_equal count, Course.count
  end

  test "should not import courses without params" do
    post importar_admin_courses_url
    assert_response :redirect
    follow_redirect!
    assert_match /Erro ao importar dados/, @response.body
  end

  test "should filter courses by campus" do
    get admin_campus_courses_path(39)
    assert_not_equal Course.where(campus_id: 39), assigns(:courses)
  end

  test "should show all courses" do
    get admin_courses_url
    assert Course.all, assigns: @courses
  end

end
{'fraction_non_alphanumeric': 0.05934997644842204, 'fraction_numerical': 0.024493641073951956, 'mean_word_length': 4.648936170212766, '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': '4434175', 'n_tokens_mistral': 759, 'n_tokens_neox': 700, 'n_words': 190}