madeindjs/api_on_rails

Chapter 3: Build users - namespace nesting in book different from my generated code

notapatch opened this issue · 2 comments

Under: Chapter 3: Build users Listing 11

The book shows UsersControllerTest with no namespace nesting:

Listing 11. test/controllers/api/v1/users_controller_test.rb
#    v------------- THIS BIT 
class UsersControllerTest < ActionDispatch::IntegrationTest
  ...
  ... None generated code. Entered by you.
  ...
end

When I do the generation rails g controller api::v1::users - I get additional namespace of Api::V1 generated:

require 'test_helper'
        V----------- THIS BIT
class Api::V1::UsersControllerTest < ActionDispatch::IntegrationTest
  # test "the truth" do
  #   assert true
  # end
end

However, I did get the same namespace as Listing 12 for the users_controller.rb.

# app/controllers/api/v1/users_controllers.rb

class Api::V1::UsersController < ApplicationController
end

Note: If you make a change then Listing 11 then Listing 14 will need to be changed also.

OK I'm updating all the listings with the correct namespace