Add missing tests around rendering invalid merge requests (HTML+JSON)

This commit is contained in:
Ash McKenzie 2018-06-05 21:42:18 +10:00
parent a34666e655
commit bbafb85395
2 changed files with 26 additions and 0 deletions

View file

@ -80,6 +80,16 @@ describe Projects::MergeRequestsController do
))
end
end
context "that is invalid" do
let(:merge_request) { create(:invalid_merge_request, target_project: project, source_project: project) }
it "renders merge request page" do
go(format: :html)
expect(response).to be_success
end
end
end
describe 'as json' do
@ -106,6 +116,16 @@ describe Projects::MergeRequestsController do
expect(response).to match_response_schema('entities/merge_request_widget')
end
end
context "that is invalid" do
let(:merge_request) { create(:invalid_merge_request, target_project: project, source_project: project) }
it "renders merge request page" do
go(format: :json)
expect(response).to be_success
end
end
end
describe "as diff" do

View file

@ -54,6 +54,11 @@ FactoryBot.define do
state :opened
end
trait :invalid do
source_branch "feature_one"
target_branch "feature_two"
end
trait :locked do
state :locked
end
@ -98,6 +103,7 @@ FactoryBot.define do
factory :merged_merge_request, traits: [:merged]
factory :closed_merge_request, traits: [:closed]
factory :reopened_merge_request, traits: [:opened]
factory :invalid_merge_request, traits: [:invalid]
factory :merge_request_with_diffs, traits: [:with_diffs]
factory :merge_request_with_diff_notes do
after(:create) do |mr|