Commit ac816f48 authored by Paul Slaughter's avatar Paul Slaughter

Add spec for editing MR approval rules

- This increases integration coverage
- Also added a shared context for project with approval rules
parent a39d6fb9
# frozen_string_literal: true
require 'spec_helper'
describe 'Merge request > User edits MR with approval rules', :js do
include_context 'project with approval rules'
let(:merge_request) { create(:merge_request, source_project: project) }
let(:mr_rule_names) { %w[foo lorem ipsum] }
def page_rule_names
page.all('.js-approval-rules table .js-name')
end
before do
project.update_attribute(:disable_overriding_approvers_per_merge_request, false)
stub_licensed_features(multiple_approval_rules: true)
mr_rule_names.each do |name|
create(:approval_merge_request_rule, merge_request: merge_request, approvals_required: 1, name: name)
end
sign_in(author)
visit(edit_project_merge_request_path(project, merge_request))
wait_for_requests
end
it "shows approval rules" do
names = page_rule_names.map(&:text)
expect(names).to eq(mr_rule_names)
end
end
......@@ -5,29 +5,13 @@ require 'rails_helper'
describe 'Merge request > User sets approval rules', :js do
include ProjectForksHelper
let(:approver) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public, :repository) }
include_context 'project with approval rules'
def page_rule_names
page.all('.js-approval-rules table .js-name')
end
before do
stub_licensed_features(multiple_approval_rules: true)
[approver, author].each do |member|
project.add_maintainer(member)
end
end
context "with project approval rules" do
let!(:regular_rules) do
Array.new(3) do |i|
create(:approval_project_rule, project: project, users: [approver], name: "Regular Rule #{i}")
end
end
context "from a fork" do
let(:forked_project) { fork_project(project, nil, repository: true) }
......
# frozen_string_literal: true
shared_context 'project with approval rules' do
let(:approver) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public, :repository) }
before do
stub_licensed_features(multiple_approval_rules: true)
[approver, author].each do |member|
project.add_maintainer(member)
end
end
let!(:regular_rules) do
Array.new(3) do |i|
create(:approval_project_rule, project: project, users: [approver], name: "Regular Rule #{i}")
end
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