Replace the 'project/commits/revert.feature' spinach test with an rspec analog

parent 2defc7b9
---
title: Replace the 'project/commits/revert.feature' spinach test with an rspec analog
merge_request: 14325
author: Vitaliy @blackst0ne Klachkov
type: other
@project_commits
Feature: Revert Commits
Background:
Given I sign in as a user
And I own a project
And I visit my project's commits page
@javascript
Scenario: I revert a commit
Given I click on commit link
And I click on the revert button
And I revert the changes directly
Then I should see the revert commit notice
@javascript
Scenario: I revert a commit that was previously reverted
Given I click on commit link
And I click on the revert button
And I revert the changes directly
And I visit my project's commits page
And I click on commit link
And I click on the revert button
And I revert the changes directly
Then I should see a revert error
@javascript
Scenario: I revert a commit in a new merge request
Given I click on commit link
And I click on the revert button
And I revert the changes in a new merge request
Then I should see the new merge request notice
class Spinach::Features::RevertCommits < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include SharedDiffNote
include RepoHelpers
step 'I click on commit link' do
visit project_commit_path(@project, sample_commit.id)
end
step 'I click on the revert button' do
find(".header-action-buttons .dropdown").click
find("a[href='#modal-revert-commit']").click
end
step 'I revert the changes directly' do
page.within('#modal-revert-commit') do
uncheck 'create_merge_request'
click_button 'Revert'
end
end
step 'I should see the revert commit notice' do
page.should have_content('The commit has been successfully reverted.')
end
step 'I should see a revert error' do
page.should have_content('Sorry, we cannot revert this commit automatically.')
end
step 'I revert the changes in a new merge request' do
page.within('#modal-revert-commit') do
click_button 'Revert'
end
end
step 'I should see the new merge request notice' do
page.should have_content('The commit has been successfully reverted. You can now submit a merge request to get this change into the original branch.')
page.should have_content("From revert-#{Commit.truncate_sha(sample_commit.id)} into master")
end
end
require 'spec_helper'
describe 'User reverts a commit', :js do
include RepoHelpers
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:user) { create(:user) }
before do
sign_in(user)
visit(project_commit_path(project, sample_commit.id))
find('.header-action-buttons .dropdown').click
find('a[href="#modal-revert-commit"]').click
end
context 'without creating a new merge request' do
before do
page.within('#modal-revert-commit') do
uncheck('create_merge_request')
click_button('Revert')
end
end
it 'reverts a commit' do
expect(page).to have_content('The commit has been successfully reverted.')
end
it 'does not revert a previously reverted commit' do
# Visit the comment again once it was reverted.
visit project_commit_path(project, sample_commit.id)
find('.header-action-buttons .dropdown').click
find('a[href="#modal-revert-commit"]').click
page.within('#modal-revert-commit') do
uncheck('create_merge_request')
click_button('Revert')
end
expect(page).to have_content('Sorry, we cannot revert this commit automatically.')
end
end
context 'with creating a new merge request' do
it 'reverts a commit' do
page.within('#modal-revert-commit') do
click_button('Revert')
end
expect(page).to have_content('The commit has been successfully reverted. You can now submit a merge request to get this change into the original branch.')
expect(page).to have_content("From revert-#{Commit.truncate_sha(sample_commit.id)} into master")
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