Skip to content

Commit

Permalink
Explicitly skip HAML tests for rails < 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron committed Mar 12, 2022
1 parent 962301b commit 8815444
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/view_component/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Engine < Rails::Engine # :nodoc:

if config_use_gob || env_use_gob
# :nocov:
app.config.view_component.use_global_output_buffer = true
ViewComponent::Base.prepend(ViewComponent::GlobalOutputBuffer)
# :nocov:
end
Expand Down
8 changes: 1 addition & 7 deletions lib/view_component/global_output_buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ def perform_render
end

def output_buffer=(other_buffer)
if @output_buffer && other_buffer
@output_buffer.replace(other_buffer)
else
# :nocov:
@output_buffer = other_buffer
# :nocov:
end
@output_buffer.replace(other_buffer)
end

def with_output_buffer(buf = nil)
Expand Down
2 changes: 2 additions & 0 deletions lib/view_component/output_buffer_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def initialize(initial_buffer = nil)
end

def replace(buffer)
return if self == buffer

@current_buffer = buffer.current
@buffer_stack = buffer.buffer_stack
end
Expand Down
6 changes: 6 additions & 0 deletions test/view_component/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ def test_renders_the_inline_component_using_a_non_standard_located_template
end

def test_renders_an_inline_component_preview_using_a_haml_template
skip if Rails.application.config.view_component.use_global_output_buffer && Rails::VERSION::STRING < '6.1'

get "/rails/view_components/inline_component/with_haml"
assert_select "h1", "Some HAML here"
assert_select "input[name=?]", "name"
Expand All @@ -536,6 +538,8 @@ def test_returns_404_when_preview_does_not_exist
end

def test_renders_a_mix_of_haml_and_erb
skip if Rails.application.config.view_component.use_global_output_buffer && Rails::VERSION::STRING < '6.1'

get "/nested_haml"
assert_response :success
assert_select "p.foo > span.bar > div.baz > article.quux > div.haml-div"
Expand All @@ -550,6 +554,8 @@ def test_raises_an_error_if_the_template_is_not_present_and_the_render_with_temp
end

def test_renders_a_preview_template_using_haml_params_from_url_custom_template_and_locals
skip if Rails.application.config.view_component.use_global_output_buffer && Rails::VERSION::STRING < '6.1'

get "/rails/view_components/inline_component/with_several_options?form_title=Title from params"

assert_select "form" do
Expand Down
2 changes: 2 additions & 0 deletions test/view_component/view_component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def test_renders_slim_template
end

def test_renders_haml_with_html_formatted_slot
skip if Rails.application.config.view_component.use_global_output_buffer && Rails::VERSION::STRING < '6.1'

render_inline(HamlHtmlFormattedSlotComponent.new)

assert_selector("p", text: "HTML Formatted one")
Expand Down

0 comments on commit 8815444

Please sign in to comment.