Skip to content

Commit 979f98f

Browse files
committed
Add basic system test for topic navigation
1 parent 04cde7d commit 979f98f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spec/system/topics_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require "rails_helper"
2+
3+
RSpec.describe "Topics", type: :system do
4+
it "displays the topics and provides navigation links" do
5+
Page.upsert_from_sitepress!(limit: 3)
6+
7+
expect(Page.count).to eq(3)
8+
9+
Page.find_each do |model|
10+
model.topics = FactoryBot.create_list(:topic, 2, :approved)
11+
model.save!
12+
end
13+
14+
visit topics_path
15+
16+
expect(page).to have_content("Topics")
17+
18+
Topic.approved.find_each do |topic|
19+
expect(page).to have_link(topic.name, href: topic_path(topic))
20+
end
21+
22+
topic = Topic.first
23+
24+
click_link topic.name
25+
26+
expect(page).to have_content(topic.name)
27+
28+
topic.pages.each do |model|
29+
expect(page).to have_link(model.title, href: model.request_path)
30+
end
31+
end
32+
end

0 commit comments

Comments
 (0)