Fix --unpublished not affecting collection documents (#7027)
Merge pull request 7027
This commit is contained in:
parent
9968df06b3
commit
9aec161550
|
@ -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
|
||||
|
|
|
@ -210,7 +210,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
|
||||
|
||||
def read_static_file(file_path, full_path)
|
||||
|
|
Loading…
Reference in New Issue