Skip to content

Commit

Permalink
Refactor ToC specs
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Jun 16, 2023
1 parent da081c9 commit e816c38
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/views/toc/current_issue.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" id="toc-header">
<div class="welcome"><%= link_to "Table of Contents", toc_index_path %> Current issue</div>
<div class="hero-small">
<div class="hero-title">
Expand Down
2 changes: 1 addition & 1 deletion app/views/toc/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" id="toc-header">
<div class="welcome">All volumes and issues</div>
<div class="hero-small">
<div class="hero-title">
Expand Down
2 changes: 1 addition & 1 deletion app/views/toc/issue.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" id="toc-header">
<div class="welcome"><%= link_to "Table of Contents", toc_index_path %> <%= Date::MONTHNAMES[@month] %> <%= @year %> Volume <%= @volume %></div>
<div class="hero-small">
<div class="hero-title">
Expand Down
2 changes: 1 addition & 1 deletion app/views/toc/volume.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" id="toc-header">
<div class="welcome"><%= link_to "Table of Contents", toc_index_path %> <%= "Year " + @year.to_s if @year %></div>
<div class="hero-small">
<div class="hero-title">
Expand Down
2 changes: 1 addition & 1 deletion app/views/toc/year.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="container">
<div class="container" id="toc-header">
<div class="welcome"><%= link_to "Table of Contents", toc_index_path %></div>
<div class="hero-small">
<div class="hero-title">
Expand Down
58 changes: 37 additions & 21 deletions spec/system/toc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
scenario "index" do
visit toc_index_path

expect(page).to have_content("Table of Contents")
expect(page).to_not have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Table of Contents")
expect(page).to_not have_link("Table of Contents")
end

@volumes.each do |volume|
expect(page).to have_link("Volume #{volume} (#{@years[@volumes.index(volume)]})", href: toc_volume_path(volume: volume))
Expand All @@ -60,51 +62,63 @@

scenario "by year" do
visit toc_year_path(year: @years.first)
expect(page).to have_content("Year #{@years.first}")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Year #{@years.first}")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@first_accepted_paper.title, href: @first_accepted_paper.seo_url)
expect(page).to_not have_link(@retracted_paper.title)
expect(page).to_not have_link(@last_accepted_paper.title)

visit toc_year_path(year: @years.last)
expect(page).to have_content("Year #{@years.last}")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Year #{@years.last}")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@retracted_paper.title, href: @retracted_paper.seo_url)
expect(page).to have_link(@last_accepted_paper.title, href: @last_accepted_paper.seo_url)
expect(page).to_not have_link(@first_accepted_paper.title)
end

scenario "by volume" do
visit toc_volume_path(volume: 1)
expect(page).to have_content("Year #{@years.first}")
expect(page).to have_content("Volume 1")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Year #{@years.first}")
expect(page).to have_content("Volume 1")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@first_accepted_paper.title, href: @first_accepted_paper.seo_url)
expect(page).to_not have_link(@retracted_paper.title)
expect(page).to_not have_link(@last_accepted_paper.title)

visit toc_volume_path(volume: @volumes.last)
expect(page).to have_content("Year #{@years.last}")
expect(page).to have_content("Volume #{@volumes.last}")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Year #{@years.last}")
expect(page).to have_content("Volume #{@volumes.last}")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@retracted_paper.title, href: @retracted_paper.seo_url)
expect(page).to have_link(@last_accepted_paper.title, href: @last_accepted_paper.seo_url)
expect(page).to_not have_link(@first_accepted_paper.title)
end

scenario "by issue" do
visit toc_issue_path(issue: 1)
expect(page).to have_content("#{Date::MONTHNAMES[@launch_month]} #{@years.first} Volume 1")
expect(page).to have_content("Issue 1")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("#{Date::MONTHNAMES[@launch_month]} #{@years.first} Volume 1")
expect(page).to have_content("Issue 1")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@first_accepted_paper.title, href: @first_accepted_paper.seo_url)
expect(page).to_not have_link(@retracted_paper.title)
expect(page).to_not have_link(@last_accepted_paper.title)

visit toc_issue_path(issue: @issues.last)
expect(page).to have_content("#{Date::MONTHNAMES[@now.month]} #{@years.last} Volume #{@volumes.last}")
expect(page).to have_content("Issue #{@issues.last}")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("#{Date::MONTHNAMES[@now.month]} #{@years.last} Volume #{@volumes.last}")
expect(page).to have_content("Issue #{@issues.last}")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@retracted_paper.title, href: @retracted_paper.seo_url)
expect(page).to have_link(@last_accepted_paper.title, href: @last_accepted_paper.seo_url)
expect(page).to_not have_link(@first_accepted_paper.title)
Expand All @@ -118,9 +132,11 @@

scenario "current issue" do
visit toc_current_issue_path
expect(page).to have_content("Current issue")
expect(page).to have_content("Year #{@years.last} Volume #{@volumes.last} Issue #{@issues.last}")
expect(page).to have_link("Table of Contents")
within("#toc-header") do
expect(page).to have_content("Current issue")
expect(page).to have_content("Year #{@years.last} Volume #{@volumes.last} Issue #{@issues.last}")
expect(page).to have_link("Table of Contents")
end
expect(page).to have_link(@retracted_paper.title, href: @retracted_paper.seo_url)
expect(page).to have_link(@last_accepted_paper.title, href: @last_accepted_paper.seo_url)
expect(page).to_not have_link(@first_accepted_paper.title)
Expand Down

0 comments on commit e816c38

Please sign in to comment.