Merge branch 'version-file' into 'master'

Version file

Fixes #1345
This commit is contained in:
Dmitriy Zaporozhets 2014-06-25 10:35:42 +00:00
commit 4d482b3b0c
4 changed files with 36 additions and 0 deletions

View file

@ -128,6 +128,7 @@ class Repository
Rails.cache.delete(cache_key(:commit_count))
Rails.cache.delete(cache_key(:graph_log))
Rails.cache.delete(cache_key(:readme))
Rails.cache.delete(cache_key(:version))
Rails.cache.delete(cache_key(:contribution_guide))
end
@ -156,12 +157,24 @@ class Repository
Gitlab::Git::Blob.find(self, sha, path)
end
def blob_by_oid(oid)
Gitlab::Git::Blob.raw(self, oid)
end
def readme
Rails.cache.fetch(cache_key(:readme)) do
tree(:head).readme
end
end
def version
Rails.cache.fetch(cache_key(:version)) do
tree(:head).blobs.find do |file|
file.name.downcase == 'version'
end
end
end
def contribution_guide
Rails.cache.fetch(cache_key(:contribution_guide)) do
tree(:head).contribution_guide

View file

@ -44,6 +44,12 @@
= link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do
= readme.name
- if @repository.version
- version = @repository.version
= link_to project_blob_path(@project, tree_join(@repository.root_ref, version.name)), class: 'btn btn-block' do
Version:
= @repository.blob_by_oid(version.id).data
.prepend-top-10
%p
%span.light Created on

View file

@ -24,3 +24,8 @@ Feature: Project Feature
When I visit edit project "Shop" page
And change project path settings
Then I should see project with new path settings
Scenario: I should see project readme and version
When I visit project "Shop" page
Then I should see project "Shop" README link
And I should see project "Shop" version

View file

@ -24,4 +24,16 @@ class ProjectFeature < Spinach::FeatureSteps
step 'I should see project with new path settings' do
project.path.should == "new-path"
end
step 'I should see project "Shop" README link' do
within '.project-side' do
page.should have_content "README.md"
end
end
step 'I should see project "Shop" version' do
within '.project-side' do
page.should have_content "Version: 2.2.0"
end
end
end