Apply rubcop and get tests pass (#76)
Dieser Commit ist enthalten in:
Ursprung
065bc17929
Commit
4edb40e526
91 geänderte Dateien mit 1070 neuen und 1006 gelöschten Zeilen
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
CustomWizard::Engine.routes.draw do
|
||||
get ':wizard_id' => 'wizard#index'
|
||||
put ':wizard_id/skip' => 'wizard#skip'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminController < ::Admin::AdminController
|
||||
before_action :ensure_admin
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminApiController < CustomWizard::AdminController
|
||||
skip_before_action :check_xhr, only: [:redirect]
|
||||
|
||||
|
@ -85,7 +86,7 @@ class CustomWizard::AdminApiController < CustomWizard::AdminController
|
|||
CustomWizard::Api::Authorization.set(params[:name], code: params[:code])
|
||||
CustomWizard::Api::Authorization.get_token(params[:name])
|
||||
|
||||
return redirect_to path('/admin/wizards/apis/' + params[:name])
|
||||
redirect_to path('/admin/wizards/apis/' + params[:name])
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminCustomFieldsController < CustomWizard::AdminController
|
||||
def index
|
||||
render_json_dump(custom_field_list)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminLogsController < CustomWizard::AdminController
|
||||
def index
|
||||
render_serialized(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminManagerController < CustomWizard::AdminController
|
||||
skip_before_action :check_xhr, only: [:export]
|
||||
before_action :get_wizard_ids, except: [:import]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminSubmissionsController < CustomWizard::AdminController
|
||||
skip_before_action :preload_json, :check_xhr, only: [:download]
|
||||
before_action :find_wizard, except: [:index]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||
before_action :find_wizard, only: [:show, :remove]
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::StepsController < ::ApplicationController
|
||||
before_action :ensure_logged_in
|
||||
before_action :ensure_can_update
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::WizardController < ::ApplicationController
|
||||
prepend_view_path(Rails.root.join('plugins', 'discourse-custom-wizard', 'views'))
|
||||
layout 'wizard'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class UpdateWatchCategoriesAction < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
watch_category_wizards = PluginStoreRow.where("
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module CustomWizardCustomFieldPreloader
|
||||
def preload_custom_fields(objects, fields)
|
||||
if objects.present? && cw_fields_enabled?
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module CustomWizardCustomFieldSerializer
|
||||
def attributes(*args)
|
||||
hash = super
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module ExtraLocalesControllerCustomWizard
|
||||
private def valid_bundle?(bundle)
|
||||
super || begin
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module InvitesControllerCustomWizard
|
||||
def path(url)
|
||||
if ::Wizard.user_requires_completion?(@user)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module CustomWizardUsersController
|
||||
def account_created
|
||||
if current_user.present? &&
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module CustomWizardFieldExtension
|
||||
attr_reader :raw,
|
||||
:label,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module CustomWizardStepExtension
|
||||
attr_accessor :title, :description, :key, :permitted, :permitted_message
|
||||
end
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Jobs
|
||||
class ClearAfterTimeWizard < ::Jobs::Base
|
||||
sidekiq_options queue: 'critical'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Jobs
|
||||
class RefreshApiAccessToken < ::Jobs::Base
|
||||
def execute(args)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Jobs
|
||||
class SetAfterTimeWizard < ::Jobs::Base
|
||||
def execute(args)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Action
|
||||
attr_accessor :data,
|
||||
:action,
|
||||
|
@ -465,7 +466,6 @@ class CustomWizard::Action
|
|||
name = keyArr.first
|
||||
end
|
||||
|
||||
|
||||
registered = registered_fields.select { |f| f[:name] == name }
|
||||
if registered.first.present?
|
||||
klass = registered.first[:klass]
|
||||
|
@ -712,7 +712,7 @@ class CustomWizard::Action
|
|||
|
||||
if @log.any?
|
||||
@log.each do |item|
|
||||
log << "; #{item.to_s}"
|
||||
log += "; #{item.to_s}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::ActionResult
|
||||
attr_accessor :success, :handler, :output
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'excon'
|
||||
|
||||
class CustomWizard::Api::Authorization
|
||||
|
@ -106,11 +107,11 @@ class CustomWizard::Api::Authorization
|
|||
|
||||
connection = Excon.new(
|
||||
authorization.token_url,
|
||||
:headers => {
|
||||
headers: {
|
||||
"Content-Type" => "application/x-www-form-urlencoded"
|
||||
},
|
||||
:method => 'GET',
|
||||
:query => URI.encode_www_form(body)
|
||||
method: 'GET',
|
||||
query: URI.encode_www_form(body)
|
||||
)
|
||||
begin
|
||||
result = connection.request()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::Endpoint
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::LogEntry
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Builder
|
||||
attr_accessor :wizard, :updater, :submissions
|
||||
|
||||
|
@ -125,7 +126,7 @@ class CustomWizard::Builder
|
|||
|
||||
if final_step
|
||||
if @wizard.id == @wizard.user.custom_fields['redirect_to_wizard']
|
||||
@wizard.user.custom_fields.delete('redirect_to_wizard');
|
||||
@wizard.user.custom_fields.delete('redirect_to_wizard')
|
||||
@wizard.user.save_custom_fields(true)
|
||||
end
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ class ::CustomWizard::CustomField
|
|||
add_error(I18n.t("#{i18n_key}.unsupported_type", type: value))
|
||||
end
|
||||
|
||||
|
||||
if attr == 'name'
|
||||
unless value.is_a?(String)
|
||||
add_error(I18n.t("#{i18n_key}.name_invalid", name: value))
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Field
|
||||
def self.types
|
||||
@types ||= {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Log
|
||||
include ActiveModel::Serialization
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Mapper
|
||||
attr_accessor :inputs, :data, :user
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::RealtimeValidation::Result
|
||||
attr_accessor :type,
|
||||
:items,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::RealtimeValidation::SimilarTopics
|
||||
attr_accessor :user
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::StepUpdater
|
||||
include ActiveModel::Model
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::TemplateValidator
|
||||
include HasErrors
|
||||
include ActiveModel::Model
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require 'addressable/uri'
|
||||
|
||||
class ::CustomWizard::UpdateValidator
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_dependency 'wizard/step'
|
||||
require_dependency 'wizard/field'
|
||||
require_dependency 'wizard/step_updater'
|
||||
|
@ -177,7 +178,7 @@ class CustomWizard::Wizard
|
|||
def can_access?
|
||||
return false unless user
|
||||
return true if user.admin
|
||||
return permitted? && (multiple_submissions || !completed?)
|
||||
permitted? && (multiple_submissions || !completed?)
|
||||
end
|
||||
|
||||
def reset
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
# name: discourse-custom-wizard
|
||||
# about: Create custom wizards
|
||||
# version: 0.7.0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::AuthorizationSerializer < ::ApplicationSerializer
|
||||
attributes :auth_type,
|
||||
:auth_url,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::BasicEndpointSerializer < ::ApplicationSerializer
|
||||
attributes :id,
|
||||
:name
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::EndpointSerializer < ::ApplicationSerializer
|
||||
attributes :id,
|
||||
:name,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::Api::LogSerializer < ::ApplicationSerializer
|
||||
attributes :log_id,
|
||||
:time,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::ApiSerializer < ::ApplicationSerializer
|
||||
attributes :name,
|
||||
:title,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::BasicApiSerializer < ::ApplicationSerializer
|
||||
attributes :name,
|
||||
:title,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::BasicWizardSerializer < ::ApplicationSerializer
|
||||
attributes :id, :name
|
||||
end
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::CustomFieldSerializer < ApplicationSerializer
|
||||
attributes :id, :klass, :name, :type, :serializers
|
||||
end
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
class CustomWizard::LogSerializer < ApplicationSerializer
|
||||
attributes :message, :date
|
||||
end
|
|
@ -1,2 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
class ::CustomWizard::RealtimeValidation::SimilarTopicsSerializer < ::SimilarTopicSerializer
|
||||
end
|
|
@ -1,5 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Builder do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Field do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Log do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Mapper do
|
||||
|
@ -86,6 +87,8 @@ describe CustomWizard::Mapper do
|
|||
|
||||
it "does not map when one of multiple conditions are not met" do
|
||||
user1.email = "angus@other-email.com"
|
||||
user1.save
|
||||
|
||||
expect(CustomWizard::Mapper.new(
|
||||
inputs: inputs['conditional_multiple_pairs'],
|
||||
data: data,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Template do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::TemplateValidator do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::UpdateValidator do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::Wizard do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../plugin_helper'
|
||||
|
||||
describe ExtraLocalesControllerCustomWizard, type: :request do
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../plugin_helper'
|
||||
|
||||
describe InvitesControllerCustomWizard, type: :request do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
let(:invite) do
|
||||
Invite.invite_by_email("angus@email.com", topic.user, topic)
|
||||
end
|
||||
let(:invite) { Invite.generate(topic.user, email: "angus@mcleod.org", topic: topic) }
|
||||
|
||||
let(:template) do
|
||||
JSON.parse(File.open(
|
||||
"#{Rails.root}/plugins/discourse-custom-wizard/spec/fixtures/wizard.json"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../plugin_helper'
|
||||
|
||||
describe CustomWizardUsersController, type: :request do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../plugin_helper'
|
||||
|
||||
describe CustomWizardFieldExtension do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../plugin_helper'
|
||||
|
||||
describe CustomWizardStepExtension do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../../plugin_helper'
|
||||
|
||||
describe CustomWizard::AdminCustomFieldsController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../../plugin_helper'
|
||||
|
||||
describe CustomWizard::AdminLogsController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../../plugin_helper'
|
||||
|
||||
describe CustomWizard::AdminManagerController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../../plugin_helper'
|
||||
|
||||
describe CustomWizard::AdminSubmissionsController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../../plugin_helper'
|
||||
|
||||
describe CustomWizard::AdminWizardController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe ApplicationController do
|
||||
|
|
|
@ -92,4 +92,3 @@ describe "custom field extensions" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::StepsController do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
require_relative '../../plugin_helper'
|
||||
|
||||
describe CustomWizard::WizardController do
|
||||
|
|
|
@ -32,7 +32,7 @@ describe CustomWizard::FieldSerializer do
|
|||
scope: Guardian.new(user)
|
||||
).as_json
|
||||
expect(json_array[0][:format]).to eq("YYYY-MM-DD")
|
||||
expect(json_array[5][:file_types]).to eq(".jpg,.png")
|
||||
expect(json_array[4][:number]).to eq(5)
|
||||
expect(json_array[3][:number]).to eq(4)
|
||||
expect(json_array[6][:file_types]).to eq(".jpg,.png")
|
||||
end
|
||||
end
|
Laden …
In neuem Issue referenzieren