Commit 91c64c04 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '52696-raw-diff-patch-requests' into 'master'

Add spec for plain diff/email patch

Closes #52696

See merge request gitlab-org/gitlab-ce!23529
parents 6adb769e 12c358f1
......@@ -28,7 +28,7 @@
= link_to project_tree_path(@project, @commit), class: "btn btn-default append-right-10 d-none d-sm-none d-md-inline" do
#{ _('Browse files') }
.dropdown.inline
%a.btn.btn-default.dropdown-toggle{ data: { toggle: "dropdown" } }
%a.btn.btn-default.dropdown-toggle.qa-options-button{ data: { toggle: "dropdown" } }
%span= _('Options')
= icon('caret-down')
%ul.dropdown-menu.dropdown-menu-right
......@@ -48,8 +48,8 @@
%li.dropdown-header
#{ _('Download') }
- unless @commit.parents.length > 1
%li= link_to s_("DownloadCommit|Email Patches"), project_commit_path(@project, @commit, format: :patch)
%li= link_to s_("DownloadCommit|Plain Diff"), project_commit_path(@project, @commit, format: :diff)
%li= link_to s_("DownloadCommit|Email Patches"), project_commit_path(@project, @commit, format: :patch), class: "qa-email-patches"
%li= link_to s_("DownloadCommit|Plain Diff"), project_commit_path(@project, @commit, format: :diff), class: "qa-plain-diff"
.commit-box{ data: { project_path: project_path(@project) } }
%h3.commit-title
......
......@@ -158,6 +158,10 @@ module QA
autoload :Activity, 'qa/page/project/activity'
autoload :Menu, 'qa/page/project/menu'
module Commit
autoload :Show, 'qa/page/project/commit/show'
end
module Import
autoload :Github, 'qa/page/project/import/github'
end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Commit
class Show < Page::Base
view 'app/views/projects/commit/_commit_box.html.haml' do
element :options_button
element :email_patches
element :plain_diff
end
def select_email_patches
click_element :options_button
click_element :email_patches
end
def select_plain_diff
click_element :options_button
click_element :plain_diff
end
end
end
end
end
end
......@@ -72,9 +72,14 @@ module QA
end
end
def go_to_commit(commit_msg)
within_element(:file_tree) do
click_on commit_msg
end
end
def go_to_new_issue
click_element :new_menu_toggle
click_link 'New issue'
end
......
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Commit data' do
before(:context) do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
@project = Resource::Repository::ProjectPush.fabricate! do |push|
push.file_name = 'README.md'
push.file_content = '# This is a test project'
push.commit_message = 'Add README.md'
end
# first file added has no parent commit, thus no diff data
# add second file to repo to enable diff from initial commit
@commit_message = 'Add second file'
@project.visit!
Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |f|
f.add_name('second')
f.add_content('second file content')
f.add_commit_message(@commit_message)
f.commit_changes
end
end
def view_commit
@project.visit!
Page::Project::Show.perform do |page|
page.go_to_commit(@commit_message)
end
end
def raw_content
find('pre').text
end
it 'user views raw email patch' do
view_commit
Page::Project::Commit::Show.perform(&:select_email_patches)
expect(page).to have_content('From: Administrator <admin@example.com>')
expect(page).to have_content('Subject: [PATCH] Add second file')
expect(page).to have_content('diff --git a/second b/second')
end
it 'user views raw commit diff' do
view_commit
Page::Project::Commit::Show.perform(&:select_plain_diff)
expect(raw_content).to start_with('diff --git a/second b/second')
expect(page).to have_content('+second file content')
end
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