Skip to content

Commit

Permalink
Merge pull request #3202 from alphagov/add-content-id-to-drug-alerts-…
Browse files Browse the repository at this point in the history
…feed

Add document content_id to atom feeds
  • Loading branch information
KludgeKML authored Nov 3, 2023
2 parents 53ed08e + 932a237 commit 4919a05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/presenters/entry_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class EntryPresenter
delegate :title,
:path,
:content_id,
to: :entry

WEBSITE_ROOT = Plek.new.website_root.gsub(/https?:\/\//, "")
Expand Down
1 change: 1 addition & 0 deletions app/views/finders/show.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ atom_feed do |feed|
feed.entry(result, id: result.tag(feed), url: absolute_url_for(result.path), updated: result.updated_at) do |entry|
entry.title(result.title)
entry.summary(result.summary, type: "html")
entry.content_id(result.content_id)
end
end
end
12 changes: 12 additions & 0 deletions spec/presenters/entry_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@
expect(EntryPresenter.feed_ended_id(atom_feed_builder, "/path/to/content")).to eq("tag:www.test.gov.uk,2019:/path/to/content/feed-ended")
end
end

# Note - this is a simple delegation and we wouldn't normally test, but
# it's important for email-alert-api's monitoring of medical alerts, so
# worth checking that it hasn't been accidentally removed.
describe "#content_id" do
let(:document) do
FactoryBot.build(:document, content_id: "AAAA-BBBB")
end
it "displays the content_id" do
expect(EntryPresenter.new(document, true).content_id).to eq("AAAA-BBBB")
end
end
end

0 comments on commit 4919a05

Please sign in to comment.