diff --git a/rails6/en/chapter04-athentification.adoc b/rails6/en/chapter04-athentification.adoc index e4860ee..34f8902 100644 --- a/rails6/en/chapter04-athentification.adoc +++ b/rails6/en/chapter04-athentification.adoc @@ -238,7 +238,7 @@ Expected response to be a <401: unauthorized>, but was a <204: No Content> That's normal. It's now time implementing the logic to create the JWT token. It is very simple. -.config/routes.rb +.app/controllers/api/v1/tokens_controller.rb [source,ruby] ---- class Api::V1::TokensController < ApplicationController @@ -524,7 +524,7 @@ The solution is quite simple. We will add a `before_action` which will call the Here is the implementation: [source,ruby] -.spec/controllers/api/v1/users_controller_test.rb +.app/controllers/api/v1/users_controller.rb ---- class Api::V1::UsersController < ApplicationController before_action :set_user, only: %i[show update destroy] diff --git a/rails6/en/chapter06-improve-json.adoc b/rails6/en/chapter06-improve-json.adoc index 5b5990e..3998a2b 100644 --- a/rails6/en/chapter06-improve-json.adoc +++ b/rails6/en/chapter06-improve-json.adoc @@ -202,7 +202,7 @@ end There you go. It's no more complicated than that. Let's change our controller a little bit. [source,ruby] -.app/controllers/api/v1/products_controller.rb +.test/controllers/api/v1/products_controller_test.rb ---- class Api::V1::ProductsController < ApplicationController # ... @@ -527,7 +527,7 @@ This addition will add a `relationship` key containing the user's identifier: This allows us correcting our first two assertions. We now want to include attributes of the user who owns the product. To do this we simply need to pass an option `:include` to the _serializer_ instantiated in the _controller_. Then let's do it: [source,ruby] -.app/serializers/product_serializer.rb +.app/controllers/api/v1/products_controller.rb ---- class Api::V1::ProductsController < ApplicationController # ... @@ -593,7 +593,7 @@ Do you understand the principle? We have included user information in the JSON o Let's start with the test: [source,ruby] -.app/controllers/api/v1/users_controller.rb +.test/controllers/api/v1/users_controller_test.rb ---- # ... class Api::V1::UsersControllerTest < ActionDispatch::IntegrationTest diff --git a/rails6/en/chapter07-placing-orders.adoc b/rails6/en/chapter07-placing-orders.adoc index 689c654..c012234 100644 --- a/rails6/en/chapter07-placing-orders.adoc +++ b/rails6/en/chapter07-placing-orders.adoc @@ -236,7 +236,7 @@ Now it is time for the orders controller implementation: [source,bash] ---- -$ rails generate controller api::v1::orders +$ rails generate serializer Order ---- And let's add relationships: @@ -477,6 +477,8 @@ class OrderTest < ActiveSupport::TestCase setup do @order = orders(:one) + @product1 = products(:one) + @product2 = products(:two) end test 'Should set total' do diff --git a/rails6/en/chapter08-improve-orders.adoc b/rails6/en/chapter08-improve-orders.adoc index 203c4d7..88452d0 100644 --- a/rails6/en/chapter08-improve-orders.adoc +++ b/rails6/en/chapter08-improve-orders.adoc @@ -400,15 +400,6 @@ class Order < ApplicationRecord end ---- -And now everything should be nice and green: - -[source,bash] ----- -$ rake test -.......................................... -42 runs, 63 assertions, 0 failures, 0 errors, 0 skips ----- - Let’s commit changes: [source,bash] @@ -501,4 +492,3 @@ $ git merge chapter08 Oh, you're here! Allow me to congratulate you! That's a long way from the first chapter. But you're one step closer. In fact, the next chapter will be the last. So try to make the most of it. The last chapter will focus on the way to optimize the API using paging, caching and background tasks. So buckle up, it's going to be a hectic ride. -