Skip to content

Commit

Permalink
Make csv_rows method private and remove tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leenagupte committed Oct 18, 2024
1 parent 01a811c commit d54110f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
8 changes: 4 additions & 4 deletions app/models/block/statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions spec/models/block/statistics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d54110f

Please sign in to comment.