From d54110f4cc2d5e477c1071829c0a75fdbd0318e2 Mon Sep 17 00:00:00 2001 From: Leena Gupte Date: Fri, 18 Oct 2024 14:18:35 +0100 Subject: [PATCH] Make csv_rows method private and remove tests --- app/models/block/statistics.rb | 8 ++++---- spec/models/block/statistics_spec.rb | 15 --------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/models/block/statistics.rb b/app/models/block/statistics.rb index 88924130c4..e757571052 100644 --- a/app/models/block/statistics.rb +++ b/app/models/block/statistics.rb @@ -51,16 +51,16 @@ def rows rows end - def csv_rows - CSV.read(csv_file_path, headers: true).map(&:to_h) - end - def data_source_link data["data_source_link"] end private + def csv_rows + CSV.read(csv_file_path, headers: true).map(&:to_h) + end + def csv_file_path @csv_file_path ||= Rails.root.join("#{STATISTICS_DATA_PATH}/#{data['csv_file']}") end diff --git a/spec/models/block/statistics_spec.rb b/spec/models/block/statistics_spec.rb index d48e59f52a..20017fd86b 100644 --- a/spec/models/block/statistics_spec.rb +++ b/spec/models/block/statistics_spec.rb @@ -42,21 +42,6 @@ end describe "chart data" do - describe "#csv_rows" do - it "returns the row data for the chart" do - expected_rows = [ - { "Date" => "2024-01-01", "value" => "10", "variable" => "variable_name" }, - { "Date" => "2024-02-01", "value" => "11", "variable" => "variable_name" }, - { "Date" => "2024-03-01", "value" => "12", "variable" => "variable_name" }, - { "Date" => "2024-04-01", "value" => "13", "variable" => "variable_name" }, - { "Date" => "2024-05-01", "value" => "14", "variable" => "variable_name" }, - { "Date" => "2024-06-01", "value" => "15", "variable" => "variable_name" }, - ] - - expect(described_class.new(blocks_hash).csv_rows).to eq(expected_rows) - end - end - describe "#data_source_link" do it "returns the link to the external data source" do expect(described_class.new(blocks_hash).data_source_link).to eq("https://www.example.com")