From 24c0f0d67198c98998514ff657562a599859d2c7 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 1 Jun 2016 09:18:04 +0200 Subject: [PATCH 1/4] Add feature test for accessing MR created from fork --- .../merge_requests/created_from_fork_spec.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 spec/features/merge_requests/created_from_fork_spec.rb diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb new file mode 100644 index 000000000000..c1fdec3a550b --- /dev/null +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +feature 'Merge request created from fork' do + given(:user) { create(:user) } + given(:project) { create(:project, :public) } + given(:fork_project) { create(:project, :public) } + + given!(:merge_request) do + create(:forked_project_link, forked_to_project: fork_project, + forked_from_project: project) + + create(:merge_request, source_project: fork_project, + target_project: project, + description: 'Test merge request') + end + + before do + project.team << [user, :master] + + login_as user + visit namespace_project_merge_request_path(project.namespace, + project, merge_request) + end + + scenario 'user can access merge request' do + expect(page).to have_content 'Test merge request' + end +end -- GitLab From 02cddaea6f51c05b7c86b2dc541350e63301b2e4 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 1 Jun 2016 10:26:33 +0200 Subject: [PATCH 2/4] Add feature specs for pipeline in MR from fork --- .../merge_requests/created_from_fork_spec.rb | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index c1fdec3a550b..edc0bdec3db5 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -9,20 +9,50 @@ create(:forked_project_link, forked_to_project: fork_project, forked_from_project: project) - create(:merge_request, source_project: fork_project, - target_project: project, - description: 'Test merge request') + create(:merge_request_with_diffs, source_project: fork_project, + target_project: project, + description: 'Test merge request') end - before do - project.team << [user, :master] - + background do + fork_project.team << [user, :master] login_as user - visit namespace_project_merge_request_path(project.namespace, - project, merge_request) end scenario 'user can access merge request' do + visit_merge_request(merge_request) + expect(page).to have_content 'Test merge request' end + + context 'pipeline present in source project' do + include WaitForAjax + + given(:pipeline) do + create(:ci_commit_with_two_jobs, project: fork_project, + sha: merge_request.last_commit.id, + ref: merge_request.source_branch) + end + + background { pipeline.create_builds(user) } + + scenario 'user visits a pipelines page', js: true do + visit_merge_request(merge_request) + page.within('.merge-request-tabs') { click_link 'Builds' } + wait_for_ajax + + page.within('table.builds') do + expect(page).to have_content 'rspec' + expect(page).to have_content 'spinach' + end + + expect(find_link('Cancel running')[:href]) + .to include fork_project.path_with_namespace + end + end + + def visit_merge_request(mr) + visit namespace_project_merge_request_path(project.namespace, + project, mr) + end end -- GitLab From d133175b39e7588608d928ca655a2cc0341295f2 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 1 Jun 2016 10:27:53 +0200 Subject: [PATCH 3/4] User internal pipeline to access project in views --- app/views/projects/commit/_ci_commit.html.haml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/projects/commit/_ci_commit.html.haml b/app/views/projects/commit/_ci_commit.html.haml index ce5c550b441c..32ff4d309776 100644 --- a/app/views/projects/commit/_ci_commit.html.haml +++ b/app/views/projects/commit/_ci_commit.html.haml @@ -1,24 +1,24 @@ .row-content-block.build-content.middle-block .pull-right - - if can?(current_user, :update_pipeline, @project) + - if can?(current_user, :update_pipeline, ci_commit.project) - if ci_commit.builds.latest.failed.any?(&:retryable?) - = link_to "Retry failed", retry_namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), class: 'btn btn-grouped btn-primary', method: :post + = link_to "Retry failed", retry_namespace_project_pipeline_path(ci_commit.project.namespace, ci_commit.project, ci_commit.id), class: 'btn btn-grouped btn-primary', method: :post - if ci_commit.builds.running_or_pending.any? - = link_to "Cancel running", cancel_namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), data: { confirm: 'Are you sure?' }, class: 'btn btn-grouped btn-danger', method: :post + = link_to "Cancel running", cancel_namespace_project_pipeline_path(ci_commit.project.namespace, ci_commit.project, ci_commit.id), data: { confirm: 'Are you sure?' }, class: 'btn btn-grouped btn-danger', method: :post .oneline.clearfix - if defined?(pipeline_details) && pipeline_details Pipeline - = link_to "##{ci_commit.id}", namespace_project_pipeline_path(@project.namespace, @project, ci_commit.id), class: "monospace" + = link_to "##{ci_commit.id}", namespace_project_pipeline_path(ci_commit.project.namespace, ci_commit.project, ci_commit.id), class: "monospace" with = pluralize ci_commit.statuses.count(:id), "build" - if ci_commit.ref for - = link_to ci_commit.ref, namespace_project_commits_path(@project.namespace, @project, ci_commit.ref), class: "monospace" + = link_to ci_commit.ref, namespace_project_commits_path(ci_commit.project.namespace, ci_commit.project, ci_commit.ref), class: "monospace" - if defined?(link_to_commit) && link_to_commit for commit - = link_to ci_commit.short_sha, namespace_project_commit_path(@project.namespace, @project, ci_commit.sha), class: "monospace" + = link_to ci_commit.short_sha, namespace_project_commit_path(ci_commit.project.namespace, ci_commit.project, ci_commit.sha), class: "monospace" - if ci_commit.duration in = time_interval_in_words ci_commit.duration @@ -31,7 +31,7 @@ %li= error You can also test your .gitlab-ci.yml in the #{link_to "Lint", ci_lint_path} -- if @project.builds_enabled? && !ci_commit.ci_yaml_file +- if ci_commit.project.builds_enabled? && !ci_commit.ci_yaml_file .bs-callout.bs-callout-warning \.gitlab-ci.yml not found in this commit @@ -45,7 +45,7 @@ %th Tags %th Duration %th Finished at - - if @project.build_coverage_enabled? + - if ci_commit.project.build_coverage_enabled? %th Coverage %th - ci_commit.statuses.stages.each do |stage| -- GitLab From 888e6fad3e78537de2884d738248f2daa1c5958f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 1 Jun 2016 10:37:01 +0200 Subject: [PATCH 4/4] Add Changelog entry for links fix on pipeline page --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index fcaf022b4161..f9d580e715cd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ v 8.9.0 (unreleased) - Add Application Setting to configure Container Registry token expire delay (default 5min) v 8.8.3 + - Fix incorrect links on pipeline page when merge request created from fork - Fix gitlab importer failing to import new projects due to missing credentials - Fix import URL migration not rescuing with the correct Error -- GitLab