Fixes for home nav link positioning (#16381)
* Add new DUS to fix home nav link positioning * fix bug in local db seeding
This commit is contained in:
parent
5904543295
commit
0dd77bcf52
3 changed files with 33 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
module DataUpdateScripts
|
||||
class UpdateHomeNavigationLinkPosition
|
||||
def run
|
||||
NavigationLink.create_or_update_by_identity(
|
||||
name: "Home",
|
||||
url: URL.url("/"),
|
||||
icon: File.read(Rails.root.join("app/assets/images/twemoji/house.svg")),
|
||||
display_only_when_signed_in: false,
|
||||
position: 1,
|
||||
section: :default,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -128,6 +128,7 @@ namespace :navigation_links do
|
|||
base_url = "#{protocol}#{domain}".freeze
|
||||
|
||||
NavigationLink.create_or_update_by_identity(
|
||||
url: "/",
|
||||
name: "Home",
|
||||
icon: home_icon,
|
||||
display_only_when_signed_in: false,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
require "rails_helper"
|
||||
require Rails.root.join(
|
||||
"lib/data_update_scripts/20220201114309_update_home_navigation_link_position.rb",
|
||||
)
|
||||
|
||||
describe DataUpdateScripts::UpdateHomeNavigationLinkPosition do
|
||||
it "creates a home navigation link when it doesn't already exist" do
|
||||
expect do
|
||||
described_class.new.run
|
||||
end.to change { NavigationLink.exists?(url: "/", name: "Home", position: 1) }.from(false).to(true)
|
||||
end
|
||||
|
||||
it "updates any existing home navigation link to have position 1" do
|
||||
link = create(:navigation_link, url: "/", name: "Home", position: 4)
|
||||
described_class.new.run
|
||||
expect(link.reload.position).to eq(1)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue