diff options
author | Phil Hughes <me@iamphill.com> | 2017-09-21 13:03:14 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-09-22 14:12:16 +0300 |
commit | eab0ca8a0b2950dbbcf6662c34b2fc8313ba9bde (patch) | |
tree | ad17deea946d5c9ee58459be5252d7c2ceef613f | |
parent | 9f3227645442017e3518e2b0ba3e9270ebabfa06 (diff) |
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.
-rw-r--r-- | app/helpers/projects_helper.rb | 4 | ||||
-rw-r--r-- | app/views/dashboard/projects/index.html.haml | 2 | ||||
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 12 |
3 files changed, 11 insertions, 7 deletions
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ddeff490d3a..21fb17e06d6 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -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 diff --git a/app/views/dashboard/projects/index.html.haml b/app/views/dashboard/projects/index.html.haml index 985871a888c..57a4da353fe 100644 --- a/app/views/dashboard/projects/index.html.haml +++ b/app/views/dashboard/projects/index.html.haml @@ -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' diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index a76c75e0c08..7ded95d01af 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -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 |