From 1afef88925d999c0c2622caee251663ba9c38fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Geonizeli?= Date: Mon, 28 Feb 2022 17:39:06 -0300 Subject: [PATCH] use json as default response format --- config/routes.rb | 8 +++++--- spec/routing/posts_routing_spec.rb | 6 +++--- spec/routing/user_follows_routing_spec.rb | 4 ++-- spec/routing/users_routing_spec.rb | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 04a1cd9..8f01daa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do - resources :posts, only: [:index, :show, :create] - resources :user_follows, only: [:create, :destroy] - resources :users, only: [:show] + defaults format: :json do + resources :posts, only: [:index, :show, :create] + resources :user_follows, only: [:create, :destroy] + resources :users, only: [:show] + end end diff --git a/spec/routing/posts_routing_spec.rb b/spec/routing/posts_routing_spec.rb index 19482f0..18cbf99 100644 --- a/spec/routing/posts_routing_spec.rb +++ b/spec/routing/posts_routing_spec.rb @@ -3,16 +3,16 @@ require "rails_helper" RSpec.describe PostsController, type: :routing do describe "routing" do it "routes to #index" do - expect(get: "/posts").to route_to("posts#index") + expect(get: "/posts").to route_to("posts#index", format: :json) end it "routes to #show" do - expect(get: "/posts/1").to route_to("posts#show", id: "1") + expect(get: "/posts/1").to route_to("posts#show", id: "1", format: :json) end it "routes to #create" do - expect(post: "/posts").to route_to("posts#create") + expect(post: "/posts").to route_to("posts#create", format: :json) end end end diff --git a/spec/routing/user_follows_routing_spec.rb b/spec/routing/user_follows_routing_spec.rb index bbd2846..481f263 100644 --- a/spec/routing/user_follows_routing_spec.rb +++ b/spec/routing/user_follows_routing_spec.rb @@ -3,11 +3,11 @@ require "rails_helper" RSpec.describe UserFollowsController, type: :routing do describe "routing" do it "routes to #create" do - expect(post: "/user_follows").to route_to("user_follows#create") + expect(post: "/user_follows").to route_to("user_follows#create", format: :json) end it "routes to #destroy" do - expect(delete: "/user_follows/1").to route_to("user_follows#destroy", id: "1") + expect(delete: "/user_follows/1").to route_to("user_follows#destroy", id: "1", format: :json) end end end diff --git a/spec/routing/users_routing_spec.rb b/spec/routing/users_routing_spec.rb index 2efa471..fa3142f 100644 --- a/spec/routing/users_routing_spec.rb +++ b/spec/routing/users_routing_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe UsersController, type: :routing do describe "routing" do it "routes to #show" do - expect(get: "/users/1").to route_to("users#show", id: "1") + expect(get: "/users/1").to route_to("users#show", id: "1", format: :json) end end end