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
Fix TimeTracking components parent class
Alexander Brandon Coles13c5780fd431
diff --git a/modules/costs/app/components/my/time_tracking/list_stats_component.rb b/modules/costs/app/components/my/time_tracking/list_stats_component.rbindex 0de44535c26..3a29937ac02 100644--- a/modules/costs/app/components/my/time_tracking/list_stats_component.rb+++ b/modules/costs/app/components/my/time_tracking/list_stats_component.rb@@ -30,7 +30,7 @@module Mymodule TimeTracking- class ListStatsComponent < OpPrimer::BorderBoxTableComponent+ class ListStatsComponent < ApplicationComponentinclude OpTurbo::Streamableoptions :time_entries, :datediff --git a/modules/costs/app/components/my/time_tracking/list_wrapper_component.rb b/modules/costs/app/components/my/time_tracking/list_wrapper_component.rbindex e56700131b9..9b12168efed 100644--- a/modules/costs/app/components/my/time_tracking/list_wrapper_component.rb+++ b/modules/costs/app/components/my/time_tracking/list_wrapper_component.rb@@ -30,7 +30,7 @@module Mymodule TimeTracking- class ListWrapperComponent < OpPrimer::BorderBoxTableComponent+ class ListWrapperComponent < ApplicationComponentinclude OpTurbo::Streamableoptions :time_entries, :date, :modediff --git a/modules/costs/spec/components/my/time_tracking/list_stats_component_spec.rb b/modules/costs/spec/components/my/time_tracking/list_stats_component_spec.rbnew file mode 100644index 00000000000..694e4dbe550--- /dev/null+++ b/modules/costs/spec/components/my/time_tracking/list_stats_component_spec.rb@@ -0,0 +1,77 @@+# frozen_string_literal: true++#-- 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 "rails_helper"++RSpec.describe My::TimeTracking::ListStatsComponent, type: :component do+ def render_component(...)+ render_inline(described_class.new(...))+ end++ let(:date) { Date.civil(2022, 5, 4) }++ subject(:rendered_component) do+ render_component(time_entries:, date:)+ end++ shared_examples_for "applying an ID" do+ it "applies an ID" do+ expect(rendered_component).to have_element id: "time-entries-list-stats-2022-05-04"+ end+ end++ context "with no time entries" do+ let(:time_entries) { build_list(:time_entry, 0) }++ include_examples "applying an ID"++ it "renders count" do+ expect(rendered_component).to have_primer_text "0 Time entries", color: "muted"+ end++ it "renders sum" do+ expect(rendered_component).to have_text "0h"+ end+ end++ context "with time entries" do+ let(:time_entries) { build_list(:time_entry, 2, hours: 1.325) }++ include_examples "applying an ID"++ it "renders count" do+ expect(rendered_component).to have_primer_text "2 Time entries", color: "muted"+ end++ it "renders sum" do+ expect(rendered_component).to have_text "2h 39m"+ end+ end+enddiff --git a/modules/costs/spec/components/my/time_tracking/list_wrapper_component_spec.rb b/modules/costs/spec/components/my/time_tracking/list_wrapper_component_spec.rbnew file mode 100644index 00000000000..4dd10f35fed--- /dev/null+++ b/modules/costs/spec/components/my/time_tracking/list_wrapper_component_spec.rb@@ -0,0 +1,62 @@+# frozen_string_literal: true++#-- 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 "rails_helper"++RSpec.describe My::TimeTracking::ListWrapperComponent, type: :component do+ def render_component(...)+ render_inline(described_class.new(...))+ end++ let(:date) { Date.civil(2022, 5, 4) }+ let(:mode) { :month }++ subject(:rendered_component) do+ render_component(time_entries:, date:, mode:)+ end++ shared_examples_for "applying an ID" do+ it "applies an ID" do+ expect(rendered_component).to have_element id: "time-entries-list-2022-05-04"+ end+ end++ context "with no time entries" do+ let(:time_entries) { create_list(:time_entry, 0) }++ it_behaves_like "rendering Box", row_count: 1+ end++ context "with time entries" do+ let(:time_entries) { create_list(:time_entry, 2) }++ it_behaves_like "rendering Box", row_count: 2+ end+end