Commit 3b27a458 authored by Phil Hughes's avatar Phil Hughes

Added specs for presenter methods

Added specs to each of the presenters for the new web_path method
parent e1670b92
---
title: Added webPath and descriptionHtml types to the repository GraphQL entities
merge_request: 37416
author:
type: added
......@@ -24,6 +24,16 @@ RSpec.describe BlobPresenter, :seed_helper do
it { expect(subject.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{blob.commit_id}/#{blob.path}") }
end
describe '.web_path' 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_path).to eq("/#{project.full_path}/-/blob/#{blob.commit_id}/#{blob.path}") }
end
describe '#highlight' do
subject { described_class.new(blob) }
......
......@@ -8,6 +8,10 @@ RSpec.describe CommitPresenter do
let(:user) { create(:user) }
let(:presenter) { described_class.new(commit, current_user: user) }
describe '.web_path' do
it { expect(presenter.web_path).to eq("/#{project.full_path}/-/commit/#{commit.sha}") }
end
describe '#status_for' do
subject { presenter.status_for('ref') }
......
......@@ -13,4 +13,8 @@ RSpec.describe TreeEntryPresenter do
describe '.web_url' do
it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/tree/#{tree.commit_id}/#{tree.path}") }
end
describe '.web_path' do
it { expect(presenter.web_path).to eq("/#{project.full_path}/-/tree/#{tree.commit_id}/#{tree.path}") }
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe UserPresenter do
let(:user) { create(:user) }
let(:presenter) { described_class.new(user) }
describe '.web_path' do
it { expect(presenter.web_path).to eq("/#{user.username}") }
end
describe '.web_url' do
it { expect(presenter.web_url).to eq("http://localhost/#{user.username}") }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment