Skip to content

Commit bc4ba8d

Browse files
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.
1 parent 1d22498 commit bc4ba8d

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

qa/qa/resource/fork.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
module QA
44
module Resource
55
class Fork < Base
6+
attribute :project do
7+
Resource::Project.fabricate! do |resource|
8+
resource.name = push.project.name
9+
resource.path_with_namespace = "#{user.name}/#{push.project.name}"
10+
end
11+
end
12+
613
attribute :push do
714
Repository::ProjectPush.fabricate!
815
end
@@ -37,6 +44,8 @@ def fabricate!
3744
Page::Layout::Banner.perform do |page|
3845
page.has_notice?('The project was successfully forked.')
3946
end
47+
48+
populate(:project)
4049
end
4150
end
4251
end

qa/qa/resource/merge_request_from_fork.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class MergeRequestFromFork < MergeRequest
1111

1212
attribute :push do
1313
Repository::ProjectPush.fabricate! do |resource|
14-
resource.project = fork
14+
resource.project = fork.project
1515
resource.branch_name = fork_branch
1616
resource.file_name = 'file2.txt'
1717
resource.user = fork.user

qa/qa/resource/project.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Project < Base
1212
Group.fabricate!
1313
end
1414

15+
attribute :path_with_namespace do
16+
"#{group.sandbox.path}/#{group.path}/#{name}" if group
17+
end
18+
1519
attribute :repository_ssh_location do
1620
Page::Project::Show.perform do |page|
1721
page.repository_clone_ssh_location
@@ -46,8 +50,14 @@ def fabricate!
4650
end
4751
end
4852

53+
def fabricate_via_api!
54+
resource_web_url(api_get)
55+
rescue ResourceNotFoundError
56+
super
57+
end
58+
4959
def api_get_path
50-
"/projects/#{name}"
60+
"/projects/#{CGI.escape(path_with_namespace)}"
5161
end
5262

5363
def api_post_path

qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ module QA
55
describe 'Merge request creation from fork' do
66
it 'user forks a project, submits a merge request and maintainer merges it' do
77
Runtime::Browser.visit(:gitlab, Page::Main::Login)
8-
Page::Main::Login.act { sign_in_using_credentials }
8+
Page::Main::Login.perform(&:sign_in_using_credentials)
99

1010
merge_request = Resource::MergeRequestFromFork.fabricate! do |merge_request|
1111
merge_request.fork_branch = 'feature-branch'
1212
end
1313

14-
Page::Main::Menu.perform { |main| main.sign_out }
15-
Page::Main::Login.perform { |login| login.sign_in_using_credentials }
14+
Page::Main::Menu.perform(&:sign_out)
15+
Page::Main::Login.perform(&:sign_in_using_credentials)
1616

1717
merge_request.visit!
1818

19-
Page::MergeRequest::Show.perform { |show| show.merge! }
19+
Page::MergeRequest::Show.perform(&:merge!)
2020

2121
expect(page).to have_content('The changes were merged')
2222
end

0 commit comments

Comments
 (0)