Skip to content
Browse files

better error message when trying a blank search

  • Loading branch information...
1 parent 9442e8b commit 93c9acbe5ca60cab781f66b3b630793257c3583e @mislav committed
Showing with 12 additions and 1 deletion.
  1. +7 −1 app/controllers/movies_controller.rb
  2. +5 −0 features/search.feature
View
8 app/controllers/movies_controller.rb
@@ -9,7 +9,13 @@ class MoviesController < ApplicationController
def index
if query = params[:q]
- perform_search query
+ if query.present?
+ perform_search query
+ else
+ render 'shared/error', :status => 500, :locals => {
+ error: "You can't enter a blank query; please search for something."
+ }
+ end
elsif @director = params[:director]
@movies = Movie.find(:directors => @director).sort(:year, :desc).page(params[:page])
freshness_from_cursor @movies
View
5 features/search.feature
@@ -12,6 +12,11 @@ Feature: Movie search
Then I should see "Search results for Lepa Brena" in the title
And I should see "No movies found"
+ Scenario: Blank search
+ When I search for ""
+ Then I should see "error" in the title
+ And I should see "You can't enter a blank query"
+
Scenario: One result
Given TMDB returns "black_cat-full.json" for movie details
And Rotten Tomatoes finds nothing by IMDB id

0 comments on commit 93c9acb

Please sign in to comment.
Something went wrong with that request. Please try again.