diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/helpers/projects_helper_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/helpers/projects_helper_spec.rb')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 4e072f02ae0..a3d0673f1b3 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ProjectsHelper do +RSpec.describe ProjectsHelper do include ProjectForksHelper let_it_be(:project) { create(:project) } @@ -444,8 +444,8 @@ describe ProjectsHelper do end describe '#get_project_nav_tabs' do + let_it_be(:user) { create(:user) } let(:project) { create(:project) } - let(:user) { create(:user) } before do allow(helper).to receive(:can?) { true } @@ -501,6 +501,20 @@ describe ProjectsHelper do is_expected.not_to include(:external_wiki) end end + + context 'when project has confluence enabled' do + before do + allow(project).to receive(:has_confluence?).and_return(true) + end + + it { is_expected.to include(:confluence) } + it { is_expected.not_to include(:wiki) } + end + + context 'when project does not have confluence enabled' do + it { is_expected.not_to include(:confluence) } + it { is_expected.to include(:wiki) } + end end describe '#can_view_operations_tab?' do @@ -977,19 +991,32 @@ describe ProjectsHelper do end end - describe '#project_license_name(project)' do + describe '#project_license_name(project)', :request_store do let_it_be(:project) { create(:project) } let_it_be(:repository) { project.repository } subject { project_license_name(project) } + def license_name + project_license_name(project) + end + context 'gitaly is working appropriately' do - it 'returns the license name' do - license = Licensee::License.new('mit') - allow(repository).to receive(:license).and_return(license) + let(:license) { Licensee::License.new('mit') } + before do + expect(repository).to receive(:license).and_return(license) + end + + it 'returns the license name' do expect(subject).to eq(license.name) end + + it 'memoizes the value' do + expect do + 2.times { expect(license_name).to eq(license.name) } + end.to change { Gitlab::GitalyClient.get_request_count }.by_at_most(1) + end end context 'gitaly is unreachable' do @@ -1003,10 +1030,16 @@ describe ProjectsHelper do subject end + + it 'memoizes the nil value' do + expect do + 2.times { expect(license_name).to be_nil } + end.to change { Gitlab::GitalyClient.get_request_count }.by_at_most(1) + end end before do - allow(repository).to receive(:license).and_raise(exception) + expect(repository).to receive(:license).and_raise(exception) end context "Gitlab::Git::CommandError" do |