Files
fizzy/test/helpers/application_helper_test.rb
T
2025-11-17 09:12:40 -05:00

51 lines
1.7 KiB
Ruby

require "test_helper"
class ApplicationHelperTest < ActionView::TestCase
def parse(html)
Nokogiri::HTML::DocumentFragment.parse(html)
end
test "page_title_tag on untenanted page" do
Current.account = nil
assert_select parse(page_title_tag), "title", text: "Fizzy"
end
test "page_title_tag on untenanted page with a page title" do
@page_title = "Holodeck"
Current.account = nil
assert_select parse(page_title_tag), "title", text: "Holodeck | Fizzy"
end
test "page_title_tag on tenanted page when user has a single account" do
Current.session = sessions(:david)
assert_select parse(page_title_tag), "title", text: "Fizzy"
end
test "page_title_tag on tenanted page when user has multiple accounts" do
Current.session = sessions(:david)
other_account = Account.create!(external_account_id: "dangling-tenant", name: "Other Account")
identities(:david).users.create!(account: other_account, name: "David")
assert_select parse(page_title_tag), "title", text: "37signals | Fizzy"
end
test "page_title_tag on tenanted page with a page title when user has a single account" do
Current.session = sessions(:david)
@page_title = "Holodeck"
assert_select parse(page_title_tag), "title", text: "Holodeck | Fizzy"
end
test "page_title_tag on tenanted page with a page title when user has multiple account" do
Current.session = sessions(:david)
other_account = Account.create!(external_account_id: "dangling-tenant", name: "Other Account")
identities(:david).users.create!(account: other_account, name: "David")
@page_title = "Holodeck"
assert_select parse(page_title_tag), "title", text: "Holodeck | 37signals | Fizzy"
end
end