Commit de14e9c2 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'replace_project_merge_requests_accept.feature' into 'master'

Replace the 'project/merge_requests/accept.feature' spinach test with an rspec analog

See merge request !14176
parents 73a913f2 da31584d
---
title: Replace the 'project/merge_requests/accept.feature' spinach test with an rspec analog
merge_request: 14176
author: Vitaliy @blackst0ne Klachkov
type: other
@project_merge_requests
Feature: Project Merge Requests Acceptance
Background:
Given There is an open Merge Request
And I am signed in as a developer of the project
@javascript
Scenario: Accepting the Merge Request and removing the source branch
Given I am on the Merge Request detail page
When I check the "Remove source branch" option
And I click on Accept Merge Request
Then I should see merge request merged
And I should not see the Remove Source Branch button
@javascript
Scenario: Accepting the Merge Request when URL has an anchor
Given I am on the Merge Request detail with note anchor page
When I check the "Remove source branch" option
And I click on Accept Merge Request
Then I should see merge request merged
And I should not see the Remove Source Branch button
@javascript
Scenario: Accepting the Merge Request without removing the source branch
Given I am on the Merge Request detail page
When I click on Accept Merge Request
Then I should see merge request merged
And I should see the Remove Source Branch button
class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
include LoginHelpers
include WaitForRequests
step 'I am on the Merge Request detail page' do
visit merge_request_path(@merge_request)
end
step 'I am on the Merge Request detail with note anchor page' do
visit merge_request_path(@merge_request, anchor: 'note_123')
end
step 'I uncheck the "Remove source branch" option' do
uncheck('Remove source branch')
end
step 'I check the "Remove source branch" option' do
check('Remove source branch')
end
step 'I click on Accept Merge Request' do
click_button('Merge')
end
step 'I should see the Remove Source Branch button' do
expect(page).to have_selector('.js-remove-branch-button')
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_requests
end
step 'I should not see the Remove Source Branch button' do
expect(page).not_to have_selector('.js-remove-branch-button')
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_requests
end
step 'There is an open Merge Request' do
@user = create(:user)
@project = create(:project, :public, :repository)
@project_member = create(:project_member, :developer, user: @user, project: @project)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end
step 'I am signed in as a developer of the project' do
sign_in(@user)
end
step 'I should see merge request merged' do
expect(page).to have_content('The changes were merged into')
end
end
require 'spec_helper'
describe 'User accepts a merge request', :js do
let(:merge_request) { create(:merge_request, :with_diffs, :simple, source_project: project) }
let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) }
before do
project.add_developer(user)
sign_in(user)
end
context 'with removing the source branch' do
before do
visit(merge_request_path(merge_request))
end
it 'accepts a merge request' do
check('Remove source branch')
click_button('Merge')
expect(page).to have_content('The changes were merged into')
expect(page).not_to have_selector('.js-remove-branch-button')
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run.
wait_for_requests
end
end
context 'without removing the source branch' do
before do
visit(merge_request_path(merge_request))
end
it 'accepts a merge request' do
click_button('Merge')
expect(page).to have_content('The changes were merged into')
expect(page).to have_selector('.js-remove-branch-button')
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_requests
end
end
context 'when a URL has an anchor' do
before do
visit(merge_request_path(merge_request, anchor: 'note_123'))
end
it 'accepts a merge request' do
check('Remove source branch')
click_button('Merge')
expect(page).to have_content('The changes were merged into')
expect(page).not_to have_selector('.js-remove-branch-button')
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_requests
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