Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #611 from nanoc/fix-identifier-with-separate-yaml-…
Browse files Browse the repository at this point in the history
…file

Use content filename when constructing identifier
  • Loading branch information
denisdefreyne committed May 31, 2015
2 parents 9c94511 + de1b2f1 commit 917d05f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/nanoc/data_sources/filesystem.rb
Expand Up @@ -73,10 +73,10 @@ def load_objects(dir_name, kind, klass)
}.merge(meta)

# Get identifier
if meta_filename
identifier = identifier_for_filename(meta_filename[dir_name.length..-1])
elsif content_filename
if content_filename
identifier = identifier_for_filename(content_filename[dir_name.length..-1])
elsif meta_filename
identifier = identifier_for_filename(meta_filename[dir_name.length..-1])
else
raise 'meta_filename and content_filename are both nil'
end
Expand Down
12 changes: 12 additions & 0 deletions test/data_sources/test_filesystem_unified.rb
Expand Up @@ -468,6 +468,18 @@ def ==(other)
end
end

def test_load_objects_correct_identifier_with_separate_yaml_file
data_source = new_data_source({ identifier_type: 'full' })

FileUtils.mkdir_p('foo')
File.write('foo/donkey.jpeg', 'data')
File.write('foo/donkey.yaml', "---\nalt: Donkey\n")

objects = data_source.send(:load_objects, 'foo', 'The Foo', Nanoc::Int::Item)
assert_equal 1, objects.size
assert_equal '/donkey.jpeg', objects.first.identifier.to_s
end

def test_filename_for
data_source = new_data_source

Expand Down

0 comments on commit 917d05f

Please sign in to comment.