OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#62103] fixed unit tests
Eric Schuberta8b62ae98a30
diff --git a/modules/storages/spec/components/storages/admin/side_panel/health_notifications_component_spec.rb b/modules/storages/spec/components/storages/admin/side_panel/health_notifications_component_spec.rbindex 100d466c997..6d1100f5485 100644--- a/modules/storages/spec/components/storages/admin/side_panel/health_notifications_component_spec.rb+++ b/modules/storages/spec/components/storages/admin/side_panel/health_notifications_component_spec.rb@@ -30,46 +30,112 @@ require "spec_helper"require_module_spec_helperRSpec.describe Storages::Admin::SidePanel::HealthNotificationsComponent, type: :component do- context "when subscribed to email notifications" do- let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_enabled, :as_automatically_managed) }+ frozen_date_time = Time.zone.local(2023, 11, 28, 1, 2, 3)- before do- render_inline(described_class.new(storage:))- end+ describe "storage without automatically managed project folders" do+ let(:storage) { build_stubbed(:nextcloud_storage, :as_not_automatically_managed) }- it "renders an unsubscribe option with info" do- expect(page).to have_css("input[type=hidden][value='0']", visible: :hidden)- expect(page).to have_test_selector(- "storage-health-notifications-description",- text: "All administrators receive health status email notifications for this storage."- )- expect(page).to have_button("Unsubscribe")+ it "does not render" do+ render_inline described_class.new(storage:)+ expect(page.text).to be_emptyendend- context "when unsubscribed to email notifications" do- let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_disabled, :as_automatically_managed) }-+ describe "storage with automatically managed project folders" dobefore dorender_inline(described_class.new(storage:))end- it "renders an unsubscribe option with info" do- expect(page).to have_css("input[type=hidden][value='1']", visible: :hidden)- expect(page).to have_test_selector(- "storage-health-notifications-description",- text: "Health status email notifications for this storage have been turned off for all administrators."- )- expect(page).to have_button("Subscribe")+ describe "synchronization health report" do+ context "with healthy storage" do+ let(:storage) do+ travel_to(frozen_date_time) do+ create(:nextcloud_storage_with_complete_configuration, :as_healthy)+ end+ end++ it "shows a healthy status" do+ expect(page).to have_test_selector("storage-health-status", text: "Healthy")+ expect(page).to have_test_selector("storage-health-checked-at", text: "Last checked 11/28/2023 01:02 AM")+ end+ end++ context "with storage health pending" do+ let(:storage) do+ travel_to(frozen_date_time) do+ create(:nextcloud_storage_with_complete_configuration)+ end+ end++ it "shows pending label" do+ expect(page).to have_test_selector("storage-health-status", text: "Pending")+ end+ end++ context "with unhealthy storage" do+ let(:storage) do+ travel_to(frozen_date_time) do+ create(:nextcloud_storage_with_complete_configuration, :as_unhealthy)+ end+ end++ it "shows an error status" do+ expect(page).to have_test_selector("storage-health-status", text: "Error")+ expect(page).to have_test_selector("storage-health-error", text: "Error code: description since 11/28/2023 01:02 AM")+ end+ end++ context "with an unhealthy storage with a localized error message" do+ let(:error_text) { I18n.t("services.errors.models.nextcloud_sync_service.unauthorized") }+ let(:storage) do+ travel_to(frozen_date_time) do+ create(:nextcloud_storage_with_complete_configuration, :as_unhealthy, health_reason: error_text)+ end+ end++ it "shows a correctly formatted error message" do+ expect(page).to have_test_selector("storage-health-status", text: "Error")+ expect(page).to have_test_selector("storage-health-error", text: "#{error_text} since 11/28/2023 01:02 AM")+ end+ end++ context "with unhealthy storage, long reason" do+ let(:storage) do+ travel_to(frozen_date_time) do+ create(:nextcloud_storage_with_complete_configuration, :as_unhealthy_long_reason)+ end+ end++ it "shows a formatted error reason" do+ expect(page).to have_test_selector("storage-health-status", text: "Error")+ expect(page).to have_test_selector("storage-health-error",+ text: "Unauthorized: Outbound request not authorized since 11/28/2023 01:02 AM")+ end+ endend- end- context "with non-automatically managed storage" do- let(:storage) { build_stubbed(:nextcloud_storage, :as_not_automatically_managed) }+ describe "email notifications" do+ context "when subscribed to email notifications" do+ let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_enabled, :as_automatically_managed) }- it "does not render" do- render_inline described_class.new(storage:)- expect(page.text).to be_empty+ it "renders an unsubscribe option with info" do+ expect(page).to have_css("input[type=hidden][value='0']", visible: :hidden)+ text = "All administrators receive health status email notifications for this storage."+ expect(page).to have_test_selector("storage-health-notifications-description", text: text)+ expect(page).to have_button("Unsubscribe")+ end+ end++ context "when unsubscribed to email notifications" do+ let(:storage) { build_stubbed(:nextcloud_storage, :with_health_notifications_disabled, :as_automatically_managed) }++ it "renders an unsubscribe option with info" do+ expect(page).to have_css("input[type=hidden][value='1']", visible: :hidden)+ text = "Health status email notifications for this storage have been turned off for all administrators."+ expect(page).to have_test_selector("storage-health-notifications-description", text:)+ expect(page).to have_button("Subscribe")+ end+ endendendenddiff --git a/modules/storages/spec/components/storages/admin/side_panel/health_status_component_spec.rb b/modules/storages/spec/components/storages/admin/side_panel/health_status_component_spec.rbdeleted file mode 100644index a8410af1c0d..00000000000--- a/modules/storages/spec/components/storages/admin/side_panel/health_status_component_spec.rb+++ /dev/null@@ -1,106 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-#-require "spec_helper"-require_module_spec_helper--RSpec.describe Storages::Admin::SidePanel::HealthStatusComponent, type: :component do- frozen_date_time = Time.zone.local(2023, 11, 28, 1, 2, 3)-- subject(:health_status_component) { described_class.new(storage) }-- before do- render_inline(health_status_component)- end-- context "with healthy storage" do- let(:storage) do- travel_to(frozen_date_time) do- create(:nextcloud_storage_with_complete_configuration, :as_healthy)- end- end-- it "shows a healthy status" do- expect(page).to have_test_selector("storage-health-status", text: "Healthy")- expect(page).to have_test_selector("storage-health-checked-at", text: "Last checked 11/28/2023 01:02 AM")- end- end-- context "with storage health pending" do- let(:storage) do- travel_to(frozen_date_time) do- create(:nextcloud_storage_with_complete_configuration)- end- end-- it "shows pending label" do- expect(page).to have_test_selector("storage-health-status", text: "Pending")- end- end-- context "with unhealthy storage" do- let(:storage) do- travel_to(frozen_date_time) do- create(:nextcloud_storage_with_complete_configuration, :as_unhealthy)- end- end-- it "shows an error status" do- expect(page).to have_test_selector("storage-health-status", text: "Error")- expect(page).to have_test_selector("storage-health-error", text: "Error code: description since 11/28/2023 01:02 AM")- end- end-- context "with an unhealthy storage with a localized error message" do- let(:error_text) { I18n.t("services.errors.models.nextcloud_sync_service.unauthorized") }- let(:storage) do- travel_to(frozen_date_time) do- create(:nextcloud_storage_with_complete_configuration, :as_unhealthy, health_reason: error_text)- end- end-- it "shows a correctly formatted error message" do- expect(page).to have_test_selector("storage-health-status", text: "Error")- expect(page).to have_test_selector("storage-health-error", text: "#{error_text} since 11/28/2023 01:02 AM")- end- end-- context "with unhealthy storage, long reason" do- let(:storage) do- travel_to(frozen_date_time) do- create(:nextcloud_storage_with_complete_configuration, :as_unhealthy_long_reason)- end- end-- it "shows a formatted error reason" do- expect(page).to have_test_selector("storage-health-status", text: "Error")- expect(page).to have_test_selector("storage-health-error",- text: "Unauthorized: Outbound request not authorized since 11/28/2023 01:02 AM")- end- end-enddiff --git a/modules/storages/spec/requests/storages/admin/connection_validation_spec.rb b/modules/storages/spec/requests/storages/admin/connection_validation_spec.rbdeleted file mode 100644index 981e4f326df..00000000000--- a/modules/storages/spec/requests/storages/admin/connection_validation_spec.rb+++ /dev/null@@ -1,125 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--require "spec_helper"--RSpec.describe "connection validation", :skip_csrf do- describe "POST /admin/settings/storages/:id/connection_validation/validate_connection" do- let(:storage) { create(:one_drive_storage) }- let(:template_body) do- template = Nokogiri(last_response.body).css("template").first.inner_html- Capybara.string(template)- end- let(:user) { create(:admin) }- let(:validator) do- double = instance_double(Storages::Peripherals::OneDriveConnectionValidator)- allow(double).to receive_messages(validate: validation_result)- double- end-- current_user { user }-- before do- allow(Storages::Peripherals::OneDriveConnectionValidator).to receive(:new).and_return(validator)- end-- subject do- post validate_connection_admin_settings_storage_connection_validation_path(storage.id, format: :turbo_stream)- end-- shared_examples_for "a validation result template" do |show_timestamp:, label:, description:|- it "returns a turbo update template" do- expect(subject.status).to eq(200)-- expect(template_body).to have_test_selector("validation-result--subtitle", text: "Connection validation")-- if show_timestamp- expect(template_body).to have_test_selector("validation-result--timestamp")- else- expect(template_body).not_to have_test_selector("validation-result--timestamp")- end-- if label.present?- expect(template_body).to have_css(".Label", text: label)- else- expect(template_body).to have_no_selector(".Label")- end-- if description.present?- expect(template_body).to have_test_selector("validation-result--description", text: description)- else- expect(template_body).not_to have_test_selector("validation-result--description", text: description)- end- end- end-- context "if the a validation result of type :none (no validation executed) is returned" do- let(:validation_result) do- Storages::ConnectionValidation.new(type: :none,- error_code: :none,- timestamp: Time.current,- description: "not configured")- end-- it_behaves_like "a validation result template", show_timestamp: false, label: nil, description: "not configured"- end-- context "if validator returns an error" do- let(:validation_result) do- Storages::ConnectionValidation.new(type: :error,- error_code: :my_err,- timestamp: Time.current,- description: "An error occurred")- end-- it_behaves_like "a validation result template",- show_timestamp: true, label: "Error", description: "MY_ERR: An error occurred"- end-- context "if validator returns a warning" do- let(:validation_result) do- Storages::ConnectionValidation.new(type: :warning,- error_code: :my_wrn,- timestamp: Time.current,- description: "There is something weird...")- end-- it_behaves_like "a validation result template",- show_timestamp: true, label: "Warning", description: "MY_WRN: There is something weird..."- end-- context "if validator returns a success" do- let(:validation_result) do- Storages::ConnectionValidation.new(type: :healthy, error_code: :none, timestamp: Time.current, description: nil)- end-- it_behaves_like "a validation result template",- show_timestamp: true, label: "Healthy", description: nil- end- end-end