Commit 0527ea09 authored by tiagonbotelho's avatar tiagonbotelho

adds guard clause for readme model method and initializes a new view with proper stylesheets

parent 6eeff67c
......@@ -50,7 +50,9 @@ module PreferencesHelper
end
def default_project_view
return 'readme' unless current_user
unless current_user
return @repository.head_commit ? 'readme' : 'activity'
end
user_view = current_user.project_view
......
......@@ -554,6 +554,8 @@ class Repository
end
def readme
return unless head_commit
cache.fetch(:readme) { tree(:head).readme }
end
......
---
title: 500 error on project show when user is not logged in and project is still empty
merge_request: 7376
author:
......@@ -85,4 +85,25 @@ describe PreferencesHelper do
and_return(double('user', messages))
end
end
describe 'default_project_view' do
let(:project) { create(:project) }
context 'user not signed in' do
before do
stub_user
@repository = project.repository
end
it 'returns readme view if repository is not empty' do
expect(helper.default_project_view).to eq('readme')
end
it 'returns activity if repository is empty' do
expect(@repository).to receive(:head_commit).and_return(nil)
expect(helper.default_project_view).to eq('activity')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment