diff --git a/app/views/actions/_share.html.haml b/app/views/actions/_share.html.haml index 85dbdd4e..65daacc2 100644 --- a/app/views/actions/_share.html.haml +++ b/app/views/actions/_share.html.haml @@ -5,5 +5,8 @@ %a.dropdown-item{ href: tumblr_share_url(answer), target: "_blank" } %i.fa.fa-fw.fa-tumblr = t(".tumblr") + %a.dropdown-item{ href: telegram_share_url(answer), target: "_blank" } + %i.fa.fa-fw.fa-telegram + = t(".telegram") %a.dropdown-item{ href: "#", name: "ab-share" } = t(".other") diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index d16c9ce5..ba7a2d65 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -81,6 +81,7 @@ en: share: twitter: "Share on Twitter" tumblr: "Share on Tumblr" + telegram: "Share on Telegram" other: "Share on other apps..." admin: announcement: diff --git a/spec/views/actions/_share.html.haml_spec.rb b/spec/views/actions/_share.html.haml_spec.rb new file mode 100644 index 00000000..16153d1c --- /dev/null +++ b/spec/views/actions/_share.html.haml_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "actions/_share.html.haml", type: :view do + let(:answer) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) } + + subject(:rendered) do + render partial: "actions/share", locals: { + answer:, + } + end + + it "has a dropdown item to share to twitter" do + expect(rendered).to have_css(%(a.dropdown-item[href^="https://twitter.com/"][target="_blank"])) + end + + it "has a dropdown item to share to tumblr" do + expect(rendered).to have_css(%(a.dropdown-item[href^="https://www.tumblr.com/"][target="_blank"])) + end + + it "has a dropdown item to share to telegram" do + expect(rendered).to have_css(%(a.dropdown-item[href^="https://t.me/"][target="_blank"])) + end + + it "has a dropdown item to share to anywhere else" do + expect(rendered).to have_css(%(a.dropdown-item[name="ab-share"])) + end +end