bug: don't 500 when URL is not present
This commit is contained in:
parent
dc06ff4ce6
commit
a000fbf0af
|
@ -335,6 +335,7 @@ class StoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def check_url_dupe
|
||||
raise ActionController::ParameterMissing.new("No URL") unless story_params[:url].present?
|
||||
@story = Story.new(story_params)
|
||||
@story.already_posted_recently?
|
||||
|
||||
|
|
|
@ -56,6 +56,20 @@ describe StoriesController do
|
|||
expect(json.fetch("title")).to eq "some other title"
|
||||
expect(json.fetch("similar_stories").count).to eq(0)
|
||||
end
|
||||
|
||||
it "throws a 400 if there's no URL present" do
|
||||
expect {
|
||||
post :check_url_dupe,
|
||||
format: :json,
|
||||
params: { story: { url: "" } }
|
||||
}.to raise_error(ActionController::ParameterMissing)
|
||||
|
||||
expect {
|
||||
post :check_url_dupe,
|
||||
format: :json,
|
||||
params: { story: {} }
|
||||
}.to raise_error(ActionController::ParameterMissing)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue