Commit bc4ba8d4 authored by Mark Lapierre's avatar Mark Lapierre

Update merge fork test

Now that Resources don't share attributes, Fork doesn't have Project
attributes. That caused the merge fork test to fail because it no
longer had access to repository_http_location via Fork. Rather than
give Fork Project attributes directly, we add a project attribute to
Fork and populate it via the API at the end of the fabricate! method
after the fork has been created via the UI.

We also update the merge fork test to be slightly more concise and
consistent with newer tests by using perform with proc coercion
instead of act or perform with the full block syntax.
parent 1d224982
......@@ -3,6 +3,13 @@
module QA
module Resource
class Fork < Base
attribute :project do
Resource::Project.fabricate! do |resource|
resource.name = push.project.name
resource.path_with_namespace = "#{user.name}/#{push.project.name}"
end
end
attribute :push do
Repository::ProjectPush.fabricate!
end
......@@ -37,6 +44,8 @@ module QA
Page::Layout::Banner.perform do |page|
page.has_notice?('The project was successfully forked.')
end
populate(:project)
end
end
end
......
......@@ -11,7 +11,7 @@ module QA
attribute :push do
Repository::ProjectPush.fabricate! do |resource|
resource.project = fork
resource.project = fork.project
resource.branch_name = fork_branch
resource.file_name = 'file2.txt'
resource.user = fork.user
......
......@@ -12,6 +12,10 @@ module QA
Group.fabricate!
end
attribute :path_with_namespace do
"#{group.sandbox.path}/#{group.path}/#{name}" if group
end
attribute :repository_ssh_location do
Page::Project::Show.perform do |page|
page.repository_clone_ssh_location
......@@ -46,8 +50,14 @@ module QA
end
end
def fabricate_via_api!
resource_web_url(api_get)
rescue ResourceNotFoundError
super
end
def api_get_path
"/projects/#{name}"
"/projects/#{CGI.escape(path_with_namespace)}"
end
def api_post_path
......
......@@ -5,18 +5,18 @@ module QA
describe 'Merge request creation from fork' do
it 'user forks a project, submits a merge request and maintainer merges it' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Page::Main::Login.perform(&:sign_in_using_credentials)
merge_request = Resource::MergeRequestFromFork.fabricate! do |merge_request|
merge_request.fork_branch = 'feature-branch'
end
Page::Main::Menu.perform { |main| main.sign_out }
Page::Main::Login.perform { |login| login.sign_in_using_credentials }
Page::Main::Menu.perform(&:sign_out)
Page::Main::Login.perform(&:sign_in_using_credentials)
merge_request.visit!
Page::MergeRequest::Show.perform { |show| show.merge! }
Page::MergeRequest::Show.perform(&:merge!)
expect(page).to have_content('The changes were merged')
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