<commit_before>require 'test_helper'

class BuildingsControllerTest < ActionController::TestCase
  setup do
    @avw = buildings(:avw)
    @user_admin = users(:user_admin)
  end

  test "not logged in" do
    get :index
    assert_redirected_to root_path
    patch :update, id:@avw, abbrv:"foo"
    assert_redirected_to root_path
    assert_equal "AVW", buildings(:avw).abbrv
    delete :destroy, id:@avw
    assert_redirected_to root_path
    assert_equal @avw, buildings(:avw)
  end

  test "logged in admin" do
    sign_in @user_admin
    get :index
    assert_response :success
    assert_not_nil assigns(:buildings)
    assert_difference('Building.count', -1) do
      delete :destroy, id:@avw
    end
#    assert_response :success
    #    post :update, id:@avw, abbrv:"WVA"
    #    assert_response :success
    #    assert_equal "WVA", buildings(:avw).abbrv
  end
end<commit_msg>buildings controller tests<commit_after>require 'test_helper'

class BuildingsControllerTest < ActionController::TestCase
  setup do
    @avw = buildings(:avw)
    @csic = buildings(:csic)
    @user_admin = users(:user_admin)
  end

  test "not logged in" do
    get :index
    assert_redirected_to root_path
    patch :update, id:@avw, abbrv:"foo"
    assert_redirected_to root_path
    assert_equal "AVW", buildings(:avw).abbrv
    delete :destroy, id:@avw
    assert_redirected_to root_path
    assert_equal @avw, buildings(:avw)
  end

  test "logged in admin" do
    sign_in @user_admin
    get :index
    assert_response :success
    assert_not_nil assigns(:buildings)
    assert_difference('Building.count', -1) do
      delete :destroy, id:@avw
    end
    assert_redirected_to buildings_index_path
    csic_abbrv_sym = "building_abbrv_#{@csic.id}".to_sym
    csic_name_sym = "building_name_#{@csic.id}".to_sym
    csic_url_sym = "building_url_#{@csic.id}".to_sym
    post :update, csic_abbrv_sym=>"WVA", csic_name_sym=>"W.V.A. Building", csic_url_sym=>"WVA URL"
    assert_redirected_to buildings_index_path
    tmp = Building.find_by_abbrv "WVA"
    assert_equal "W.V.A. Building", tmp.name
    assert_equal "WVA URL", tmp.url
    post :update, building_abbrv_new:"FOO", building_name_new:"The Foo Building", building_url_new:"Foo URL"
    assert_redirected_to buildings_index_path
    tmp = Building.find_by_abbrv "FOO"
    assert_equal "The Foo Building", tmp.name
    assert_equal "Foo URL", tmp.url
  end
end
{'fraction_non_alphanumeric': 0.099626400996264, 'fraction_numerical': 0.0008302200083022001, 'mean_word_length': 4.01039501039501, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '125232', 'n_tokens_mistral': 862, 'n_tokens_neox': 850, 'n_words': 186}