Skip to content

Commit

Permalink
Convert Government navigation component
Browse files Browse the repository at this point in the history
  • Loading branch information
tijmenb committed May 29, 2018
1 parent 6606f9e commit ee71c70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Move the Title component from static (PR #324)
* Move the Lead paragraph component from static (PR #325)
* Add a Phase banner component to replace the Alpha/Beta banners in Static (PR #333)
* Move the Government navigation component from static (PR #334)

### Upgrade instructions

Expand All @@ -23,6 +24,7 @@ Replace the component by running the following:
```
find app/views -type f -print0 | xargs -0 sed -i '' 's/govuk_component\/title/govuk_publishing_components\/components\/title/g'
find app/views -type f -print0 | xargs -0 sed -i '' 's/govuk_component\/lead_paragraph/govuk_publishing_components\/components\/lead_paragraph/g'
find app/views -type f -print0 | xargs -0 sed -i '' 's/govuk_component\/government_navigation/govuk_publishing_components\/components\/government_navigation/g'
```

Your tests are likely to need updating as well.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
require 'govuk_component_test_helper'
require 'rails_helper'

class GovernmentNavigationTestCase < ComponentTestCase
describe "Government navigation", type: :view do
def component_name
"government_navigation"
end

test "renders a list of government links" do
it "renders a list of government links" do
render_component({})

assert_select "\#proposition-links li a", text: "Departments"
assert_link_with_text("/government/organisations", "Departments")
assert_link_with_text("/government/announcements", "Announcements")
# etc.
end

test "no links are active by default" do
it "has no active links by default" do
render_component({})

assert_select "a.active", false
end

test "can mark a link as active" do
it "can mark a link as active" do
render_component(active: 'departments')

assert_select "a.active", text: "Departments"
end

def assert_link_with_text(link, text)
assert_select "a[href=\"#{link}\"]", text: text
end
end

0 comments on commit ee71c70

Please sign in to comment.