diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb index 9d419b07e53476e43bb673691aed379311afbf68..0aef477811f37cce4f8366220c8ca4a2d7e6c01a 100644 --- a/app/controllers/projects/builds_controller.rb +++ b/app/controllers/projects/builds_controller.rb @@ -4,10 +4,6 @@ class Projects::BuildsController < Projects::ApplicationController before_action :authorize_update_build!, except: [:index, :show, :status] layout 'project' - # Skip authentication for status badge only - skip_before_action :authenticate_user!, :reject_blocked!, :project, - :repository, :authorize_manage_builds!, :build, only: [:badge] - def index @scope = params[:scope] @all_builds = project.builds @@ -51,18 +47,16 @@ class Projects::BuildsController < Projects::ApplicationController redirect_to build_path(build) end - def status - render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) - end - def cancel @build.cancel redirect_to build_path(@build) end - def badge - project = Project.find_with_namespace("#{params[:namespace_id]}/#{params[:project_id]}") + def status + render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) + end + def badge respond_to do |format| format.html { render_404 } format.svg do diff --git a/doc/ci/quick_start/README.md b/doc/ci/quick_start/README.md index 85f46469f81b477741d521463a6d198c87f4c2c4..6598843049e8197b27a6bf450f7098ac664d8957 100644 --- a/doc/ci/quick_start/README.md +++ b/doc/ci/quick_start/README.md @@ -192,8 +192,6 @@ You can access a builds badge image using following link: http://example.gitlab.com/namespace/project/builds/status/branch/badge.svg ``` -Build badge is available for everyone, even if your project is private or internal. - ## Next steps Awesome! You started using CI in GitLab! diff --git a/features/project/builds/badge.feature b/features/project/builds/badge.feature index 64263b2f538410542b9c27d757dc1a35a1850835..9eb34475e680451e2d324fa13f979d7ac6890c10 100644 --- a/features/project/builds/badge.feature +++ b/features/project/builds/badge.feature @@ -1,6 +1,7 @@ Feature: Project Builds Badge Background: - Given project exists in some group namespace + Given I sign in as a user + And I own a project And project has CI enabled And project has a recent build diff --git a/features/steps/project/builds/badge.rb b/features/steps/project/builds/badge.rb index 0ceb4ddcd25d9442e7280a617e983d8f031eb8ad..65f5e0f766fc0faf351a8d44322b140ba75505ba 100644 --- a/features/steps/project/builds/badge.rb +++ b/features/steps/project/builds/badge.rb @@ -1,4 +1,5 @@ class Spinach::Features::ProjectBuildsBadge < Spinach::FeatureSteps + include SharedAuthentication include SharedProject include SharedBuilds include RepoHelpers