diff --git a/lib/travis/api/v3/services/cron/for_branch.rb b/lib/travis/api/v3/services/cron/for_branch.rb index 0290e112..cdbc24db 100644 --- a/lib/travis/api/v3/services/cron/for_branch.rb +++ b/lib/travis/api/v3/services/cron/for_branch.rb @@ -2,7 +2,9 @@ module Travis::API::V3 class Services::Cron::ForBranch < Service def run! - query.find_for_branch(find(:branch, find(:repository))) + repo = find(:repository) + raise InsufficientAccess unless Travis::Features.owner_active?(:cron, repo.owner) + query.find_for_branch(find(:branch, repo)) end end end diff --git a/spec/v3/services/cron/for_branch_spec.rb b/spec/v3/services/cron/for_branch_spec.rb index b698ebe1..32b0f76b 100644 --- a/spec/v3/services/cron/for_branch_spec.rb +++ b/spec/v3/services/cron/for_branch_spec.rb @@ -11,13 +11,13 @@ describe Travis::API::V3::Services::Cron::ForBranch do end describe "find cron job for branch with feature disabled" do + before { cron } before { Travis::Features.deactivate_owner(:cron, repo.owner) } before { get("/v3/repo/#{repo.id}/branch/#{branch.name}/cron") } example { expect(parsed_body).to be == { "@type" => "error", - "error_type" => "not_found", - "error_message" => "cron not found (or insufficient access)", - "resource_type" => "cron" + "error_type" => "insufficient_access", + "error_message" => "forbidden" }} end