diff --git a/README.md b/README.md index fb85e2b48..588606bba 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,13 @@ The smoke tests live in the file [`test/VideoStoreAPI_smoke_tests.postman_collec 1. Click `Import` in the top left 1. Drag-and-drop the file into the box 1. In the left sidebar, click on the `Collections` tab -1. There should now be an entry for the smoke tests. Hover over it and click the `>` icon for a detail view. +1. There should now be an entry for the smoke tests. Hover over it and click the `>` icon for a detail view. You will notice they are in the format `{{url}}/movies`. `{{url}}` is a key which you can give a value on your computer. +1. To do so go to the Gearbox in the top-right and select `Manage Environments` +![Manage Environments](images/manage-environment.png) +1. Then Select `Add` +![add button](images/add-btn.png) +1. Lastly add a key `url` and value `http://localhost:3000` +![Key & Value](images/key-value.png) 1. Click the blue `Run` button. This will launch the collection runner. 1. In the collection runner, scroll down in the center pane and click the blue `Start Test` button @@ -273,8 +279,7 @@ Fields to return: - `title` - `checkout_date` - `due_date` - + # Reference - [Postman on Environments](https://www.getpostman.com/docs/environments) - \ No newline at end of file diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 3f87378bd..494a81099 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -14,4 +14,15 @@ def index end end + def show + movie = Movie.find_by(title: params[:title]) + if movie + render json: movie.as_json(only: [:title, :overview, :release_date, :inventory]), status: :ok + # add available _inventory + else + #render :not_found = 404 + render status: :not_found, json: { error: "Could not find a movie with the title #{params[:title]}"} + end + end + end diff --git a/config/routes.rb b/config/routes.rb index d3add50a5..f7d1a11a8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,7 @@ get 'movies', to:'movies#index', as: 'movies' # GET /movies, #index - +get 'movies/:title', to:'movies#show', as: 'movie' # GET /movies/:title #show # params: title diff --git a/test/fixtures/movies.yml b/test/fixtures/movies.yml index bf0295bd7..dd696f01a 100644 --- a/test/fixtures/movies.yml +++ b/test/fixtures/movies.yml @@ -1,17 +1,19 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + psycho: title: Psycho - overview: When larcenous real estate clerk Marion Crane + overview: When larcenous real estate clerk Marion Crane goes on the lam with a wad of cash and hopes of starting a new life, she ends up at the notorious Bates Motel, where manager Norman Bates cares for his housebound mother. The place seems quirky, but fineā€¦ until Marion decides to take a shower. release_date: 1960-06-16 inventory: 8 jaws: title: Jaws - overview: An insatiable great white shark + overview: An insatiable great white shark terrorizes the townspeople of Amity Island, The police chief, an oceanographer and a grizzled shark hunter seek to destroy the bloodthirsty beast. + release_date: 1975-06-19 inventory: 6 exorcist: title: The Exorcist - overview: 12-year-old + overview: 12-year-old Regan MacNeil begins to adapt an explicit new personality as strange events befall the local area of Georgetown. Her mother becomes torn between science and superstition in a desperate bid to save her daughter, and ultimately turns to her last hope: Father Damien Karras, a troubled priest who is struggling with his own faith. release_date: 1973-12-26 inventory: 7