Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rails6/en/chapter04-athentification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions rails6/en/chapter06-improve-json.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ...
Expand Down Expand Up @@ -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
# ...
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion rails6/en/chapter07-placing-orders.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions rails6/en/chapter08-improve-orders.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.