From 82b6a17ca70a20015e654b4a0fdb8aec6d244f95 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 6 Oct 2015 21:41:37 +0200 Subject: [PATCH] Fix ci build routing and few tests Signed-off-by: Dmitriy Zaporozhets --- app/controllers/ci/builds_controller.rb | 8 +++-- app/helpers/builds_helper.rb | 2 +- app/models/ci/build.rb | 2 +- spec/features/ci/builds_spec.rb | 42 ++++++++++++------------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/controllers/ci/builds_controller.rb b/app/controllers/ci/builds_controller.rb index daf3bcf72a9..b0b8b62fced 100644 --- a/app/controllers/ci/builds_controller.rb +++ b/app/controllers/ci/builds_controller.rb @@ -17,7 +17,7 @@ module Ci if params[:return_to] redirect_to URI.parse(params[:return_to]).path else - redirect_to ci_project_build_path(project, build) + redirect_to build_path(build) end end @@ -28,7 +28,7 @@ module Ci def cancel @build.cancel - redirect_to ci_project_build_path(@project, @build) + redirect_to build_path(@build) end protected @@ -44,5 +44,9 @@ module Ci def commit_by_sha @project.commits.find_by(sha: params[:id]) end + + def build_path(build) + namespace_project_build_path(build.gl_project.namespace, build.gl_project, build) + end end end diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index 626f4e2f4c0..1b5a2c31d74 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -8,6 +8,6 @@ module BuildsHelper end def build_url(build) - ci_project_build_url(build.project, build) + namespace_project_build_path(build.gl_project, build.project, build) end end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 3c92710968c..5d17f4418ed 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -144,7 +144,7 @@ module Ci state :canceled, value: 'canceled' end - delegate :sha, :short_sha, :project, + delegate :sha, :short_sha, :project, :gl_project, to: :commit, prefix: false def before_sha diff --git a/spec/features/ci/builds_spec.rb b/spec/features/ci/builds_spec.rb index 07f76e4065c..aa0df59c04d 100644 --- a/spec/features/ci/builds_spec.rb +++ b/spec/features/ci/builds_spec.rb @@ -1,33 +1,31 @@ require 'spec_helper' describe "Builds" do - context :private_project do + before do + login_as(:user) + @commit = FactoryGirl.create :ci_commit + @build = FactoryGirl.create :ci_build, commit: @commit + @gl_project = @commit.project.gl_project + @gl_project.team << [@user, :master] + end + + describe "GET /:project/builds/:id/cancel" do before do - @commit = FactoryGirl.create :ci_commit - @build = FactoryGirl.create :ci_build, commit: @commit - login_as :user - @commit.project.gl_project.team << [@user, :master] + @build.run! + visit cancel_ci_project_build_path(@commit.project, @build) end - describe "GET /:project/builds/:id/cancel" do - before do - @build.run! - visit cancel_ci_project_build_path(@commit.project, @build) - end + it { expect(page).to have_content 'canceled' } + it { expect(page).to have_content 'Retry' } + end - it { expect(page).to have_content 'canceled' } - it { expect(page).to have_content 'Retry' } + describe "POST /:project/builds/:id/retry" do + before do + visit cancel_ci_project_build_path(@commit.project, @build) + click_link 'Retry' end - describe "POST /:project/builds/:id/retry" do - before do - @build.cancel! - visit ci_project_build_path(@commit.project, @build) - click_link 'Retry' - end - - it { expect(page).to have_content 'pending' } - it { expect(page).to have_content 'Cancel' } - end + it { expect(page).to have_content 'pending' } + it { expect(page).to have_content 'Cancel' } end end