diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-12-19 19:43:19 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-12-19 19:43:19 +0300 |
commit | 0be4b0b74e785a6ea18db0b13d1390608d828aa6 (patch) | |
tree | f175b1cce30eddda9b76354e97808c91574db2d1 /spec | |
parent | ac22576d80b6d043c4991ad39172976566465693 (diff) | |
parent | d02059ddf3fef105a8e835024b589d9eac2140f0 (diff) |
Merge branch '36020-private-npm-modules' into 'master'
Do not generate links for private NPM modules in blob view
Closes #36020
See merge request gitlab-org/gitlab-ce!16002
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/blob_viewer/package_json_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/models/blob_viewer/package_json_spec.rb b/spec/models/blob_viewer/package_json_spec.rb index 0f8330e91c1..5ed2f4400bc 100644 --- a/spec/models/blob_viewer/package_json_spec.rb +++ b/spec/models/blob_viewer/package_json_spec.rb @@ -22,4 +22,51 @@ describe BlobViewer::PackageJson do expect(subject.package_name).to eq('module-name') end end + + describe '#package_url' do + it 'returns the package URL' do + expect(subject).to receive(:prepare!) + + expect(subject.package_url).to eq("https://www.npmjs.com/package/#{subject.package_name}") + end + end + + describe '#package_type' do + it 'returns "package"' do + expect(subject).to receive(:prepare!) + + expect(subject.package_type).to eq('package') + end + end + + context 'when package.json has "private": true' do + let(:data) do + <<-SPEC.strip_heredoc + { + "name": "module-name", + "version": "10.3.1", + "private": true, + "homepage": "myawesomepackage.com" + } + SPEC + end + let(:blob) { fake_blob(path: 'package.json', data: data) } + subject { described_class.new(blob) } + + describe '#package_url' do + it 'returns homepage if any' do + expect(subject).to receive(:prepare!) + + expect(subject.package_url).to eq('myawesomepackage.com') + end + end + + describe '#package_type' do + it 'returns "private package"' do + expect(subject).to receive(:prepare!) + + expect(subject.package_type).to eq('private package') + end + end + end end |