diff options
author | Loic Nageleisen <loic.nageleisen@gmail.com> | 2014-03-29 00:15:25 +0400 |
---|---|---|
committer | Loic Nageleisen <loic.nageleisen@gmail.com> | 2014-06-07 13:14:33 +0400 |
commit | c1ccc3a57b8e335c014e3176f3255ed74703572f (patch) | |
tree | 66eeeffeb0bb55d60eefde0d441001d63875098c /spec/models/project_wiki_spec.rb | |
parent | ab094e67eed54f5c29a33d2114cc91908e543972 (diff) |
Added ability to serve files in wiki repository
From #6168.
Diffstat (limited to 'spec/models/project_wiki_spec.rb')
-rw-r--r-- | spec/models/project_wiki_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb index 32a82470e4f..f06a5cd4ecc 100644 --- a/spec/models/project_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -149,6 +149,40 @@ describe ProjectWiki do end end + describe '#find_file' do + before do + file = Gollum::File.new(subject.wiki) + Gollum::Wiki.any_instance. + stub(:file).with('image.jpg', 'master', true). + and_return(file) + Gollum::File.any_instance. + stub(:mime_type). + and_return('image/jpeg') + Gollum::Wiki.any_instance. + stub(:file).with('non-existant', 'master', true). + and_return(nil) + end + + after do + Gollum::Wiki.any_instance.unstub(:file) + Gollum::File.any_instance.unstub(:mime_type) + end + + it 'returns the latest version of the file if it exists' do + file = subject.find_file('image.jpg') + file.mime_type.should == 'image/jpeg' + end + + it 'returns nil if the page does not exist' do + subject.find_file('non-existant').should == nil + end + + it 'returns a Gollum::File instance' do + file = subject.find_file('image.jpg') + file.should be_a Gollum::File + end + end + describe "#create_page" do after do destroy_page(subject.pages.first.page) |