Commit eab0ca8a authored by Phil Hughes's avatar Phil Hughes

Fixes dashboard/projects empty state showing when viewing personal projects

This was caused by the `@projects` value being empty when the current
user does not have any personal projects.
parent 9f322764
......@@ -239,8 +239,8 @@ module ProjectsHelper
end
end
def has_projects_or_name?(projects, params)
!!(params[:name] || any_projects?(projects))
def show_projects?(projects, params)
!!(params[:personal] || params[:name] || any_projects?(projects))
end
private
......
......@@ -10,7 +10,7 @@
= render "projects/last_push"
%div{ class: container_class }
- if has_projects_or_name?(@projects, params)
- if show_projects?(@projects, params)
= render 'dashboard/projects_head'
= render 'nav'
= render 'projects'
......
......@@ -420,22 +420,26 @@ describe ProjectsHelper do
end
end
describe '#has_projects_or_name?' do
describe '#show_projects' do
let(:projects) do
create(:project)
Project.all
end
it 'returns true when there are projects' do
expect(helper.has_projects_or_name?(projects, {})).to eq(true)
expect(helper.show_projects?(projects, {})).to eq(true)
end
it 'returns true when there are no projects but a name is given' do
expect(helper.has_projects_or_name?(Project.none, name: 'foo')).to eq(true)
expect(helper.show_projects?(Project.none, name: 'foo')).to eq(true)
end
it 'returns true when there are no projects but personal is present' do
expect(helper.show_projects?(Project.none, personal: 'true')).to eq(true)
end
it 'returns false when there are no projects and there is no name' do
expect(helper.has_projects_or_name?(Project.none, {})).to eq(false)
expect(helper.show_projects?(Project.none, {})).to eq(false)
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