Skip to content

Commit

Permalink
Fix double snapshot creation error
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed May 1, 2015
1 parent 8b698df commit c3753d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nanoc/base/compilation/item_rep_recorder_proxy.rb
Expand Up @@ -70,7 +70,7 @@ def snapshot(snapshot_name, params = {})

# Count
existing = Set.new
names = @rule_memory.select { |r| r[0] == :snapshot }.map { |r| r[2] }
names = @rule_memory.select { |r| r[0] == :snapshot }.map { |r| r[1] }
names.each do |n|
if existing.include?(n)
raise Nanoc::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, snapshot_name)
Expand Down
21 changes: 21 additions & 0 deletions test/base/test_item_rep_recorder_proxy.rb
@@ -0,0 +1,21 @@
# encoding: utf-8

class Nanoc::ItemRepRecorderProxyTest < Nanoc::TestCase
def test_double_names
item_rep = mock
proxy = Nanoc::ItemRepRecorderProxy.new(item_rep)

proxy.snapshot(:foo, stuff: :giraffe)
assert_raises(Nanoc::Errors::CannotCreateMultipleSnapshotsWithSameName) do
proxy.snapshot(:foo, stuff: :donkey)
end
end

def test_double_params
item_rep = mock
proxy = Nanoc::ItemRepRecorderProxy.new(item_rep)

proxy.snapshot(:foo)
proxy.snapshot(:bar)
end
end

0 comments on commit c3753d8

Please sign in to comment.