Commit c57ac000 authored by Mark Lapierre's avatar Mark Lapierre

Add support for pushing and viewing files

The MR below adds a test for the code owners feature. This adds the
part of those changes specific to CE - the ability to add and view
files in a project.

https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7368
parent 8131b64a
.tree-content-holder.js-tree-content{ 'data-logs-path': @logs_path } .tree-content-holder.js-tree-content{ 'data-logs-path': @logs_path }
.table-holder .table-holder
%table.table#tree-slider{ class: "table_#{@hex_path} tree-table" } %table.table#tree-slider{ class: "table_#{@hex_path} tree-table qa-file-tree" }
%thead %thead
%tr %tr
%th= s_('ProjectFileTree|Name') %th= s_('ProjectFileTree|Name')
......
...@@ -30,6 +30,14 @@ module QA ...@@ -30,6 +30,14 @@ module QA
@directory = dir @directory = dir
end end
def files=(files)
if !files.is_a?(Array) || files.empty?
raise ArgumentError, "Please provide an array of hashes e.g.: [{name: 'file1', content: 'foo'}]"
end
@files = files
end
def fabricate! def fabricate!
Git::Repository.perform do |repository| Git::Repository.perform do |repository|
if ssh_key if ssh_key
...@@ -63,6 +71,10 @@ module QA ...@@ -63,6 +71,10 @@ module QA
@directory.each_child do |f| @directory.each_child do |f|
repository.add_file(f.basename, f.read) if f.file? repository.add_file(f.basename, f.read) if f.file?
end end
elsif @files
@files.each do |f|
repository.add_file(f[:name], f[:content])
end
else else
repository.add_file(file_name, file_content) repository.add_file(file_name, file_content)
end end
......
...@@ -42,6 +42,10 @@ module QA ...@@ -42,6 +42,10 @@ module QA
element :web_ide_button element :web_ide_button
end end
view 'app/views/projects/tree/_tree_content.html.haml' do
element :file_tree
end
def project_name def project_name
find('.qa-project-name').text find('.qa-project-name').text
end end
...@@ -51,6 +55,12 @@ module QA ...@@ -51,6 +55,12 @@ module QA
click_element :new_file_option click_element :new_file_option
end end
def go_to_file(filename)
within_element(:file_tree) do
click_on filename
end
end
def switch_to_branch(branch_name) def switch_to_branch(branch_name)
find_element(:branches_select).click find_element(:branches_select).click
......
# frozen_string_literal: true
describe QA::Factory::Repository::Push do
describe '.files=' do
let(:files) do
[
{
name: 'file.txt',
content: 'foo'
}
]
end
it 'raises an error if files is not an array' do
expect { subject.files = '' }.to raise_error(ArgumentError)
end
it 'raises an error if files is an empty array' do
expect { subject.files = [] }.to raise_error(ArgumentError)
end
it 'does not raise if files is an array' do
expect { subject.files = files }.not_to raise_error
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