Просмотр исходного кода

Maintenance: Update dependency rubocop-rails to v2.17.3

renovatebot 2 лет назад
Родитель
Сommit
42c3977f1e

+ 1 - 1
Gemfile.lock

@@ -479,7 +479,7 @@ GEM
     rubocop-performance (1.15.1)
       rubocop (>= 1.7.0, < 2.0)
       rubocop-ast (>= 0.4.0)
-    rubocop-rails (2.16.1)
+    rubocop-rails (2.17.3)
       activesupport (>= 4.2.0)
       rack (>= 1.1)
       rubocop (>= 1.33.0, < 2.0)

+ 22 - 22
app/controllers/knowledge_base/answers_controller.rb

@@ -29,6 +29,28 @@ class KnowledgeBase::AnswersController < KnowledgeBase::BaseController
     render json: { id: object.id, assets: assets }, status: :ok
   end
 
+  # overrides show method to return KnowledgeBase::Answer::Translation::Content for the object just created
+  def create
+    clean_params = klass.association_name_to_id_convert(params)
+    clean_params = klass.param_cleanup(clean_params, true)
+
+    # create object
+    object = klass.new(clean_params)
+
+    # set relations
+    object.associations_from_param(params)
+
+    # save object
+    object.save!
+
+    assets = object.assets({})
+
+    contents = object.translations.filter_map(&:content)
+    assets = ApplicationModel::CanAssets.reduce contents, assets
+
+    render json: { id: object.id, assets: assets }, status: :created
+  end
+
   # overrides show method to return KnowledgeBase::Answer::Translation::Content that was just saved
   def update
     object = klass.find(params[:id])
@@ -59,26 +81,4 @@ class KnowledgeBase::AnswersController < KnowledgeBase::BaseController
     render json: { id: object.id, assets: assets }, status: :ok
   end
 
-  # overrides show method to return KnowledgeBase::Answer::Translation::Content for the object just created
-  def create
-    clean_params = klass.association_name_to_id_convert(params)
-    clean_params = klass.param_cleanup(clean_params, true)
-
-    # create object
-    object = klass.new(clean_params)
-
-    # set relations
-    object.associations_from_param(params)
-
-    # save object
-    object.save!
-
-    assets = object.assets({})
-
-    contents = object.translations.filter_map(&:content)
-    assets = ApplicationModel::CanAssets.reduce contents, assets
-
-    render json: { id: object.id, assets: assets }, status: :created
-  end
-
 end

+ 18 - 18
app/controllers/sessions_controller.rb

@@ -5,6 +5,24 @@ class SessionsController < ApplicationController
   skip_before_action :verify_csrf_token, only: %i[show destroy create_omniauth failure_omniauth]
   skip_before_action :user_device_log, only: %i[create_sso]
 
+  def show
+    user = authentication_check_only
+    raise Exceptions::NotAuthorized, 'no valid session' if user.blank?
+
+    # return current session
+    render json: SessionHelper.json_hash(user).merge(config: config_frontend)
+  rescue Exceptions::NotAuthorized => e
+    render json: {
+      error:       e.message,
+      config:      config_frontend,
+      models:      SessionHelper.models,
+      collections: {
+        Locale.to_app_model     => Locale.where(active: true),
+        PublicLink.to_app_model => PublicLink.all,
+      }
+    }
+  end
+
   # "Create" a login, aka "log the user in"
   def create
     user = authenticate_with_password
@@ -37,24 +55,6 @@ class SessionsController < ApplicationController
     redirect_to '/#'
   end
 
-  def show
-    user = authentication_check_only
-    raise Exceptions::NotAuthorized, 'no valid session' if user.blank?
-
-    # return current session
-    render json: SessionHelper.json_hash(user).merge(config: config_frontend)
-  rescue Exceptions::NotAuthorized => e
-    render json: {
-      error:       e.message,
-      config:      config_frontend,
-      models:      SessionHelper.models,
-      collections: {
-        Locale.to_app_model     => Locale.where(active: true),
-        PublicLink.to_app_model => PublicLink.all,
-      }
-    }
-  end
-
   # "Delete" a login, aka "log the user out"
   def destroy
     if %w[test development].include?(Rails.env) && ENV['FAKE_SELENIUM_LOGIN_USER_ID'].present?

+ 1 - 1
app/models/concerns/has_tags.rb

@@ -97,7 +97,7 @@ Model.tag_references('Tag') # [1, 4, ...]
     def tag_references(tag)
       Tag
         .tag_references(tag: tag, object: name)
-        .map { |elem| elem[1] }
+        .pluck(1)
     end
 
 =begin

+ 1 - 3
app/models/ticket/article.rb

@@ -332,9 +332,7 @@ returns
 
   def check_mentions
     begin
-      mention_user_ids = Nokogiri::HTML(body).css('a[data-mention-user-id]').map do |link|
-        link['data-mention-user-id']
-      end
+      mention_user_ids = Nokogiri::HTML(body).css('a[data-mention-user-id]').pluck('data-mention-user-id')
     rescue => e
       Rails.logger.error "Can't parse body '#{body}' as HTML for extracting Mentions."
       Rails.logger.error e

+ 1 - 1
config/initializers/delayed_jobs_ensure_active_job_lock_removal.rb

@@ -3,7 +3,7 @@
 require 'delayed_job'
 
 module Delayed
-  class Job < ::ActiveRecord::Base
+  class Job < ::ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
 
     after_destroy :remove_active_job_lock
 

+ 1 - 1
config/initializers/delayed_jobs_verify_db_connection.rb

@@ -3,7 +3,7 @@
 require 'delayed_job'
 
 module Delayed
-  class Job < ::ActiveRecord::Base
+  class Job < ::ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
 
     def self.recover_from(_error)
       ::ActiveRecord::Base.connection.verify!

+ 1 - 1
lib/sequencer/unit/import/kayako/object_attribute/attribute_type/checkbox.rb

@@ -7,7 +7,7 @@ class Sequencer::Unit::Import::Kayako::ObjectAttribute::AttributeType::Checkbox
     relevant_options = attribute['options'].select { |option| multiple_values.include?(option['id']) }
     value_locales = relevant_options.filter_map { |option| option['values'].detect { |locale_item| locale_item['locale'] == default_language } }
 
-    value_locales.map { |value_locale| value_locale['translation'] }
+    value_locales.pluck('translation')
   end
 
   private

+ 1 - 1
spec/graphql/gql/queries/online_notifications_spec.rb

@@ -31,7 +31,7 @@ RSpec.describe Gql::Queries::OnlineNotifications, type: :graphql do
     end
 
     it 'contains a notification', authenticated_as: :user do
-      returned_ids = gql.result.nodes.map { |elem| elem['id'] }
+      returned_ids = gql.result.nodes.pluck('id')
 
       expect(returned_ids).to contain_exactly(gql.id(notification))
     end

+ 1 - 3
spec/integration/otrs_spec.rb

@@ -32,9 +32,7 @@ RSpec.describe 'OTRS import', integration: true, integration_standalone: true, r
     let(:object_attribute_names) do
       local_objects.select do |local_object|
         local_object[:object] == 'Ticket'
-      end.collect do |local_object|
-        local_object['name']
-      end
+      end.pluck('name')
     end
     let(:expected_object_attribute_names) { %w[vertriebsweg te_test number sugar_crm_remote_no sugar_crm_company_selected_no sugar_crm_company_selection combine title itsm_criticality customer_id itsm_impact itsm_review_required itsm_decision_result organization_id itsm_repair_start_time itsm_recovery_start_time itsm_decision_date itsm_due_date topic_no open_exchange_ticket_number hostname ticket_free_key11 type ticket_free_text11 open_exchange_tn topic zarafa_tn group_id scom_hostname checkbox_example scom_uuid scom_state scom_service location owner_id department customer_location textfeld state_id pending_time priority_id tags] }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов