Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/helpers/byline_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ def byline(creation, options = {})

# A plain text version of the byline, for when we don't want to deliver a linkified version.
def text_byline(creation, options = {})
only_path = false

if creation.respond_to?(:anonymous?) && creation.anonymous?
anon_byline = t("byline_helper.anonymous_byline")
anon_byline = t("byline_helper.anonymous_with_name_byline_html", pseud_byline: non_anonymous_byline(creation)) if anonymous_with_name?(options, creation)
anon_byline = t("byline_helper.anonymous_with_name_byline_html", pseud_byline: byline_text(creation, only_path, text_only: true)) if anonymous_with_name?(options, creation)
anon_byline
else
only_path = false
byline_text(creation, only_path, text_only: true)
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/helpers/byline_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,18 @@
end
end
end

describe "#text_byline" do
let(:user) { create(:user, login: "Joe") }
let(:work) { create(:work, authors: [user.default_pseud], collections: [create(:anonymous_collection)]) }

before do
allow(helper).to receive(:logged_in_as_admin?).and_return(true)
end

it "includes no links for partially anonymous byline shown to admins" do
expect(helper.text_byline(work)).to_not include("href")
expect(helper.text_byline(work)).to eq("Anonymous [Joe]")
end
end
end
Loading