summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-10-18 09:46:27 +0000
committerRémy Coutable <remy@rymai.me>2018-10-18 09:46:27 +0000
commit329aa24920d9bf385c244e648db4ab38dd3c23e8 (patch)
tree90c2376f4082189faf2af4c0f2fe18ae6773817d /qa
parent00aebc73ebba79a5291d9ff26d628c5bd6010a90 (diff)
parentc57ac000067b73640033a359267dbacf57e7d2d0 (diff)
downloadgitlab-ce-329aa24920d9bf385c244e648db4ab38dd3c23e8.tar.gz
Merge branch 'ml-qa-code-owners' into 'master'
QA: Add support for pushing and viewing files See merge request gitlab-org/gitlab-ce!21911
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/factory/repository/push.rb12
-rw-r--r--qa/qa/page/project/show.rb10
-rw-r--r--qa/spec/factory/repository/push_spec.rb26
3 files changed, 48 insertions, 0 deletions
diff --git a/qa/qa/factory/repository/push.rb b/qa/qa/factory/repository/push.rb
index 6c5088f1da5..703c78daa99 100644
--- a/qa/qa/factory/repository/push.rb
+++ b/qa/qa/factory/repository/push.rb
@@ -30,6 +30,14 @@ module QA
@directory = dir
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!
Git::Repository.perform do |repository|
if ssh_key
@@ -63,6 +71,10 @@ module QA
@directory.each_child do |f|
repository.add_file(f.basename, f.read) if f.file?
end
+ elsif @files
+ @files.each do |f|
+ repository.add_file(f[:name], f[:content])
+ end
else
repository.add_file(file_name, file_content)
end
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index fcc4bb79c10..d6dddf03ffb 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -42,6 +42,10 @@ module QA
element :web_ide_button
end
+ view 'app/views/projects/tree/_tree_content.html.haml' do
+ element :file_tree
+ end
+
def project_name
find('.qa-project-name').text
end
@@ -51,6 +55,12 @@ module QA
click_element :new_file_option
end
+ def go_to_file(filename)
+ within_element(:file_tree) do
+ click_on filename
+ end
+ end
+
def switch_to_branch(branch_name)
find_element(:branches_select).click
diff --git a/qa/spec/factory/repository/push_spec.rb b/qa/spec/factory/repository/push_spec.rb
new file mode 100644
index 00000000000..2eb6c008248
--- /dev/null
+++ b/qa/spec/factory/repository/push_spec.rb
@@ -0,0 +1,26 @@
+# 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