-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from alphagov/travel-advice-atom
Add atom feeds to travel advice
- Loading branch information
Showing
12 changed files
with
192 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
atom_feed(root_url: @content_item.web_url, id: @content_item.web_url) do |feed| | ||
feed.title("Travel Advice Summary") | ||
feed.updated @content_item.atom_public_updated_at | ||
feed.author do |author| | ||
author.name "GOV.UK" | ||
end | ||
feed.entry(@content_item, id: "#{@content_item.web_url}##{@content_item.atom_public_updated_at}", url: @content_item.web_url, updated: @content_item.atom_public_updated_at) do |entry| | ||
entry.title(@content_item.title) | ||
entry.link(:rel => "self", :type => "application/atom+xml", :href => "#{@content_item.web_url}.atom") | ||
entry.summary(:type => :xhtml) do |summary| | ||
summary << @content_item.atom_change_description | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'test_helper' | ||
|
||
class TravelAdviceAtomFeed < ActionDispatch::IntegrationTest | ||
setup do | ||
setup_and_visit_travel_advice_atom_feed('full-country') | ||
@base_path = @content_item['base_path'] | ||
@updated_at = DateTime.parse(@content_item["public_updated_at"]).rfc3339 | ||
end | ||
|
||
test "it sets the alternative link correctly" do | ||
assert page.has_css?("//feed/link[rel='alternate'][href$='#{@base_path}']") | ||
end | ||
|
||
test "it sets the entry's id to the url concatenated with updated_at" do | ||
id = page.find("//feed/entry/id").text | ||
assert id.end_with?("#{@base_path}##{@updated_at}") | ||
end | ||
|
||
test "it sets the entry's title correctly" do | ||
title = page.find("//feed/entry/title").text | ||
assert_equal title, @content_item['title'] | ||
end | ||
|
||
test "it sets the entry's summary correctly" do | ||
summary = page.find("//feed/entry/summary").text | ||
assert_equal summary, @content_item['details']['change_description'].strip | ||
end | ||
|
||
test "it sets the entry's updated correctly" do | ||
updated = page.find("//feed/entry/updated").text | ||
assert_equal updated, @updated_at | ||
end | ||
|
||
def setup_and_visit_travel_advice_atom_feed(name) | ||
example = get_content_example_by_format_and_name('travel_advice', name) | ||
@content_item = JSON.parse(example).tap do |item| | ||
content_store_has_item(item["base_path"], item.to_json) | ||
visit "#{item['base_path']}.atom" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters