debian-mirror-gitlab/spec/views/projects/merge_requests/show.html.haml_spec.rb

77 lines
2.2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
require 'spec_helper'
2021-04-17 20:07:23 +05:30
RSpec.describe 'projects/merge_requests/show.html.haml', :aggregate_failures do
2021-10-27 15:23:28 +05:30
using RSpec::Parameterized::TableSyntax
2021-04-17 20:07:23 +05:30
include_context 'merge request show action'
2021-02-22 17:27:13 +05:30
2020-06-23 00:09:42 +05:30
before do
2021-04-17 20:07:23 +05:30
merge_request.reload
2020-06-23 00:09:42 +05:30
end
2021-02-22 17:27:13 +05:30
context 'when the merge request is open' do
it 'shows the "Mark as draft" button' do
render
2019-02-15 15:39:39 +05:30
2021-02-22 17:27:13 +05:30
expect(rendered).to have_css('a', visible: true, text: 'Mark as draft')
expect(rendered).to have_css('a', visible: false, text: 'Reopen')
expect(rendered).to have_css('a', visible: true, text: 'Close')
2019-02-15 15:39:39 +05:30
end
end
2016-09-29 09:46:39 +05:30
context 'when the merge request is closed' do
2021-04-17 20:07:23 +05:30
before do
merge_request.close!
2021-02-22 17:27:13 +05:30
end
2016-09-29 09:46:39 +05:30
it 'shows the "Reopen" button' do
render
2021-02-22 17:27:13 +05:30
expect(rendered).not_to have_css('a', visible: true, text: 'Mark as draft')
2016-09-29 09:46:39 +05:30
expect(rendered).to have_css('a', visible: true, text: 'Reopen')
expect(rendered).to have_css('a', visible: false, text: 'Close')
end
2021-04-17 20:07:23 +05:30
context 'when source project does not exist' do
it 'does not show the "Reopen" button' do
allow(merge_request).to receive(:source_project).and_return(nil)
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
render
2016-09-29 09:46:39 +05:30
2021-04-17 20:07:23 +05:30
expect(rendered).to have_css('a', visible: false, text: 'Reopen')
expect(rendered).to have_css('a', visible: false, text: 'Close')
end
2016-09-29 09:46:39 +05:30
end
end
2021-10-27 15:23:28 +05:30
describe 'gitpod modal' do
let(:gitpod_modal_selector) { '#modal-enable-gitpod' }
let(:user) { create(:user) }
let(:user_gitpod_enabled) { create(:user).tap { |x| x.update!(gitpod_enabled: true) } }
where(:site_enabled, :current_user, :should_show) do
false | ref(:user) | false
true | ref(:user) | true
true | nil | true
true | ref(:user_gitpod_enabled) | false
end
with_them do
it 'handles rendering gitpod user enable modal' do
allow(Gitlab::CurrentSettings).to receive(:gitpod_enabled).and_return(site_enabled)
allow(view).to receive(:current_user).and_return(current_user)
render
if should_show
expect(rendered).to have_css(gitpod_modal_selector)
else
expect(rendered).to have_no_css(gitpod_modal_selector)
end
end
end
end
2016-09-29 09:46:39 +05:30
end