From f6f77547d743d9af3ae3c1a908a7a9d34f8256ca Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 1 Dec 2020 08:20:10 +1100 Subject: [PATCH] Use explicit file loading for tests coverage --- coverage/.last_run.json | 2 +- spec/components/custom_wizard/action_spec.rb | 2 +- spec/components/custom_wizard/builder_spec.rb | 2 +- .../custom_wizard/custom_field_spec.rb | 2 +- spec/components/custom_wizard/field_spec.rb | 2 +- spec/components/custom_wizard/log_spec.rb | 2 +- spec/components/custom_wizard/mapper_spec.rb | 2 +- spec/components/custom_wizard/template_spec.rb | 2 +- .../custom_wizard/template_validator_spec.rb | 2 +- .../custom_wizard/update_validator_spec.rb | 2 +- spec/components/custom_wizard/wizard_spec.rb | 2 +- spec/extensions/custom_field_extensions_spec.rb | 2 +- .../extensions/extra_locales_controller_spec.rb | 2 +- spec/extensions/invites_controller_spec.rb | 2 +- spec/extensions/users_controller_spec.rb | 2 +- spec/extensions/wizard_field_spec.rb | 2 +- spec/extensions/wizard_step_spec.rb | 2 +- spec/jobs/clear_after_time_wizard_spec.rb | 2 +- spec/jobs/set_after_time_wizard_spec.rb | 2 +- spec/plugin_helper.rb | 17 +++++++++-------- .../admin/custom_fields_controller_spec.rb | 2 +- .../custom_wizard/admin/logs_controller_spec.rb | 2 +- .../admin/manager_controller_spec.rb | 2 +- .../admin/submissions_controller_spec.rb | 2 +- .../admin/wizard_controller_spec.rb | 2 +- .../application_controller_spec.rb | 2 +- .../custom_field_extensions_spec.rb | 2 +- .../custom_wizard/steps_controller_spec.rb | 2 +- .../custom_wizard/wizard_controller_spec.rb | 2 +- .../basic_wizard_serializer_spec.rb | 2 +- .../custom_field_serializer_spec.rb | 2 +- .../custom_wizard/log_serializer_spec.rb | 2 +- .../wizard_field_serializer_spec.rb | 2 +- .../custom_wizard/wizard_serializer_spec.rb | 2 +- .../custom_wizard/wizard_step_serializer.rb | 2 +- 35 files changed, 43 insertions(+), 42 deletions(-) diff --git a/coverage/.last_run.json b/coverage/.last_run.json index 9671b9f1..95ea134b 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,5 +1,5 @@ { "result": { - "covered_percent": 89.03 + "covered_percent": 89.17 } } diff --git a/spec/components/custom_wizard/action_spec.rb b/spec/components/custom_wizard/action_spec.rb index 890dde12..85b6b18a 100644 --- a/spec/components/custom_wizard/action_spec.rb +++ b/spec/components/custom_wizard/action_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Action do fab!(:user) { Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com", trust_level: TrustLevel[2]) } diff --git a/spec/components/custom_wizard/builder_spec.rb b/spec/components/custom_wizard/builder_spec.rb index e6fc1105..e5a51905 100644 --- a/spec/components/custom_wizard/builder_spec.rb +++ b/spec/components/custom_wizard/builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Builder do fab!(:trusted_user) { diff --git a/spec/components/custom_wizard/custom_field_spec.rb b/spec/components/custom_wizard/custom_field_spec.rb index 71f2bd14..944e6c74 100644 --- a/spec/components/custom_wizard/custom_field_spec.rb +++ b/spec/components/custom_wizard/custom_field_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::CustomField do diff --git a/spec/components/custom_wizard/field_spec.rb b/spec/components/custom_wizard/field_spec.rb index d6d6e61a..295e5137 100644 --- a/spec/components/custom_wizard/field_spec.rb +++ b/spec/components/custom_wizard/field_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Field do before do diff --git a/spec/components/custom_wizard/log_spec.rb b/spec/components/custom_wizard/log_spec.rb index 9c8b570d..d68c6ba1 100644 --- a/spec/components/custom_wizard/log_spec.rb +++ b/spec/components/custom_wizard/log_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Log do before do diff --git a/spec/components/custom_wizard/mapper_spec.rb b/spec/components/custom_wizard/mapper_spec.rb index 4ddbee57..bb87a623 100644 --- a/spec/components/custom_wizard/mapper_spec.rb +++ b/spec/components/custom_wizard/mapper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Mapper do fab!(:user1) { diff --git a/spec/components/custom_wizard/template_spec.rb b/spec/components/custom_wizard/template_spec.rb index 2ccdb3c9..7a862c63 100644 --- a/spec/components/custom_wizard/template_spec.rb +++ b/spec/components/custom_wizard/template_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Template do fab!(:user) { Fabricate(:user) } diff --git a/spec/components/custom_wizard/template_validator_spec.rb b/spec/components/custom_wizard/template_validator_spec.rb index b657af73..1f941675 100644 --- a/spec/components/custom_wizard/template_validator_spec.rb +++ b/spec/components/custom_wizard/template_validator_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::TemplateValidator do fab!(:user) { Fabricate(:user) } diff --git a/spec/components/custom_wizard/update_validator_spec.rb b/spec/components/custom_wizard/update_validator_spec.rb index c8370484..3bceb939 100644 --- a/spec/components/custom_wizard/update_validator_spec.rb +++ b/spec/components/custom_wizard/update_validator_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::UpdateValidator do fab!(:user) { Fabricate(:user) } diff --git a/spec/components/custom_wizard/wizard_spec.rb b/spec/components/custom_wizard/wizard_spec.rb index 10bc3bdf..069b8369 100644 --- a/spec/components/custom_wizard/wizard_spec.rb +++ b/spec/components/custom_wizard/wizard_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::Wizard do fab!(:user) { Fabricate(:user) } diff --git a/spec/extensions/custom_field_extensions_spec.rb b/spec/extensions/custom_field_extensions_spec.rb index de588d95..5abb0bd8 100644 --- a/spec/extensions/custom_field_extensions_spec.rb +++ b/spec/extensions/custom_field_extensions_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "rails_helper" +require_relative '../plugin_helper' describe "custom field extensions" do fab!(:topic) { Fabricate(:topic) } diff --git a/spec/extensions/extra_locales_controller_spec.rb b/spec/extensions/extra_locales_controller_spec.rb index 3fe02be4..4c8f97c8 100644 --- a/spec/extensions/extra_locales_controller_spec.rb +++ b/spec/extensions/extra_locales_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../plugin_helper' describe ExtraLocalesControllerCustomWizard, type: :request do let(:new_user) { Fabricate(:user, trust_level: TrustLevel[0]) } diff --git a/spec/extensions/invites_controller_spec.rb b/spec/extensions/invites_controller_spec.rb index 05fa58a5..affd3760 100644 --- a/spec/extensions/invites_controller_spec.rb +++ b/spec/extensions/invites_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../plugin_helper' describe InvitesControllerCustomWizard, type: :request do fab!(:topic) { Fabricate(:topic) } diff --git a/spec/extensions/users_controller_spec.rb b/spec/extensions/users_controller_spec.rb index 5a219dee..dccee66b 100644 --- a/spec/extensions/users_controller_spec.rb +++ b/spec/extensions/users_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../plugin_helper' describe CustomWizardUsersController, type: :request do let(:template) do diff --git a/spec/extensions/wizard_field_spec.rb b/spec/extensions/wizard_field_spec.rb index d13b3c80..63cbb249 100644 --- a/spec/extensions/wizard_field_spec.rb +++ b/spec/extensions/wizard_field_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../plugin_helper' describe CustomWizardFieldExtension do let(:field_hash) do diff --git a/spec/extensions/wizard_step_spec.rb b/spec/extensions/wizard_step_spec.rb index 7d1fbb68..2075a419 100644 --- a/spec/extensions/wizard_step_spec.rb +++ b/spec/extensions/wizard_step_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../plugin_helper' describe CustomWizardStepExtension do let(:step_hash) do diff --git a/spec/jobs/clear_after_time_wizard_spec.rb b/spec/jobs/clear_after_time_wizard_spec.rb index ec7c8fa6..16e30c2d 100644 --- a/spec/jobs/clear_after_time_wizard_spec.rb +++ b/spec/jobs/clear_after_time_wizard_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../plugin_helper' describe Jobs::ClearAfterTimeWizard do fab!(:user1) { Fabricate(:user) } diff --git a/spec/jobs/set_after_time_wizard_spec.rb b/spec/jobs/set_after_time_wizard_spec.rb index d4939660..81749051 100644 --- a/spec/jobs/set_after_time_wizard_spec.rb +++ b/spec/jobs/set_after_time_wizard_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../plugin_helper' describe Jobs::SetAfterTimeWizard do fab!(:user1) { Fabricate(:user) } diff --git a/spec/plugin_helper.rb b/spec/plugin_helper.rb index 55deb6a2..b54eb60d 100644 --- a/spec/plugin_helper.rb +++ b/spec/plugin_helper.rb @@ -1,10 +1,11 @@ +# frozen_string_literal: true + require 'simplecov' -SimpleCov.configure do - add_filter do |src| - src.filename !~ /discourse-custom-wizard/ || - src.filename =~ /spec/ || - src.filename =~ /db/ || - src.filename =~ /api/ ## API features are currently experimental - end -end \ No newline at end of file +SimpleCov.start do + root "plugins/discourse-custom-wizard" + track_files "plugins/discourse-custom-wizard/**/*.rb" + add_filter { |src| src.filename =~ /(\/spec\/|\/db\/|plugin\.rb|api)/ } +end + +require 'rails_helper' \ No newline at end of file diff --git a/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb b/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb index a4bba7be..2eee457e 100644 --- a/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/custom_fields_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../../plugin_helper' describe CustomWizard::AdminCustomFieldsController do fab!(:admin_user) { Fabricate(:user, admin: true) } diff --git a/spec/requests/custom_wizard/admin/logs_controller_spec.rb b/spec/requests/custom_wizard/admin/logs_controller_spec.rb index 37a83e90..2eefb299 100644 --- a/spec/requests/custom_wizard/admin/logs_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/logs_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../../plugin_helper' describe CustomWizard::AdminLogsController do fab!(:admin_user) { Fabricate(:user, admin: true) } diff --git a/spec/requests/custom_wizard/admin/manager_controller_spec.rb b/spec/requests/custom_wizard/admin/manager_controller_spec.rb index 3912bf35..33113c1b 100644 --- a/spec/requests/custom_wizard/admin/manager_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/manager_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../../plugin_helper' describe CustomWizard::AdminManagerController do fab!(:admin_user) { Fabricate(:user, admin: true) } diff --git a/spec/requests/custom_wizard/admin/submissions_controller_spec.rb b/spec/requests/custom_wizard/admin/submissions_controller_spec.rb index 51628ea2..9edb131b 100644 --- a/spec/requests/custom_wizard/admin/submissions_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/submissions_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../../plugin_helper' describe CustomWizard::AdminSubmissionsController do fab!(:admin_user) {Fabricate(:user, admin: true)} diff --git a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb index d33762e4..13067acd 100644 --- a/spec/requests/custom_wizard/admin/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/admin/wizard_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../../plugin_helper' describe CustomWizard::AdminWizardController do fab!(:admin_user) {Fabricate(:user, admin: true)} diff --git a/spec/requests/custom_wizard/application_controller_spec.rb b/spec/requests/custom_wizard/application_controller_spec.rb index 4c67cc41..866e75a9 100644 --- a/spec/requests/custom_wizard/application_controller_spec.rb +++ b/spec/requests/custom_wizard/application_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe ApplicationController do fab!(:user) { diff --git a/spec/requests/custom_wizard/custom_field_extensions_spec.rb b/spec/requests/custom_wizard/custom_field_extensions_spec.rb index d8c89f14..b93e89d2 100644 --- a/spec/requests/custom_wizard/custom_field_extensions_spec.rb +++ b/spec/requests/custom_wizard/custom_field_extensions_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "rails_helper" +require_relative '../../plugin_helper' describe "custom field extensions" do let!(:topic) { Fabricate(:topic) } diff --git a/spec/requests/custom_wizard/steps_controller_spec.rb b/spec/requests/custom_wizard/steps_controller_spec.rb index 4db3ff3a..a236fd82 100644 --- a/spec/requests/custom_wizard/steps_controller_spec.rb +++ b/spec/requests/custom_wizard/steps_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::StepsController do fab!(:user) { diff --git a/spec/requests/custom_wizard/wizard_controller_spec.rb b/spec/requests/custom_wizard/wizard_controller_spec.rb index a9833381..30032ecc 100644 --- a/spec/requests/custom_wizard/wizard_controller_spec.rb +++ b/spec/requests/custom_wizard/wizard_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::WizardController do fab!(:user) { diff --git a/spec/serializers/custom_wizard/basic_wizard_serializer_spec.rb b/spec/serializers/custom_wizard/basic_wizard_serializer_spec.rb index 0e088e2d..90d5a3a7 100644 --- a/spec/serializers/custom_wizard/basic_wizard_serializer_spec.rb +++ b/spec/serializers/custom_wizard/basic_wizard_serializer_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::BasicWizardSerializer do fab!(:user) { Fabricate(:user) } diff --git a/spec/serializers/custom_wizard/custom_field_serializer_spec.rb b/spec/serializers/custom_wizard/custom_field_serializer_spec.rb index 63725937..e1a2d806 100644 --- a/spec/serializers/custom_wizard/custom_field_serializer_spec.rb +++ b/spec/serializers/custom_wizard/custom_field_serializer_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::CustomFieldSerializer do fab!(:user) { Fabricate(:user) } diff --git a/spec/serializers/custom_wizard/log_serializer_spec.rb b/spec/serializers/custom_wizard/log_serializer_spec.rb index 2ea39871..42dea659 100644 --- a/spec/serializers/custom_wizard/log_serializer_spec.rb +++ b/spec/serializers/custom_wizard/log_serializer_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::LogSerializer do fab!(:user) { Fabricate(:user) } diff --git a/spec/serializers/custom_wizard/wizard_field_serializer_spec.rb b/spec/serializers/custom_wizard/wizard_field_serializer_spec.rb index 02069a9b..1481a19d 100644 --- a/spec/serializers/custom_wizard/wizard_field_serializer_spec.rb +++ b/spec/serializers/custom_wizard/wizard_field_serializer_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::FieldSerializer do fab!(:user) { Fabricate(:user) } diff --git a/spec/serializers/custom_wizard/wizard_serializer_spec.rb b/spec/serializers/custom_wizard/wizard_serializer_spec.rb index 16734f83..21d697ea 100644 --- a/spec/serializers/custom_wizard/wizard_serializer_spec.rb +++ b/spec/serializers/custom_wizard/wizard_serializer_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::WizardSerializer do fab!(:user) { Fabricate(:user) } diff --git a/spec/serializers/custom_wizard/wizard_step_serializer.rb b/spec/serializers/custom_wizard/wizard_step_serializer.rb index 30e8cc5f..d4a35d5d 100644 --- a/spec/serializers/custom_wizard/wizard_step_serializer.rb +++ b/spec/serializers/custom_wizard/wizard_step_serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require_relative '../../plugin_helper' describe CustomWizard::StepSerializer do fab!(:user) { Fabricate(:user) }