Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/views/downloads/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<%= render "downloads/download_preface" %>

<div id="chapters" class="userstuff">
<% if @chapters.size > 1 %>
<%# if chaptered OR more than one chap should display chapter title/notes%>
<% if (@chapters.size > 1) || (@work.chaptered?) %>
<% for chapter in @chapters %>
<%= render "downloads/download_chapter", chapter: chapter %>
<% end %>
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/work_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@
step %{all indexing jobs have been run}
end

When "I force delete chapter {int} of {string}" do |chapter, title|
work = Work.find_by(title: title)
work.chapters.where(position: chapter).first.destroy!
step %{all indexing jobs have been run}
end

# Posts a chapter for the current user
When /^I post a chapter for the work "([^"]*)"(?: as "(.*?)")?$/ do |work_title, pseud|
work = Work.find_by(title: work_title)
Expand Down
62 changes: 55 additions & 7 deletions features/works/work_download.feature
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,31 @@ Feature: Download a work
And I follow "HTML"
Then I should see "Chapter 2"

Scenario: Download of chaptered work without posted chapters does not include chapters
Scenario: Download of single-chapter work does not include chapter title or notes

Given the work "Bazinga"
And a draft chapter is added to "Bazinga"
And I delete chapter 1 of "Bazinga"
When I view the work "Bazinga"
Given the work "Single Chapter Work"
When I view the work "Single Chapter Work"
And I follow "HTML"
Then I should not see "Chapter 1"
And I should not see "Chapter 2"
And I should be able to download all versions of "Bazinga"

Scenario: Download of chaptered work without posted chapters does not include chapters

Given I am logged in
And I set up the draft "Allons-sy"
And I fill in "content" with "Run! Rose, run!"
And I press "Post"
And I follow "Add Chapter"
And I fill in "content" with "Remember, remember the 5th of November"
And I press "Save Draft"
And I force delete chapter 1 of "Allons-sy"
When I view the work "Allons-sy"
And I follow "HTML"
# Content of the deleted chapter and the drafted chapter shouldn't appear
Then I should not see "Run! Rose, run!"
And I should not see "Remember, remember the 5th of November"
# Confrim that the skeleton of the work is still downloaded
And I should see "Allons-sy"
And I should be able to download all versions of "Allons-sy"

Scenario: Download chaptered works

Expand Down Expand Up @@ -438,3 +453,36 @@ Feature: Download a work
And I should see "Chapter 1"
And I should see "Chapter 2: Chapter Two Title"

Scenario: Download work with only one chapter expecting more chapters include chapter title and notes

Given I am logged in as "myname"
And I set up the draft "Download"
And I fill in "Work Title" with "Download"
And I fill in "content" with "Content for chapter one."
And I check "This work has multiple chapters"
And I fill in "Chapter 1 of" with "?"
And I check "at the beginning"
And I fill in "Notes" with "Overall start notes"
And I check "at the end"
And I fill in "End Notes" with "Overall end notes"
And I press "Post"
When I go to the 1st chapter of the work "Download"
And I follow "Edit Chapter"
And I fill in "Chapter Title" with "Chapter One Title"
And I check "at the beginning"
And I fill in "Notes" with "Text of notes at chapter start"
And I check "at the end"
And I fill in "End Notes" with "Text of notes at chapter end"
And I press "Update"
When I view the work "Download"
And I follow "HTML"
Then I should receive a file of type "html"
And I should see "Overall start notes"
And I should see "Overall end notes"
And I should see "Chapter 1: Chapter One Title"
And I should see "Chapter Notes"
And I should see "Text of notes at chapter start"
And I should see "See the end of the chapter for more notes"
And I should see "Chapter End Notes"
And I should see "Text of notes at chapter end"

Loading