<commit_before>require 'test_helper'

class GroupOffersXlsxExportTest < ActionDispatch::IntegrationTest
  def setup
    @superadmin = create :user
    @group_offers = Array.new(10).map { create :group_offer }
    login_as @superadmin
    get group_offers_url(format: :xlsx)
  end

  test 'xlsx file is downloadable' do
    assert_equal 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
      response.content_type
  end

  test 'xlsx files has the right columns' do
    excel_file = Tempfile.new
    excel_file.write(response.body)
    excel_file.close
    wb = Roo::Spreadsheet.open(excel_file.path, extension: 'xlsx')

    assert_equal wb.cell(1, 1), 'Title'
    assert_equal wb.cell(2, 1), @group_offers.last.title
    assert_equal wb.cell(1, 2), 'Location'
    assert_equal wb.cell(1, 3), 'Availability'
    assert_equal wb.cell(1, 4), 'Target group'
    assert_equal wb.cell(1, 5), 'Duration'
    assert_equal wb.cell(1, 6), 'Offer state'
    assert_equal wb.cell(1, 7), 'Volunteers'
    assert_equal wb.cell(1, 8), 'Group offer category'
  end
end<commit_msg>trying to fix group offer xlsx export test<commit_after>require 'test_helper'

class GroupOffersXlsxExportTest < ActionDispatch::IntegrationTest
  def setup
    @superadmin = create :user
  end

  test 'xlsx file is downloadable' do
    @group_offers = Array.new(10).map { create :group_offer }
    login_as @superadmin
    get group_offers_url(format: :xlsx)
    assert_equal 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
      response.content_type
  end

  test 'xlsx files has the right columns' do
    create :group_offer
    login_as @superadmin
    get group_offers_url(format: :xlsx)
    excel_file = Tempfile.new
    excel_file.write(response.body)
    excel_file.close
    wb = Roo::Spreadsheet.open(excel_file.path, extension: 'xlsx')

    assert_equal wb.cell(1, 1), 'Title'
    assert_equal wb.cell(2, 1), @group_offers.first.title
    assert_equal wb.cell(1, 2), 'Location'
    assert_equal wb.cell(1, 3), 'Availability'
    assert_equal wb.cell(1, 4), 'Target group'
    assert_equal wb.cell(1, 5), 'Duration'
    assert_equal wb.cell(1, 6), 'Offer state'
    assert_equal wb.cell(1, 7), 'Volunteers'
    assert_equal wb.cell(1, 8), 'Group offer category'
  end
end
{'fraction_non_alphanumeric': 0.10756449497157848, 'fraction_numerical': 0.0174901617839965, 'mean_word_length': 4.050772626931567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '365466', 'n_tokens_mistral': 854, 'n_tokens_neox': 816, 'n_words': 189}