diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-03-05 17:51:40 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-03-05 17:51:40 +0000 |
commit | 8fe880dc064e0e6cd10f7176ade7c312cfb37b90 (patch) | |
tree | fd52091357726e167d27690e5d1e99a981e1821d /spec/views/projects/_home_panel.html.haml_spec.rb | |
parent | 49f72d06654bd7bdea259154e1092a53aab57acc (diff) | |
download | gitlab-ce-8fe880dc064e0e6cd10f7176ade7c312cfb37b90.tar.gz |
Projects and groups badges API
Diffstat (limited to 'spec/views/projects/_home_panel.html.haml_spec.rb')
-rw-r--r-- | spec/views/projects/_home_panel.html.haml_spec.rb | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb index 62af946dcab..15fce65979b 100644 --- a/spec/views/projects/_home_panel.html.haml_spec.rb +++ b/spec/views/projects/_home_panel.html.haml_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' describe 'projects/_home_panel' do - let(:project) { create(:project, :public) } + let(:group) { create(:group) } + let(:project) { create(:project, :public, namespace: group) } let(:notification_settings) do user&.notification_settings_for(project) @@ -35,4 +36,55 @@ describe 'projects/_home_panel' do expect(rendered).not_to have_selector('.notification_dropdown') end end + + context 'when project' do + let!(:user) { create(:user) } + let(:badges) { project.badges } + + context 'has no badges' do + it 'should not render any badge' do + render + + expect(rendered).to have_selector('.project-badges') + expect(rendered).not_to have_selector('.project-badges > a') + end + end + + shared_examples 'show badges' do + it 'should render the all badges' do + render + + expect(rendered).to have_selector('.project-badges a') + + badges.each do |badge| + expect(rendered).to have_link(href: badge.rendered_link_url) + end + end + end + + context 'only has group badges' do + before do + create(:group_badge, group: project.group) + end + + it_behaves_like 'show badges' + end + + context 'only has project badges' do + before do + create(:project_badge, project: project) + end + + it_behaves_like 'show badges' + end + + context 'has both group and project badges' do + before do + create(:project_badge, project: project) + create(:group_badge, group: project.group) + end + + it_behaves_like 'show badges' + end + end end |