Skip to content

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

fixed ical generation spec

Jonas Jabari9fd91bc52e8b
diff --git a/modules/calendar/spec/services/create_ical_service_spec.rb b/modules/calendar/spec/services/create_ical_service_spec.rb
index b73537974e7..faab38d0ddd 100644
--- a/modules/calendar/spec/services/create_ical_service_spec.rb
+++ b/modules/calendar/spec/services/create_ical_service_spec.rb
@@ -63,6 +63,10 @@ describe Calendar::CreateICalService, type: :model do
let(:freezed_date_time) { DateTime.now }
+ let(:formatted_result) do
+ subject.result.gsub("\r\n ", "").gsub("\r", "").gsub("\\n", "\n")
+ end
+
before do
Timecop.freeze(freezed_date_time)
end
@@ -130,8 +134,7 @@ describe Calendar::CreateICalService, type: :model do
END:VCALENDAR
EOICAL
- expect(subject.result.gsub("\r\n ", "").gsub("\r", "").gsub("\\n", "\n"))
- .to eql(expected_ical_string)
+ expect(formatted_result).to eql(expected_ical_string)
end
# rubocop:enable RSpec/ExampleLength
@@ -141,15 +144,6 @@ describe Calendar::CreateICalService, type: :model do
end
describe 'stripped and truncated workpackage description' do
- let(:rich_text_description) do
- <<-STRING
- test **description**\n\n1. **foo**\n2. bar\n3. **baz**\n\nLorem ipsum#{' '}
- dolor<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/4/content">sit#{' '}
- amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore#{' '}
- magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.#{' '}
- Stet clita kasd gubergren, no sea tak
- STRING
- end
let(:work_package_with_rich_text_description) do
create(:work_package, project:,
due_date: Time.zone.today + 7.days, assigned_to: user,
@@ -179,16 +173,16 @@ describe Calendar::CreateICalService, type: :model do
end
it 'strips html tags from the description' do
- expect(subject.result).to include("test description") # no <b> tags
- expect(subject.result).to include("\\nfoo\\nbar\\nbaz") # no <br> tags or <ol> tags
+ expect(formatted_result).to include("test description") # no <b> tags
+ expect(formatted_result).to include("\nfoo\nbar\nbaz") # no <br> tags or <ol> tags
end
it 'strips images from the description' do
- expect(subject.result).to include("test image") # no <img> tags
+ expect(formatted_result).to include("test image") # no <img> tags
end
it 'truncates the description at 250 chars' do
- expect(subject.result).to include("sanctus est ...")
+ expect(formatted_result).to include("sanctus est ...")
end
end
@@ -210,9 +204,6 @@ describe Calendar::CreateICalService, type: :model do
work_package_with_malicious_description
]
end
- let(:formatted_result) do
- subject.result.gsub("\r\n ", "").gsub("\r", "").gsub("\\n", "\n")
- end
it 'escapes malicious workpackage subject values' do
expect(formatted_result).not_to include("<script>alert('Subject');</script>")