Commit 2669fdbe authored by Toon Claes's avatar Toon Claes

Ensure the correct Merge Request button is found

The project was not public and this caused a 404. So the tests were
giving deceiving results.

By searching for the Merge Request button in `#content-body` this
is overcome, and also other Merge Request buttons (e.g. in the
sidebar) are ignored.
parent 0d2c68d5
......@@ -3,16 +3,18 @@ require 'spec_helper'
feature 'Merge Request button', feature: true do
shared_examples 'Merge Request button only shown when allowed' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:forked_project) { create(:project, forked_from_project: project) }
let(:project) { create(:project, :public) }
let(:forked_project) { create(:project, :public, forked_from_project: project) }
context 'not logged in' do
it 'does not show Create Merge Request button' do
visit url
within("#content-body") do
expect(page).not_to have_link(label)
end
end
end
context 'logged in as developer' do
before do
......@@ -28,9 +30,11 @@ feature 'Merge Request button', feature: true do
visit url
within("#content-body") do
expect(page).to have_link(label, href: href)
end
end
end
context 'logged in as non-member' do
before do
......@@ -40,8 +44,10 @@ feature 'Merge Request button', feature: true do
it 'does not show Create Merge Request button' do
visit url
within("#content-body") do
expect(page).not_to have_link(label)
end
end
context 'on own fork of project' do
let(:user) { forked_project.owner }
......@@ -54,11 +60,13 @@ feature 'Merge Request button', feature: true do
visit fork_url
within("#content-body") do
expect(page).to have_link(label, href: href)
end
end
end
end
end
context 'on branches page' do
it_behaves_like 'Merge Request button only shown when allowed' do
......
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