Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create :pre snapshot if none already exist #1065

Merged
merged 1 commit into from Jan 15, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/nanoc/rule_dsl/rule_memory_calculator.rb
Expand Up @@ -84,6 +84,9 @@ def new_rule_memory_for_rep(rep)
unless rule_memory.snapshot_actions.any? { |sa| sa.snapshot_name == :last }
executor.snapshot(:last)
end
unless rule_memory.snapshot_actions.any? { |sa| sa.snapshot_name == :pre }
executor.snapshot(:pre)
end

assign_paths_to_mem(rule_memory, rep: rep)
end
Expand Down
18 changes: 18 additions & 0 deletions spec/nanoc/regressions/gh_1064_spec.rb
@@ -0,0 +1,18 @@
describe 'GH-1064', site: true, stdio: true do
before do
File.write('content/foo.erb', '*<%= @items["/bar.*"].compiled_content(snapshot: :pre) %>*')
File.write('content/bar.erb', 'Bar!')

File.write('Rules', <<EOS)
compile '/*' do
filter :erb
write item.identifier
end
EOS
end

it 'does not reuse old content' do
Nanoc::CLI.run(%w(compile))
expect(File.read('output/foo.erb')).to eql('*Bar!*')
end
end
18 changes: 15 additions & 3 deletions spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb
Expand Up @@ -96,7 +96,11 @@
expect(subject[1].snapshot_name).to eql(:last)
expect(subject[1].path).to be_nil

expect(subject.size).to eql(2)
expect(subject[2]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
expect(subject[2].snapshot_name).to eql(:pre)
expect(subject[2].path).to be_nil

expect(subject.size).to eql(3)
end
end

Expand All @@ -122,7 +126,11 @@
expect(subject[1].snapshot_name).to eql(:last)
expect(subject[1].path).to eq('/foo.md')

expect(subject.size).to eql(2)
expect(subject[2]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
expect(subject[2].snapshot_name).to eql(:pre)
expect(subject[2].path).to be_nil

expect(subject.size).to eql(3)
end
end

Expand All @@ -148,7 +156,11 @@
expect(subject[1].snapshot_name).to eql(:last)
expect(subject[1].path).to be_nil

expect(subject.size).to eql(2)
expect(subject[2]).to be_a(Nanoc::Int::ProcessingActions::Snapshot)
expect(subject[2].snapshot_name).to eql(:pre)
expect(subject[2].path).to be_nil

expect(subject.size).to eql(3)
end
end
end
Expand Down