Skip to content

Commit

Permalink
Level B export: tags
Browse files Browse the repository at this point in the history
Needs a new ActivityCsvPresenter method, because as previously seen
with `#sustainable_development_goals`, `ActivityPresenter#tags`
produces an HTML version.
  • Loading branch information
rgarner committed Jan 23, 2025
1 parent 909b27a commit 7f7d360
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/presenters/activity_csv_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ def sustainable_development_goals
end
end

def tags
return if self[:tags].blank?

tags_options.select { |tag| tag.code.in?(self[:tags]) }
.map(&:description)
.join("|")
end

private

def list_of_countries(country_code_list, klass)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/beis_users_can_download_exports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
other_fund_programme = create(:programme_activity, :newton_funded)
programme_1 = create(
:programme_activity, :ispf_funded, commitment: create(:commitment, value: BigDecimal("250_000.00")),
benefitting_countries: %w[AR EC BR]
benefitting_countries: %w[AR EC BR], tags: [4, 5]
)
programme_1.comments = create_list(:comment, 2)
programme_1.budgets = [
Expand Down Expand Up @@ -351,7 +351,7 @@
"Aid type" => "D01: Donor country personnel",
"ODA eligibility" => "Eligible",
"Publish to IATI?" => "Yes",
"Tags" => nil,
"Tags" => "Tactical Fund|Previously reported under OODA",
"Budget 2023-2024" => "£101.00", # each revision adds £50 in the factories; we have 2
"Budget 2024-2025" => "£2.00",
"Budget 2025-2026" => nil,
Expand Down
14 changes: 14 additions & 0 deletions spec/presenters/activity_csv_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,18 @@
it { is_expected.to be_nil }
end
end

describe "#tags" do
subject { described_class.new(activity).tags }

context "the activity has no tags" do
let(:activity) { build(:project_activity, tags: []) }
it { is_expected.to be_nil }
end

context "the activity has some tags from the codelist in tags.yml" do
let(:activity) { build(:project_activity, tags: [4, 5]) }
it { is_expected.to eql("Tactical Fund|Previously reported under OODA") }
end
end
end

0 comments on commit 7f7d360

Please sign in to comment.