Skip to content

Commit

Permalink
Merge 880d2f9 into c6e0c5f
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaCheca committed Apr 30, 2018
2 parents c6e0c5f + 880d2f9 commit dc60dfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/events_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class EventsExporter

PRIVATE_FIELDS = ['status', 'notes', 'canceled_reasons', 'published_at', 'canceled_at', 'lobby_activity',
'lobby_scheduled', 'general_remarks', 'lobby_contact_firstname',
'accepted_at', 'declined_reasons', 'declined_at',
'accepted_at', 'declined_reasons', 'declined_at', 'user_name',
'lobby_contact_lastname', 'lobby_contact_email', 'lobby_contact_phone', 'manager_general_remarks'].freeze

FIELDS = ['title', 'description', 'scheduled', 'updated_at', 'user_name', 'holder_name', 'position_names', 'location', 'status',
FIELDS = ['title', 'description', 'scheduled', 'updated_at', 'holder_name', 'position_names', 'location', 'status',
'notes', 'canceled_reasons', 'published_at', 'canceled_at', 'lobby_activity',
'organization_name', 'lobby_scheduled', 'general_remarks', 'lobby_contact_firstname',
'accepted_at', 'declined_reasons', 'declined_at',
Expand Down Expand Up @@ -42,7 +42,7 @@ def windows_event_row(event)
end

def save_csv(path)
CSV.open(path, 'w', col_sep: ';', force_quotes: true, encoding: "ISO-8859-1") do |csv|
CSV.open(path, 'w', col_sep: ';', force_quotes: true, encoding: "UTF-8") do |csv|
csv << windows_headers
Event.find_each do |event|
csv << windows_event_row(event)
Expand All @@ -51,7 +51,7 @@ def save_csv(path)
end

def save_xls(path)
Spreadsheet.client_encoding = 'ISO-8859-1'
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet
sheet.row(0).default_format = Spreadsheet::Format.new color: :blue, weight: :bold
Expand Down Expand Up @@ -79,7 +79,7 @@ def save_json(path)
private

def windows_array(values)
values.map { |v| v.to_s.encode("ISO-8859-1", invalid: :replace, undef: :replace, replace: '') }
values.map { |v| v.to_s.encode("UTF-8", invalid: :replace, undef: :replace, replace: '') }
end

def process_field(event, field)
Expand Down
10 changes: 4 additions & 6 deletions spec/lib/events_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

describe "#headers" do

it "Should contain twenty-five colums headers" do
expect(exporter.headers.size).to eq(9)
it "Should contain eight colums headers" do
expect(exporter.headers.size).to eq(8)
end

it "Should return correct headers translations" do
Expand All @@ -32,7 +32,6 @@
expect(row).to include(event.description)
expect(row).to include(I18n.l(event.scheduled, format: :short))
expect(row).to include(I18n.l(event.updated_at, format: :short))
expect(row).to include(event.user_name)
expect(row).to include(event.position_names)
expect(row).to include(event.location)
expect(row).to include(event.organization_name)
Expand All @@ -46,8 +45,8 @@

describe "#headers" do

it "Should contain twenty-five colums headers" do
expect(exporter.headers.size).to eq(25)
it "Should contain twenty-four colums headers" do
expect(exporter.headers.size).to eq(24)
end

it "Should return correct headers translations" do
Expand All @@ -69,7 +68,6 @@
expect(row).to include(event.description)
expect(row).to include(I18n.l(event.scheduled, format: :short))
expect(row).to include(I18n.l(event.updated_at, format: :short))
expect(row).to include(event.user_name)
expect(row).to include(event.position_names)
expect(row).to include(event.location)
expect(row).to include("Aceptado")
Expand Down

0 comments on commit dc60dfb

Please sign in to comment.