<commit_before># encoding: utf-8
require 'test_helper'

class ObjectManagerAttributesControllerTest < ActionDispatch::IntegrationTest
  setup do

    # set accept header
    @headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }

    # create agent
    roles  = Role.where(name: 'Admin')
    groups = Group.all

    UserInfo.current_user_id = 1
    @admin = User.create_or_update(
      login: 'tickets-admin',
      firstname: 'Tickets',
      lastname: 'Admin',
      email: '<EMAIL>',
      password: '<PASSWORD>',
      active: true,
      roles: roles,
      groups: groups,
    )
  end
  test 'converts string to boolean for default option' do
    credentials = ActionController::HttpAuthentication::Basic.encode_credentials('<EMAIL>', '<PASSWORD>')

    post '/api/v1/object_manager_attributes', params: { 'name' => 'customdescription2', 'object' => 'Ticket', 'display' => 'custom description 2', 'active' => true, 'data_type' => 'boolean', 'data_option' => { 'options' => { 'true' => '', 'false' => '' }, 'default' => 'true' }, 'screens' => { 'create_middle' => { 'ticket.customer' => { 'shown' => true, 'item_class' => 'column' }, 'ticket.agent' => { 'shown' => true, 'item_class' => 'column' } }, 'edit' => { 'ticket.customer' => { 'shown' => true }, 'ticket.agent' => { 'shown' => true } } }, 'id' => 'c-192' }.to_json, headers: @headers.merge('Authorization' => credentials)
    assert_response :success
    result = JSON.parse @response.body
    obj = ObjectManager::Attribute.find result['id']
    assert_equal true, obj.data_option['default']
    assert_equal 'boolean', obj.data_type
    obj.destroy
  end
end<commit_msg>stick to test naming convention and better variable name<commit_after># encoding: utf-8
require 'test_helper'

class ObjectManagerAttributesControllerTest < ActionDispatch::IntegrationTest
  setup do

    # set accept header
    @headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }

    # create agent
    roles  = Role.where(name: 'Admin')
    groups = Group.all

    UserInfo.current_user_id = 1
    @admin = User.create_or_update(
      login: 'tickets-admin',
      firstname: 'Tickets',
      lastname: 'Admin',
      email: '<EMAIL>',
      password: '<PASSWORD>',
      active: true,
      roles: roles,
      groups: groups,
    )
  end
  test '01 converts string to boolean for default value for boolean data type' do
    credentials = ActionController::HttpAuthentication::Basic.encode_credentials('<EMAIL>', '<PASSWORD>')

    post '/api/v1/object_manager_attributes', params: { 'name' => 'customdescription2', 'object' => 'Ticket', 'display' => 'custom description 2', 'active' => true, 'data_type' => 'boolean', 'data_option' => { 'options' => { 'true' => '', 'false' => '' }, 'default' => 'true' }, 'screens' => { 'create_middle' => { 'ticket.customer' => { 'shown' => true, 'item_class' => 'column' }, 'ticket.agent' => { 'shown' => true, 'item_class' => 'column' } }, 'edit' => { 'ticket.customer' => { 'shown' => true }, 'ticket.agent' => { 'shown' => true } } }, 'id' => 'c-192' }.to_json, headers: @headers.merge('Authorization' => credentials)
    assert_response :success
    result = JSON.parse @response.body
    object = ObjectManager::Attribute.find result['id']
    assert_equal true, object.data_option['default']
    assert_equal 'boolean', object.data_type
    object.destroy
  end
end
{'fraction_non_alphanumeric': 0.17296980357666372, 'fraction_numerical': 0.005277044854881266, 'mean_word_length': 4.017647058823529, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 65, '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': '4554031', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1050, 'n_words': 254}