diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 00:06:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 00:06:17 +0300 |
commit | 11faf8ae72dcdbaff31f97410a3a9319324438fd (patch) | |
tree | 2dc680f52ef8b2355c9097dfd1bbeb5ba899df3c /spec/presenters | |
parent | 7f0a4a64d0bc59b184ae3ee578adb6ebd3c48bf7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/release_presenter_spec.rb | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/spec/presenters/release_presenter_spec.rb b/spec/presenters/release_presenter_spec.rb new file mode 100644 index 00000000000..8bca38f7054 --- /dev/null +++ b/spec/presenters/release_presenter_spec.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe ReleasePresenter do + include Gitlab::Routing.url_helpers + + let_it_be(:project) { create(:project, :repository) } + let(:developer) { create(:user) } + let(:guest) { create(:user) } + let(:user) { developer } + let(:release) { create(:release, project: project) } + let(:presenter) { described_class.new(release, current_user: user) } + + before do + project.add_developer(developer) + project.add_guest(guest) + end + + describe '#commit_path' do + subject { presenter.commit_path } + + it 'returns commit path' do + is_expected.to eq(project_commit_path(project, release.commit.id)) + end + + context 'when commit is not found' do + let(:release) { create(:release, project: project, sha: 'not-found') } + + it { is_expected.to be_nil } + end + + context 'when user is guest' do + let(:user) { guest } + + it { is_expected.to be_nil } + end + end + + describe '#tag_path' do + subject { presenter.tag_path } + + it 'returns tag path' do + is_expected.to eq(project_tag_path(project, release.tag)) + end + + context 'when user is guest' do + let(:user) { guest } + + it { is_expected.to be_nil } + end + end + + describe '#merge_requests_url' do + subject { presenter.merge_requests_url } + + it 'returns merge requests url' do + is_expected.to match /#{project_merge_requests_url(project)}/ + end + + context 'when release_mr_issue_urls feature flag is disabled' do + before do + stub_feature_flags(release_mr_issue_urls: false) + end + + it { is_expected.to be_nil } + end + end + + describe '#issues_url' do + subject { presenter.issues_url } + + it 'returns merge requests url' do + is_expected.to match /#{project_issues_url(project)}/ + end + + context 'when release_mr_issue_urls feature flag is disabled' do + before do + stub_feature_flags(release_mr_issue_urls: false) + end + + it { is_expected.to be_nil } + end + end +end |