Fix lint errors
This commit is contained in:
parent
0ab822c33a
commit
b4e0699e82
|
@ -16,7 +16,7 @@ class Ajax::RelationshipController < AjaxController
|
|||
type: params[:type]
|
||||
)
|
||||
@response[:success] = true
|
||||
@response[:message] = t('messages.friend.create.success')
|
||||
@response[:message] = t("messages.friend.create.success")
|
||||
rescue Errors::Base => e
|
||||
@response[:message] = t(e.locale_tag)
|
||||
ensure
|
||||
|
@ -30,7 +30,7 @@ class Ajax::RelationshipController < AjaxController
|
|||
type: params[:type]
|
||||
)
|
||||
@response[:success] = true
|
||||
@response[:message] = t('messages.friend.create.success')
|
||||
@response[:message] = t("messages.friend.create.success")
|
||||
rescue Errors::Base => e
|
||||
@response[:message] = t(e.locale_tag)
|
||||
ensure
|
||||
|
|
|
@ -59,7 +59,7 @@ class AjaxController < ApplicationController
|
|||
|
||||
@response = {
|
||||
success: false,
|
||||
message: I18n.t('messages.parameter_error', parameter: e.param.capitalize),
|
||||
message: I18n.t("messages.parameter_error", parameter: e.param.capitalize),
|
||||
status: :parameter_error
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ class AjaxController < ApplicationController
|
|||
def build_response
|
||||
@response = {
|
||||
success: false,
|
||||
message: '',
|
||||
status: 'unknown'
|
||||
message: "",
|
||||
status: "unknown"
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ class UserController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def followings
|
||||
@title = 'Following'
|
||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
||||
|
@ -109,6 +110,7 @@ class UserController < ApplicationController
|
|||
format.js { render "show_follow", layout: false }
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def questions
|
||||
@title = 'Questions'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Relationships::Follow < Relationship
|
||||
after_create do
|
||||
Notification.notify target, self
|
||||
|
|
|
@ -21,6 +21,7 @@ class User
|
|||
# Follow an user
|
||||
def follow(target_user)
|
||||
raise Errors::FollowingSelf if target_user == self
|
||||
|
||||
create_relationship(active_follow_relationships, target_user)
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ module User::TimelineMethods
|
|||
|
||||
# @return [Array] the users' timeline
|
||||
def timeline
|
||||
Answer.where('user_id in (?) OR user_id = ?', following_ids, id).order(:created_at).reverse_order.includes(comments: [:user, :smiles], question: [:user], user: [:profile], smiles: [:user])
|
||||
Answer.where("user_id in (?) OR user_id = ?", following_ids, id).order(:created_at).reverse_order.includes(comments: %i[user smiles], question: [:user], user: [:profile], smiles: [:user])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddTypeToRelationships < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
add_column :relationships, :type, :string
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveRelationshipCountersFromUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :users, :follower_count
|
||||
remove_column :users, :friend_count
|
||||
remove_column :users, :follower_count, :integer
|
||||
remove_column :users, :friend_count, :integer
|
||||
end
|
||||
end
|
||||
|
|
|
@ -232,8 +232,8 @@ class Exporter
|
|||
|
||||
def user_stub(user)
|
||||
uobj = {}
|
||||
%i(answered_count asked_count comment_smiled_count commented_count created_at
|
||||
id permanently_banned screen_name smiled_count).each do |f|
|
||||
%i[answered_count asked_count comment_smiled_count commented_count created_at
|
||||
id permanently_banned screen_name smiled_count].each do |f|
|
||||
uobj[f] = user.send f
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'dry-types'
|
||||
require "dry-types"
|
||||
|
||||
module Types
|
||||
include Dry.Types()
|
||||
|
||||
RelationshipTypes = Types::String.enum('follow')
|
||||
RelationshipTypes = Types::String.enum("follow")
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@ module UseCase
|
|||
|
||||
def find_source_user
|
||||
return current_user if current_user.is_a?(::User)
|
||||
|
||||
::User.find_by!(screen_name: current_user)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
raise Errors::UserNotFound
|
||||
|
@ -36,6 +37,7 @@ module UseCase
|
|||
|
||||
def find_target_user
|
||||
return target_user if target_user.is_a?(::User)
|
||||
|
||||
::User.find_by!(screen_name: target_user)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
raise Errors::UserNotFound
|
||||
|
|
|
@ -5,7 +5,7 @@ require "rails_helper"
|
|||
|
||||
describe Ajax::RelationshipController, type: :controller do
|
||||
shared_examples_for "params is empty" do
|
||||
let(:params) { }
|
||||
let(:params) { {} }
|
||||
|
||||
include_examples "ajax does not succeed", "is required"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue