diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2018-09-25 13:33:48 -0400 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2018-09-25 14:03:57 -0400 |
commit | d8416288d360503bd2f208b62d5dae6df83206e8 (patch) | |
tree | 94c9415f9b859721ae19d4f059e81ca0a94527ef | |
parent | 4ca1afec3534b7e70454bfd99552804c55ca0c83 (diff) | |
download | gitlab-ce-ml-qa-code-owners.tar.gz |
Add support for pushing and viewing filesml-qa-code-owners
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
-rw-r--r-- | app/views/projects/tree/_tree_content.html.haml | 2 | ||||
-rw-r--r-- | qa/qa/factory/repository/push.rb | 12 | ||||
-rw-r--r-- | qa/qa/page/project/show.rb | 10 | ||||
-rw-r--r-- | qa/spec/factory/repository/push_spec.rb | 28 |
4 files changed, 51 insertions, 1 deletions
diff --git a/app/views/projects/tree/_tree_content.html.haml b/app/views/projects/tree/_tree_content.html.haml index 587aeafa82f..5e0523f0b96 100644 --- a/app/views/projects/tree/_tree_content.html.haml +++ b/app/views/projects/tree/_tree_content.html.haml @@ -1,6 +1,6 @@ .tree-content-holder.js-tree-content{ 'data-logs-path': @logs_path } .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 %tr %th= s_('ProjectFileTree|Name') 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 267e7bbc249..b9ba7235b38 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -31,6 +31,10 @@ module QA element :tree_holder, '.tree-holder' end + view 'app/views/projects/tree/_tree_content.html.haml' do + element :file_tree + end + view 'app/presenters/project_presenter.rb' do element :new_file_button, "_('New file')," end @@ -43,6 +47,12 @@ module QA click_on 'New file' 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..cdf5ada8ae8 --- /dev/null +++ b/qa/spec/factory/repository/push_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +describe QA::Factory::Repository::Push do + describe '.files=' do + let(:files) do + [ + { + name: 'file.txt', + content: 'foo' + } + ] + end + + subject { described_class.new } + + 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 |