From bc56d86a63c0b71267e5eb1e1e28b95ef40dcb15 Mon Sep 17 00:00:00 2001 From: Jan Suchal Date: Tue, 9 Jan 2018 16:03:17 +0100 Subject: [PATCH] Support ruby 2.5.0 --- .travis.yml | 2 -- app/jobs/regular/bulk_invite.rb | 5 ++++- spec/jobs/bulk_invite_spec.rb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 73ae46e5b09..a62d28ebc6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,6 @@ addons: matrix: fast_finish: true - allow_failures: - - rvm: 2.5.0 rvm: - 2.5.0 diff --git a/app/jobs/regular/bulk_invite.rb b/app/jobs/regular/bulk_invite.rb index dbb195a5cdf..5aa29987be4 100644 --- a/app/jobs/regular/bulk_invite.rb +++ b/app/jobs/regular/bulk_invite.rb @@ -29,7 +29,8 @@ module Jobs end def read_csv_file(csv_path) - CSV.foreach(csv_path, encoding: "bom|utf-8") do |csv_info| + file = File.open(csv_path, encoding: 'bom|utf-8') + CSV.new(file).each do |csv_info| if csv_info[0] if (EmailValidator.email_regex =~ csv_info[0]) # email is valid @@ -45,6 +46,8 @@ module Jobs rescue Exception => e log "Bulk Invite Process Failed -- '#{e.message}'" @failed += 1 + ensure + file.close end def get_group_ids(group_names, csv_line_number) diff --git a/spec/jobs/bulk_invite_spec.rb b/spec/jobs/bulk_invite_spec.rb index 3cc66f26eac..573f27639c9 100644 --- a/spec/jobs/bulk_invite_spec.rb +++ b/spec/jobs/bulk_invite_spec.rb @@ -12,7 +12,7 @@ describe Jobs::BulkInvite do context '.read_csv_file' do let(:user) { Fabricate(:user) } let(:bulk_invite) { Jobs::BulkInvite.new } - let(:csv_file) { File.new("#{Rails.root}/spec/fixtures/csv/discourse.csv") } + let(:csv_file) { "#{Rails.root}/spec/fixtures/csv/discourse.csv" } it 'reads csv file' do bulk_invite.current_user = user