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

Remove reduntant ViewComponent spec, it was testing the gem

Dombi Attila709fa8da592f
diff --git a/spec/components/rails_component_spec.rb b/spec/components/rails_component_spec.rb
deleted file mode 100644
index 19207e6a432..00000000000
--- a/spec/components/rails_component_spec.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2023 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'
-
-describe RailsComponent, type: :component do
- let(:controller) { double(ApplicationController) }
- let(:action_view) { ActionView::Base.new(ActionView::LookupContext.new(''), {}, controller) }
- let(:model) { double('model', foo: '<strong>Some HTML here!</strong>') }
- let(:context) do
- { controller: }
- end
- let(:options) do
- { context: }
- end
-
- let(:test_component) do
- component = Class.new(described_class) do
- include ViewComponent::InlineTemplate
-
- property :foo
-
- erb_template <<~ERB
- <%= foo %>
- ERB
-
- def link
- link_to "<strong>HTML</strong>", '/foo/bar'
- end
-
- def content
- content_tag(:div) do
- content_tag(:span) do
- "<script>foo</script>"
- end
- end
- end
- end
-
- component.const_set("TestComponent", component)
- component
- end
-
- let(:component) { test_component.new(model, **options) }
-
- before do
- allow(controller).to receive(:view_context).and_return(action_view)
- end
-
- shared_examples 'uses action_view helpers' do
- describe '#link' do
- subject { component.link }
-
- it 'uses link_to from rails with escaping' do
- expect(subject).to eq %(<a href="/foo/bar">&lt;strong&gt;HTML&lt;/strong&gt;</a>)
- end
- end
-
- describe '#foo' do
- subject { component.call }
-
- it 'escapes the property' do
- render_inline component
- expect(subject).to include "&lt;strong&gt;Some HTML here!&lt;/strong&gt;"
- end
- end
-
- describe '#content' do
- subject { component.content }
-
- it 'uses content_tag from rails with escaping', :aggregate_failures do
- expect(subject).to eq "<div><span>&lt;script&gt;foo&lt;/script&gt;</span></div>"
- end
- end
- end
-
- describe 'delegate to action_view' do
- context 'when action_view set' do
- let(:context) do
- { controller:, action_view: }
- end
-
- it_behaves_like 'uses action_view helpers'
- end
-
- context 'when not set' do
- it_behaves_like 'uses action_view helpers'
- end
- end
-end