Add proper follow-user class to liquid when passed UserDecorator (#20101)

* Add proper follow-user class to liquid

* Adjust test
This commit is contained in:
Ben Halpern 2023-09-13 11:36:21 -04:00 committed by GitHub
parent dfe71c15a1
commit d6d7eeeb59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -186,8 +186,8 @@ module ApplicationHelper
def follow_button(followable, style = "full", classes = "")
return if followable == Users::DeletedUser
user_follow = followable.instance_of?(User) ? "follow-user" : ""
followable_type = followable.class_name
user_follow = followable_type.include?("User") ? "follow-user" : "" # User or UserDecorator
followable_name = followable.name
tag.button(

View file

@ -19,6 +19,11 @@ RSpec.describe UserTag, type: :liquid_tag do
liquid = generate_user_tag(user.username)
expect(liquid.render).to include("<img")
end
it "renders the proper follow button for a user" do
liquid = generate_user_tag(user.username)
expect(liquid.render).to include("follow-user")
end
end
context "when given an invalid username" do