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