From 22a4eb202f3ddf6b946041dc4e7b2e3e18f14630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 4 Dec 2024 19:58:46 +0100 Subject: [PATCH] Don't show day of week when not weekly --- .../side_panel/details_component.html.erb | 2 +- .../side_panel/details_component_spec.rb | 76 +++++++++++++++++++ .../meeting/spec/factories/meeting_factory.rb | 5 +- .../factories/recurring_meeting_factory.rb | 6 -- 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 modules/meeting/spec/components/meetings/side_panel/details_component_spec.rb diff --git a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb b/modules/meeting/app/components/meetings/side_panel/details_component.html.erb index a0cc27b31703..5ea1394963ab 100644 --- a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb +++ b/modules/meeting/app/components/meetings/side_panel/details_component.html.erb @@ -39,7 +39,7 @@ @meeting.recurring_meeting.human_day_of_week end end - end if @meeting.recurring_meeting.frequency != "daily" + end if @meeting.recurring_meeting.frequency_weekly? else if @series.present? details.with_row(mb: 2) do diff --git a/modules/meeting/spec/components/meetings/side_panel/details_component_spec.rb b/modules/meeting/spec/components/meetings/side_panel/details_component_spec.rb new file mode 100644 index 000000000000..709db948fd1d --- /dev/null +++ b/modules/meeting/spec/components/meetings/side_panel/details_component_spec.rb @@ -0,0 +1,76 @@ +# 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 Meetings::SidePanel::DetailsComponent, type: :component do + let(:user) { build_stubbed(:user) } + + subject do + render_inline(described_class.new(meeting:)) + page + end + + before do + login_as(user) + end + + context "with templated meeting and working_days frequency" do + let(:series) do + build_stubbed(:recurring_meeting, + start_time: DateTime.parse("2024-12-04T10:00:00Z"), + frequency: "working_days") + end + let(:meeting) do + build_stubbed(:structured_meeting_template, + recurring_meeting: series) + end + + it "doesn't show the weekday" do + expect(subject).to have_no_text("Wednesday") + end + end + + context "with templated meeting and weekly frequency" do + let(:series) do + build_stubbed(:recurring_meeting, + start_time: DateTime.parse("2024-12-04T10:00:00Z"), + frequency: "weekly") + end + let(:meeting) do + build_stubbed(:structured_meeting_template, + recurring_meeting: series) + end + + it "shows the weekday" do + expect(subject).to have_text("Wednesday") + end + end +end diff --git a/modules/meeting/spec/factories/meeting_factory.rb b/modules/meeting/spec/factories/meeting_factory.rb index 68dd2c14897b..3ec2041df7d2 100644 --- a/modules/meeting/spec/factories/meeting_factory.rb +++ b/modules/meeting/spec/factories/meeting_factory.rb @@ -49,8 +49,9 @@ recurring_meeting after(:build) do |template, evaluator| - template.author = evaluator.recurring_meeting.author - template.project = evaluator.recurring_meeting.project + %w[author project start_time].each do |attr| + template.send(:"#{attr}=", evaluator.recurring_meeting.send(attr)) + end end end end diff --git a/modules/meeting/spec/factories/recurring_meeting_factory.rb b/modules/meeting/spec/factories/recurring_meeting_factory.rb index fc1188dd8430..204860667b8e 100644 --- a/modules/meeting/spec/factories/recurring_meeting_factory.rb +++ b/modules/meeting/spec/factories/recurring_meeting_factory.rb @@ -46,11 +46,5 @@ recurring_meeting.project = project recurring_meeting.template = create(:structured_meeting_template, recurring_meeting:, project:) end - - after(:stub) do |recurring_meeting, evaluator| - project = evaluator.project - recurring_meeting.project = project - recurring_meeting.template = build_stubbed(:structured_meeting_template, recurring_meeting:, project:) - end end end