diff options
author | Nick Thomas <nick@gitlab.com> | 2019-06-05 15:44:53 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-06-05 15:44:53 +0000 |
commit | 327c7d5a07fa08276a52b6a2bfdf79eee812a2cd (patch) | |
tree | 0da14d9a65451f5c1937fb8679cab3ab9f4c7954 /spec | |
parent | 86ff32da666c8d284ecff5987d42fa4dfed2ee9b (diff) | |
parent | 4644a2daf5ec5e86e2b2989f04e99e4f081f6fef (diff) | |
download | gitlab-ce-327c7d5a07fa08276a52b6a2bfdf79eee812a2cd.tar.gz |
Merge branch 'graphql-file-entry-url' into 'master'
Add web_url to tree entry in GraphQL API
See merge request gitlab-org/gitlab-ce!28646
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/repository/components/table/row_spec.js | 12 | ||||
-rw-r--r-- | spec/graphql/types/tree/blob_type_spec.rb | 2 | ||||
-rw-r--r-- | spec/graphql/types/tree/tree_entry_type_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/representation/tree_entry_spec.rb | 20 | ||||
-rw-r--r-- | spec/presenters/blob_presenter_spec.rb | 10 | ||||
-rw-r--r-- | spec/presenters/tree_entry_presenter_spec.rb | 16 |
6 files changed, 60 insertions, 2 deletions
diff --git a/spec/frontend/repository/components/table/row_spec.js b/spec/frontend/repository/components/table/row_spec.js index 6b4508c418e..a70dc7bb866 100644 --- a/spec/frontend/repository/components/table/row_spec.js +++ b/spec/frontend/repository/components/table/row_spec.js @@ -86,4 +86,16 @@ describe('Repository table row component', () => { expect(vm.find('.commit-sha').text()).toContain('1'); }); + + it('renders link with href', () => { + factory({ + id: '1', + path: 'test', + type: 'blob', + url: 'https://test.com', + currentPath: '/', + }); + + expect(vm.find('a').attributes('href')).toEqual('https://test.com'); + }); }); diff --git a/spec/graphql/types/tree/blob_type_spec.rb b/spec/graphql/types/tree/blob_type_spec.rb index fa29bb5fff7..b12e214ca84 100644 --- a/spec/graphql/types/tree/blob_type_spec.rb +++ b/spec/graphql/types/tree/blob_type_spec.rb @@ -5,5 +5,5 @@ require 'spec_helper' describe Types::Tree::BlobType do it { expect(described_class.graphql_name).to eq('Blob') } - it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path) } + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path, :web_url) } end diff --git a/spec/graphql/types/tree/tree_entry_type_spec.rb b/spec/graphql/types/tree/tree_entry_type_spec.rb index 397cabde8e5..ea1b6426034 100644 --- a/spec/graphql/types/tree/tree_entry_type_spec.rb +++ b/spec/graphql/types/tree/tree_entry_type_spec.rb @@ -5,5 +5,5 @@ require 'spec_helper' describe Types::Tree::TreeEntryType do it { expect(described_class.graphql_name).to eq('TreeEntry') } - it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path) } + it { expect(described_class).to have_graphql_fields(:id, :name, :type, :path, :flat_path, :web_url) } end diff --git a/spec/lib/gitlab/graphql/representation/tree_entry_spec.rb b/spec/lib/gitlab/graphql/representation/tree_entry_spec.rb new file mode 100644 index 00000000000..d45e690160c --- /dev/null +++ b/spec/lib/gitlab/graphql/representation/tree_entry_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Graphql::Representation::TreeEntry do + let(:project) { create(:project, :repository) } + let(:repository) { project.repository } + + describe '.decorate' do + it 'returns NilClass when given nil' do + expect(described_class.decorate(nil, repository)).to be_nil + end + + it 'returns array of TreeEntry' do + entries = described_class.decorate(repository.tree.blobs, repository) + + expect(entries.first).to be_a(described_class) + end + end +end diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index bb1db9a3d51..eacf383be7d 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -14,6 +14,16 @@ describe BlobPresenter, :seed_helper do end let(:blob) { Blob.new(git_blob) } + describe '.web_url' do + let(:project) { create(:project, :repository) } + let(:repository) { project.repository } + let(:blob) { Gitlab::Graphql::Representation::TreeEntry.new(repository.tree.blobs.first, repository) } + + subject { described_class.new(blob) } + + it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/blob/#{blob.commit_id}/#{blob.path}") } + end + describe '#highlight' do subject { described_class.new(blob) } diff --git a/spec/presenters/tree_entry_presenter_spec.rb b/spec/presenters/tree_entry_presenter_spec.rb new file mode 100644 index 00000000000..d74ee5dc28f --- /dev/null +++ b/spec/presenters/tree_entry_presenter_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe TreeEntryPresenter do + include Gitlab::Routing.url_helpers + + let(:project) { create(:project, :repository) } + let(:repository) { project.repository } + let(:tree) { Gitlab::Graphql::Representation::TreeEntry.new(repository.tree.trees.first, repository) } + let(:presenter) { described_class.new(tree) } + + describe '.web_url' do + it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/tree/#{tree.commit_id}/#{tree.path}") } + end +end |