diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 7bc82fcf0..e8de37aa8 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -39,10 +39,7 @@ class FollowsController < ApplicationController else rate_limiter = RateLimitChecker.new(current_user) if rate_limiter.limit_by_action("follow_account") - render json: { - error: "Daily account follow limit reached!", - status: :too_many_requests - } + render json: { error: "Daily account follow limit reached!" }, status: :too_many_requests return end follow(followable, need_notification: need_notification) diff --git a/spec/requests/follows_create_spec.rb b/spec/requests/follows_create_spec.rb index 80d6b5f5b..5d5055dee 100644 --- a/spec/requests/follows_create_spec.rb +++ b/spec/requests/follows_create_spec.rb @@ -22,17 +22,18 @@ RSpec.describe "Follows #create", type: :request do allow(rate_limit_checker). to receive(:user_today_follow_count). - and_return(501) + and_return(RateLimitChecker.daily_account_follow_limit + 1) allow(RateLimitChecker). to receive(:new). and_return(rate_limit_checker) end - it "raises an error for too many follows in a day" do + it "returns an error for too many follows in a day" do post "/follows", headers: headers, params: follow_payload json_response = JSON.parse(response.body) + expect(response).to have_http_status(:too_many_requests) expect(json_response["error"]).to eq("Daily account follow limit reached!") end end