diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-29 11:04:50 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-07 12:46:23 +0300 |
commit | e8ca579d88703aeeaa64dbf4ac45f73a60181568 (patch) | |
tree | 7b162a264c764f58df8f9a5cadf49da5465180cc /spec/features/merge_requests | |
parent | 7c00b53812895970fdb00cf1d27b059bb15815cd (diff) |
Add a project forks spec helper
The helper creates a fork of a project with all provided attributes,
but skipping the creation of the repository on disk.
Diffstat (limited to 'spec/features/merge_requests')
-rw-r--r-- | spec/features/merge_requests/create_new_mr_from_fork_spec.rb | 18 | ||||
-rw-r--r-- | spec/features/merge_requests/created_from_fork_spec.rb | 17 | ||||
-rw-r--r-- | spec/features/merge_requests/diffs_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/merge_requests/form_spec.rb | 12 |
4 files changed, 32 insertions, 19 deletions
diff --git a/spec/features/merge_requests/create_new_mr_from_fork_spec.rb b/spec/features/merge_requests/create_new_mr_from_fork_spec.rb index e6f827174e2..93c40ff6443 100644 --- a/spec/features/merge_requests/create_new_mr_from_fork_spec.rb +++ b/spec/features/merge_requests/create_new_mr_from_fork_spec.rb @@ -1,9 +1,15 @@ require 'spec_helper' feature 'Creating a merge request from a fork', :js do + include ProjectForksHelper + let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } - let!(:source_project) { ::Projects::ForkService.new(project, user).execute } + let!(:source_project) do + fork_project(project, user, + repository: true, + namespace: user.namespace) + end before do source_project.add_master(user) @@ -49,7 +55,6 @@ feature 'Creating a merge request from a fork', :js do target_project_member = target_project.owner CreateBranchService.new(target_project, target_project_member) .execute('a-brand-new-branch-to-test', 'master') - visit project_new_merge_request_path(source_project) first('.js-target-project').click @@ -66,13 +71,18 @@ feature 'Creating a merge request from a fork', :js do end context 'creating to the source of a fork' do - let(:target_project) { project } + let!(:target_project) { project } it_behaves_like('create merge request to other project') end context 'creating to a sibling of a fork' do - let!(:target_project) { ::Projects::ForkService.new(project, create(:user)).execute } + let!(:target_project) do + other_user = create(:user) + fork_project(project, other_user, + repository: true, + namespace: other_user.namespace) + end it_behaves_like('create merge request to other project') end diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index 09541873f71..f9bc3ee6c58 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -1,21 +1,20 @@ require 'spec_helper' feature 'Merge request created from fork' do + include ProjectForksHelper + given(:user) { create(:user) } given(:project) { create(:project, :public, :repository) } - given(:fork_project) { create(:project, :public, :repository) } + given(:forked_project) { fork_project(project, user, repository: true) } given!(:merge_request) do - create(:forked_project_link, forked_to_project: fork_project, - forked_from_project: project) - - create(:merge_request_with_diffs, source_project: fork_project, + create(:merge_request_with_diffs, source_project: forked_project, target_project: project, description: 'Test merge request') end background do - fork_project.team << [user, :master] + forked_project.team << [user, :master] sign_in user end @@ -31,7 +30,7 @@ feature 'Merge request created from fork' do background do create(:note_on_commit, note: comment, - project: fork_project, + project: forked_project, commit_id: merge_request.commit_shas.first) end @@ -55,7 +54,7 @@ feature 'Merge request created from fork' do context 'source project is deleted' do background do MergeRequests::MergeService.new(project, user).execute(merge_request) - fork_project.destroy! + forked_project.destroy! end scenario 'user can access merge request', js: true do @@ -69,7 +68,7 @@ feature 'Merge request created from fork' do context 'pipeline present in source project' do given(:pipeline) do create(:ci_pipeline, - project: fork_project, + project: forked_project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch) end diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb index f4ba660ca39..ee9bb50a881 100644 --- a/spec/features/merge_requests/diffs_spec.rb +++ b/spec/features/merge_requests/diffs_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' feature 'Diffs URL', js: true do + include ProjectForksHelper + let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } @@ -68,7 +70,7 @@ feature 'Diffs URL', js: true do context 'when editing file' do let(:author_user) { create(:user) } let(:user) { create(:user) } - let(:forked_project) { Projects::ForkService.new(project, author_user).execute } + let(:forked_project) { fork_project(project, author_user, repository: true) } let(:merge_request) { create(:merge_request_with_diffs, source_project: forked_project, target_project: project, author: author_user) } let(:changelog_id) { Digest::SHA1.hexdigest("CHANGELOG") } diff --git a/spec/features/merge_requests/form_spec.rb b/spec/features/merge_requests/form_spec.rb index de98b147d04..758fc9b139d 100644 --- a/spec/features/merge_requests/form_spec.rb +++ b/spec/features/merge_requests/form_spec.rb @@ -1,8 +1,10 @@ require 'rails_helper' describe 'New/edit merge request', :js do + include ProjectForksHelper + let!(:project) { create(:project, :public, :repository) } - let(:fork_project) { create(:project, :repository, forked_from_project: project) } + let(:forked_project) { fork_project(project, nil, repository: true) } let!(:user) { create(:user) } let!(:user2) { create(:user) } let!(:milestone) { create(:milestone, project: project) } @@ -170,16 +172,16 @@ describe 'New/edit merge request', :js do context 'forked project' do before do - fork_project.team << [user, :master] + forked_project.team << [user, :master] sign_in(user) end context 'new merge request' do before do visit project_new_merge_request_path( - fork_project, + forked_project, merge_request: { - source_project_id: fork_project.id, + source_project_id: forked_project.id, target_project_id: project.id, source_branch: 'fix', target_branch: 'master' @@ -238,7 +240,7 @@ describe 'New/edit merge request', :js do context 'edit merge request' do before do merge_request = create(:merge_request, - source_project: fork_project, + source_project: forked_project, target_project: project, source_branch: 'fix', target_branch: 'master' |