Skip to content

Commit aa5c781

Browse files
committed
Only show approved topics on article
1 parent 8d28546 commit aa5c781

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

app/content/layouts/article.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
<div class="article-content container" itemprop="articleBody">
3737
<%= yield %>
3838
</div>
39-
<% if @page.topics.any? %>
39+
<% if @page.topics.approved.any? %>
4040
<section id="article-topics" class="section-content container">
41-
<%= render Pages::Topics.new(topics: @page.topics.pluck(:slug)) %>
41+
<%= render Pages::Topics.new(topics: @page.topics.approved.pluck(:slug)) %>
4242
</section>
4343
<% end %>
4444
</article>

spec/system/articles_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
article = Page.first
1414
article.topics << FactoryBot.create_list(:topic, 2, :approved)
15+
article.topics << FactoryBot.create_list(:topic, 1, :pending)
16+
article.topics << FactoryBot.create_list(:topic, 1, :rejected)
1517
article.save!
1618

1719
visit "/articles"
@@ -22,11 +24,15 @@
2224
expect(page).to have_content(article.title)
2325
end
2426

25-
expect(article.topics.count).to eq(2)
27+
expect(article.topics.count).to eq(4)
28+
expect(article.topics.approved.count).to eq(2)
2629

27-
article.topics.each do |topic|
30+
article.topics.approved.each do |topic|
2831
expect(page).to have_link("##{topic.slug}", href: topic_path(topic))
2932
end
33+
(article.topics.rejected + article.topics.pending).each do |topic|
34+
expect(page).not_to have_link("##{topic.slug}", href: topic_path(topic))
35+
end
3036

3137
first_topic = article.topics.first
3238
click_link "##{first_topic.slug}"

0 commit comments

Comments
 (0)