Commit 82b6a17c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix ci build routing and few tests

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 27b75b2b
......@@ -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
......@@ -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
......@@ -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
......
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
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