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

Use content filename when constructing identifier #611

Merged
merged 1 commit into from May 31, 2015
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
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