Skip to content

Commit 70bf1a8

Browse files
committed
Fix trailing whitespace linting issues in ViewComponents
1 parent 10f7efb commit 70bf1a8

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

app/components/navbar_component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
class NavbarComponent < ViewComponent::Base
22
include ActionView::Helpers::TranslationHelper
3-
3+
44
def initialize(current_user: nil)
55
@current_user = current_user
66
end
7-
7+
88
def user_signed_in?
99
@current_user.present?
1010
end
11-
11+
1212
# Helper method to safely generate URLs in tests and production
1313
def locale_url(locale)
1414
if helpers.respond_to?(:url_for)

test/components/flash_component_test.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,45 @@ def test_component_renders_nothing_when_flash_is_empty
55
component = FlashComponent.new(flash: {})
66
assert_equal false, component.render?
77
end
8-
8+
99
def test_component_renders_notice_flash
1010
flash = ActionDispatch::Flash::FlashHash.new
1111
flash[:notice] = "Test notice message"
12-
12+
1313
component = FlashComponent.new(flash: flash)
1414
render_inline(component)
15-
15+
1616
assert_selector ".border-green-200.bg-green-50.text-green-800", text: "Test notice message"
1717
end
18-
18+
1919
def test_component_renders_alert_flash
2020
flash = ActionDispatch::Flash::FlashHash.new
2121
flash[:alert] = "Test alert message"
22-
22+
2323
component = FlashComponent.new(flash: flash)
2424
render_inline(component)
25-
25+
2626
assert_selector ".border-red-200.bg-red-50.text-red-800", text: "Test alert message"
2727
end
28-
28+
2929
def test_component_renders_other_flash_types
3030
flash = ActionDispatch::Flash::FlashHash.new
3131
flash[:info] = "Test info message"
32-
32+
3333
component = FlashComponent.new(flash: flash)
3434
render_inline(component)
35-
35+
3636
assert_selector ".border-blue-200.bg-blue-50.text-blue-800", text: "Test info message"
3737
end
38-
38+
3939
def test_component_skips_blank_messages
4040
flash = ActionDispatch::Flash::FlashHash.new
4141
flash[:notice] = ""
4242
flash[:alert] = "This should show"
43-
43+
4444
component = FlashComponent.new(flash: flash)
4545
render_inline(component)
46-
46+
4747
assert_no_selector ".border-green-200.bg-green-50.text-green-800"
4848
assert_selector ".border-red-200.bg-red-50.text-red-800", text: "This should show"
4949
end

test/components/navbar_component_test.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,64 @@
22

33
class NavbarComponentTest < ViewComponent::TestCase
44
include ActionView::Helpers::TranslationHelper
5-
5+
66
# Mock the component's helpers method for testing
77
class TestNavbarComponent < NavbarComponent
88
def helpers
99
MockHelpers.new
1010
end
1111
end
12-
12+
1313
# Simple mock for helpers
1414
class MockHelpers
1515
def url_for(options)
1616
"#"
1717
end
18-
18+
1919
def respond_to?(method_name)
2020
method_name == :url_for || super
2121
end
2222
end
23-
23+
2424
setup do
2525
# No setup needed
2626
end
2727

2828
def test_renders_guest_menu_when_not_signed_in
2929
component = TestNavbarComponent.new(current_user: nil)
3030
render_inline(component)
31-
31+
3232
# Guest menu links should be present
3333
assert_link t("nav.sign_in")
3434
assert_link t("nav.sign_up")
35-
35+
3636
# User menu elements should not be present
3737
assert_no_link t("nav.dashboard")
3838
assert_no_text t("nav.signed_in_as")
3939
end
40-
40+
4141
def test_renders_user_menu_when_signed_in
4242
user = User.new(email: "[email protected]")
4343
component = TestNavbarComponent.new(current_user: user)
4444
render_inline(component)
45-
45+
4646
# User menu elements should be present
4747
assert_link t("nav.dashboard")
4848
assert_link t("nav.profile")
4949
assert_link t("nav.sign_out")
50-
50+
5151
# Should show user email
5252
assert_text "[email protected]"
53-
53+
5454
# Guest elements should not be present
5555
assert_no_link t("nav.sign_up")
5656
end
57-
57+
5858
def test_language_dropdown_is_always_present
5959
# Test with user not signed in
6060
component = TestNavbarComponent.new(current_user: nil)
6161
render_inline(component)
62-
62+
6363
# Should show current locale and language options
6464
assert_text I18n.locale.to_s.upcase
6565
assert_text "English (EN)"

0 commit comments

Comments
 (0)