Fix lint errors

This commit is contained in:
Karina Kwiatek 2022-01-24 20:48:36 +01:00 committed by Karina Kwiatek
parent d9ff4d5765
commit 22a66f4d1a
4 changed files with 11 additions and 14 deletions

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "digest"
require "errors" require "errors"
require "use_case/question/create" require "use_case/question/create"
require "use_case/question/create_followers" require "use_case/question/create_followers"
@ -44,18 +43,18 @@ class Ajax::QuestionController < AjaxController
if user_signed_in? && params[:rcpt] == "followers" if user_signed_in? && params[:rcpt] == "followers"
UseCase::Question::CreateFollowers.call( UseCase::Question::CreateFollowers.call(
source_user_id: current_user.id, source_user_id: current_user.id,
content: params[:question], content: params[:question],
author_identifier: AnonymousBlock.get_identifier(request.ip) author_identifier: AnonymousBlock.get_identifier(request.ip)
) )
return return
end end
UseCase::Question::Create.call( UseCase::Question::Create.call(
source_user_id: user_signed_in? ? current_user.id : nil, source_user_id: user_signed_in? ? current_user.id : nil,
target_user_id: params[:rcpt], target_user_id: params[:rcpt],
content: params[:question], content: params[:question],
anonymous: params[:anonymousQuestion], anonymous: params[:anonymousQuestion],
author_identifier: AnonymousBlock.get_identifier(request.ip) author_identifier: AnonymousBlock.get_identifier(request.ip)
) )
end end

View File

@ -42,10 +42,8 @@ module UseCase
raise Errors::BadRequest.new("anonymous must be set to true") raise Errors::BadRequest.new("anonymous must be set to true")
end end
if !target_user.privacy_allow_anonymous_questions && anonymous # The target user does not want questions from strangers
# The target user does not want questions from strangers raise Errors::Forbidden.new("no anonymous questions allowed") if !target_user.privacy_allow_anonymous_questions && anonymous
raise Errors::Forbidden.new("no anonymous questions allowed")
end
end end
def check_blocks def check_blocks
@ -62,7 +60,7 @@ module UseCase
return return
end end
source_user.increment!(:asked_count) source_user.increment(:asked_count)
end end
def filtered?(question) def filtered?(question)

View File

@ -29,7 +29,7 @@ module UseCase
private private
def increment_asked_count def increment_asked_count
source_user.increment!(:asked_count) source_user.increment(:asked_count)
end end
def source_user def source_user

View File

@ -48,7 +48,7 @@ describe Ajax::QuestionController, :ajax_controller, type: :controller do
include_examples "returns the expected response" include_examples "returns the expected response"
end end
shared_examples "enqueues a QuestionWorker job" do |expected_rcpt| shared_examples "enqueues a QuestionWorker job" do |_expected_rcpt|
it "enqueues a QuestionWorker job" do it "enqueues a QuestionWorker job" do
allow(QuestionWorker).to receive(:perform_async) allow(QuestionWorker).to receive(:perform_async)
subject subject