Skip to content

Commit

Permalink
Rubocop style fixes
Browse files Browse the repository at this point in the history
Co-authored-by: Bess Sadler <bess@users.noreply.github.com>
  • Loading branch information
leefaisonr and bess committed Mar 23, 2023
1 parent c254665 commit 3bc4733
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
require: rubocop-rails
require: rubocop-rails

Rails/FilePath:
Enabled: false
17 changes: 9 additions & 8 deletions app/services/guide_card_loading_service.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# frozen_string_literal: true
require 'csv'

require 'csv'
# service for loading GuideCard data
class GuideCardLoadingService
# location of source data for GuideCards
def csv_location
Rails.root.join('data', 'dbo-guides', 'dbo.Guides.31756.csv')
end

def import
guide_card_data=CSV.parse(File.read(csv_location), headers: true)
guide_card_data = CSV.parse(File.read(csv_location), headers: true)
guide_card_data.each do |card|
gc=GuideCard.new
gc.id=card[0]
gc.heading=card[1]
gc.sortid=card[2]
gc.path=card[3]
gc = GuideCard.new
gc.id = card[0]
gc.heading = card[1]
gc.sortid = card[2]
gc.path = card[3]
gc.save
end
end
end

15 changes: 8 additions & 7 deletions spec/services/guide_card_loading_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# frozen_string_literal: true
require "rails_helper"

require 'rails_helper'

describe GuideCardLoadingService do
let(:gcls) {described_class.new}
it "can instantiate" do
let(:gcls) { described_class.new }
it 'can instantiate' do
expect(gcls).to be_instance_of described_class
end

it "has a CSV file" do
it 'has a CSV file' do
expect(gcls.csv_location).to eq Rails.root.join('data', 'dbo-guides', 'dbo.Guides.31756.csv')
end

it "imports all data from the CSV file" do
it 'imports all data from the CSV file' do
expect(GuideCard.count).to eq 0
gcls.import
expect(GuideCard.count).to eq 31756
expect(GuideCard.count).to eq 31_756
end
end
end

0 comments on commit 3bc4733

Please sign in to comment.