change error type
This commit is contained in:
parent
98a75e5931
commit
6fb0f7b6ce
|
@ -7,7 +7,7 @@ module Travis::API::V3
|
|||
raise LoginRequired unless access_control.logged_in? or access_control.full_access?
|
||||
raise NotFound unless repository = find(:repository)
|
||||
raise NotFound unless branch = find(:branch, repository)
|
||||
raise ArgumentError, 'interval must be "daily", "weekly" or "monthly"' unless ["daily", "weekly", "monthly"].include?(params["interval"])
|
||||
raise Error.new('Invalid value for interval. Interval must be "daily", "weekly" or "monthly"!', status: 422) unless ["daily", "weekly", "monthly"].include?(params["interval"])
|
||||
access_control.permissions(repository).create_cron!
|
||||
|
||||
if branch.cron
|
||||
|
|
|
@ -55,11 +55,12 @@ describe Travis::API::V3::Services::Cron::Create do
|
|||
describe "creating a cron job with a wrong interval" do
|
||||
before { last_cron }
|
||||
before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) }
|
||||
it "raises an error" do
|
||||
expect {
|
||||
post("/v3/repo/#{repo.id}/branch/#{branch.name}/cron", wrong_options, headers)
|
||||
}.to raise_error(ArgumentError, 'interval must be "daily", "weekly" or "monthly"')
|
||||
end
|
||||
before { post("/v3/repo/#{repo.id}/branch/#{branch.name}/cron", wrong_options, headers) }
|
||||
example { expect(parsed_body).to be == {
|
||||
"@type" => "error",
|
||||
"error_type" => "error",
|
||||
"error_message" => "Invalid value for interval. Interval must be \"daily\", \"weekly\" or \"monthly\"!"
|
||||
}}
|
||||
end
|
||||
|
||||
describe "try creating a cron job without login" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user