提交 4d482b3b 编写于 作者: D Dmitriy Zaporozhets

Merge branch 'version-file' into 'master'

Version file

Fixes #1345
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册