fix feature flag for_branch endpoint

This commit is contained in:
Steffen Kötte 2016-03-29 16:51:00 +02:00
parent 69df412aa1
commit 9734e7133f
2 changed files with 6 additions and 4 deletions

View File

@ -2,7 +2,9 @@ module Travis::API::V3
class Services::Cron::ForBranch < Service class Services::Cron::ForBranch < Service
def run! 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 end
end end

View File

@ -11,13 +11,13 @@ describe Travis::API::V3::Services::Cron::ForBranch do
end end
describe "find cron job for branch with feature disabled" do describe "find cron job for branch with feature disabled" do
before { cron }
before { Travis::Features.deactivate_owner(:cron, repo.owner) } before { Travis::Features.deactivate_owner(:cron, repo.owner) }
before { get("/v3/repo/#{repo.id}/branch/#{branch.name}/cron") } before { get("/v3/repo/#{repo.id}/branch/#{branch.name}/cron") }
example { expect(parsed_body).to be == { example { expect(parsed_body).to be == {
"@type" => "error", "@type" => "error",
"error_type" => "not_found", "error_type" => "insufficient_access",
"error_message" => "cron not found (or insufficient access)", "error_message" => "forbidden"
"resource_type" => "cron"
}} }}
end end