Fix --unpublished not affecting collection documents (#7027)

Merge pull request 7027
This commit is contained in:
Philip Belesky 2018-05-21 02:30:15 +10:00 committed by Pat Hawks
parent d22b8ee392
commit 6792ff936c
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
2 changed files with 101 additions and 1 deletions

View File

@ -263,6 +263,104 @@ Feature: Collections
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/hardy.html" file should not exist
Scenario: Access rendered collection with future date and unpublished flag via Liquid
Given I have a _puppies directory
And I have the following documents under the puppies collection:
| title | date | content | published |
| Rover | 2007-12-31 | content for Rover. | true |
| Figor | 2007-12-31 | content for Figor. | false |
| Snowy | 2199-12-31 | content for Snowy. | true |
| Hardy | 2199-12-31 | content for Hardy. | false |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: true
"""
And I have a "index.md" page that contains "{% for puppy in site.puppies %}<div>{{ puppy.title }}</div>{% endfor %}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
But I should see "<div>Snowy</div>" in "_site/index.html"
And I should not see "<div>Figor</div>" in "_site/index.html"
And I should not see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should exist
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/figor.html" file should not exist
And the "_site/puppies/hardy.html" file should not exist
When I run jekyll build --unpublished
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
And I should see "<div>Snowy</div>" in "_site/index.html"
And I should see "<div>Figor</div>" in "_site/index.html"
But I should see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should exist
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/figor.html" file should exist
And the "_site/puppies/hardy.html" file should not exist
When I run jekyll build --unpublished --future
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
And I should see "<div>Snowy</div>" in "_site/index.html"
And I should see "<div>Figor</div>" in "_site/index.html"
But I should see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should exist
And the "_site/puppies/snowy.html" file should exist
And the "_site/puppies/figor.html" file should exist
And the "_site/puppies/hardy.html" file should exist
Scenario: Access unrendered collection with future date and unpublished flag via Liquid
Given I have a _puppies directory
And I have the following documents under the puppies collection:
| title | date | content | published |
| Rover | 2007-12-31 | content for Rover. | true |
| Figor | 2007-12-31 | content for Figor. | false |
| Snowy | 2199-12-31 | content for Snowy. | true |
| Hardy | 2199-12-31 | content for Hardy. | false |
And I have a "_config.yml" file with content:
"""
collections:
puppies:
output: false
"""
And I have a "index.md" page that contains "{% for puppy in site.puppies %}<div>{{ puppy.title }}</div>{% endfor %}"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
But I should see "<div>Snowy</div>" in "_site/index.html"
And I should not see "<div>Figor</div>" in "_site/index.html"
And I should not see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should not exist
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/figor.html" file should not exist
And the "_site/puppies/hardy.html" file should not exist
When I run jekyll build --unpublished
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
And I should see "<div>Snowy</div>" in "_site/index.html"
And I should see "<div>Figor</div>" in "_site/index.html"
But I should see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should not exist
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/figor.html" file should not exist
And the "_site/puppies/hardy.html" file should not exist
When I run jekyll build --unpublished --future
Then I should get a zero exit status
And the _site directory should exist
And I should see "<div>Rover</div>" in "_site/index.html"
And I should see "<div>Snowy</div>" in "_site/index.html"
And I should see "<div>Figor</div>" in "_site/index.html"
But I should see "<div>Hardy</div>" in "_site/index.html"
And the "_site/puppies/rover.html" file should not exist
And the "_site/puppies/snowy.html" file should not exist
And the "_site/puppies/figor.html" file should not exist
And the "_site/puppies/hardy.html" file should not exist
Scenario: All the documents
Given I have an "index.html" page that contains "All documents: {% for doc in site.documents %}{{ doc.relative_path }} {% endfor %}"
And I have fixture collections

View File

@ -212,7 +212,9 @@ module Jekyll
def read_document(full_path)
doc = Document.new(full_path, :site => site, :collection => self)
doc.read
docs << doc unless doc.data["published"] == false
if site.unpublished || doc.published?
docs << doc
end
end
private