docbrown/spec/tasks/add_navigation_links_spec.rb
Suzanne Aitchison f1864847e7
Make home link an admin-customisable navigation link (#16268)
* move home link to a customisable navlink

* add trailing slash for path

* update specs

* replace positions, set home link to -1

* add update script for adding home navigation link

* update data update script
2022-02-01 09:27:09 +00:00

29 lines
869 B
Ruby

require "rails_helper"
RSpec.describe "Navigation Links tasks", type: :task do
before do
Rake::Task.clear
PracticalDeveloper::Application.load_tasks
end
describe "#create" do
it "creates navigation links for new forem if nonexistent" do
expect { Rake::Task["navigation_links:create"].invoke }.to change(NavigationLink, :count).by(6)
end
context "when navigation links exist" do
before do
NavigationLink.destroy_all
create(:navigation_link,
name: "Reading List",
url: URL.url("readinglist"),
display_only_when_signed_in: true,
position: 0)
end
it "does not create nav links if they already exist" do
expect { Rake::Task["navigation_links:create"].invoke }.to change(NavigationLink, :count).from(1).to(6)
end
end
end
end