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 ...@@ -239,8 +239,8 @@ module ProjectsHelper
end end
end end
def has_projects_or_name?(projects, params) def show_projects?(projects, params)
!!(params[:name] || any_projects?(projects)) !!(params[:personal] || params[:name] || any_projects?(projects))
end end
private private
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
= render "projects/last_push" = render "projects/last_push"
%div{ class: container_class } %div{ class: container_class }
- if has_projects_or_name?(@projects, params) - if show_projects?(@projects, params)
= render 'dashboard/projects_head' = render 'dashboard/projects_head'
= render 'nav' = render 'nav'
= render 'projects' = render 'projects'
......
...@@ -420,22 +420,26 @@ describe ProjectsHelper do ...@@ -420,22 +420,26 @@ describe ProjectsHelper do
end end
end end
describe '#has_projects_or_name?' do describe '#show_projects' do
let(:projects) do let(:projects) do
create(:project) create(:project)
Project.all Project.all
end end
it 'returns true when there are projects' do 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 end
it 'returns true when there are no projects but a name is given' do 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 end
it 'returns false when there are no projects and there is no name' do 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
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