docbrown/spec/tasks/add_navigation_links_spec.rb
Suzanne Aitchison f1df37f431
Add "only display when logged out" as an option on Navigation Links (#18275)
* add new column with enum value

* refactor to use display_to column

* add some more specs to application_helper

* test for the backfill DUS

* fix line length

* refactor
2022-08-08 10:55:24 +01:00

29 lines
858 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_to: :logged_in,
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