diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-23 12:06:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-23 12:06:22 +0300 |
commit | 1d89871c573830a8194110af252e8907177184b3 (patch) | |
tree | 9aece724c48fc633f38c3b8cbaf2f71fcf4c3f4c /spec | |
parent | 89861e72b7375353654513aa2bc0a3b60a5e4377 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/vue_shared/plugins/global_toast_spec.js | 10 | ||||
-rw-r--r-- | spec/views/projects/artifacts/_artifact.html.haml_spec.rb | 74 |
2 files changed, 79 insertions, 5 deletions
diff --git a/spec/frontend/vue_shared/plugins/global_toast_spec.js b/spec/frontend/vue_shared/plugins/global_toast_spec.js index 551abe3cb41..89f43a5e556 100644 --- a/spec/frontend/vue_shared/plugins/global_toast_spec.js +++ b/spec/frontend/vue_shared/plugins/global_toast_spec.js @@ -1,24 +1,24 @@ -import toast from '~/vue_shared/plugins/global_toast'; import Vue from 'vue'; +import toast from '~/vue_shared/plugins/global_toast'; describe('Global toast', () => { let spyFunc; beforeEach(() => { - spyFunc = jest.spyOn(Vue.toasted, 'show').mockImplementation(() => {}); + spyFunc = jest.spyOn(Vue.prototype.$toast, 'show').mockImplementation(() => {}); }); afterEach(() => { spyFunc.mockRestore(); }); - it('should pass all args to Vue toasted', () => { + it("should call GitLab UI's toast method", () => { const arg1 = 'TestMessage'; const arg2 = { className: 'foo' }; toast(arg1, arg2); - expect(Vue.toasted.show).toHaveBeenCalledTimes(1); - expect(Vue.toasted.show).toHaveBeenCalledWith(arg1, arg2); + expect(Vue.prototype.$toast.show).toHaveBeenCalledTimes(1); + expect(Vue.prototype.$toast.show).toHaveBeenCalledWith(arg1, arg2); }); }); diff --git a/spec/views/projects/artifacts/_artifact.html.haml_spec.rb b/spec/views/projects/artifacts/_artifact.html.haml_spec.rb new file mode 100644 index 00000000000..460b63efa2f --- /dev/null +++ b/spec/views/projects/artifacts/_artifact.html.haml_spec.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe "projects/artifacts/_artifact.html.haml" do + let(:project) { create(:project) } + + describe 'delete button' do + before do + create(:ci_build, :artifacts, project: project) + + allow(view).to receive(:current_user).and_return(user) + assign(:project, project) + end + + context 'with admin' do + let(:user) { build(:admin) } + + it 'has a delete button' do + render_partial + + expect(rendered).to have_link('Delete artifacts', href: project_artifact_path(project, project.job_artifacts.first)) + end + end + + context 'with owner' do + let(:user) { create(:user) } + let(:project) { build(:project, namespace: user.namespace) } + + it 'has a delete button' do + render_partial + + expect(rendered).to have_link('Delete artifacts', href: project_artifact_path(project, project.job_artifacts.first)) + end + end + + context 'with master' do + let(:user) { create(:user) } + + it 'has a delete button' do + allow_any_instance_of(ProjectTeam).to receive(:max_member_access).and_return(Gitlab::Access::MASTER) + render_partial + + expect(rendered).to have_link('Delete artifacts', href: project_artifact_path(project, project.job_artifacts.first)) + end + end + + context 'with developer' do + let(:user) { build(:user) } + + it 'has no delete button' do + project.add_developer(user) + render_partial + + expect(rendered).not_to have_link('Delete artifacts') + end + end + + context 'with reporter' do + let(:user) { build(:user) } + + it 'has no delete button' do + project.add_reporter(user) + render_partial + + expect(rendered).not_to have_link('Delete artifacts') + end + end + end + + def render_partial + render partial: 'projects/artifacts/artifact', collection: project.job_artifacts, as: :artifact + end +end |