diff --git a/app/components/polls/poll_component.rb b/app/components/polls/poll_component.rb index 92a7b64b4..a1cda60ea 100644 --- a/app/components/polls/poll_component.rb +++ b/app/components/polls/poll_component.rb @@ -9,6 +9,6 @@ class Polls::PollComponent < ApplicationComponent private def dates - I18n.t("polls.dates", open_at: l(poll.starts_at.to_date), closed_at: l(poll.ends_at.to_date)) + t("polls.dates", open_at: l(poll.starts_at.to_date), closed_at: l(poll.ends_at.to_date)) end end diff --git a/spec/components/polls/poll_component_spec.rb b/spec/components/polls/poll_component_spec.rb index 154b8419e..9cd5ea50a 100644 --- a/spec/components/polls/poll_component_spec.rb +++ b/spec/components/polls/poll_component_spec.rb @@ -42,12 +42,25 @@ describe Polls::PollComponent do end end - it "renders the dates inside an HTML tag" do - poll = create(:poll, starts_at: "2015-07-15", ends_at: "2015-07-22") + describe "dates" do + it "renders the dates inside an HTML tag" do + poll = create(:poll, starts_at: "2015-07-15", ends_at: "2015-07-22") - render_inline Polls::PollComponent.new(poll) + render_inline Polls::PollComponent.new(poll) - expect(page).to have_css ".dates", exact_text: "From 2015-07-15 to 2015-07-22" + expect(page).to have_css ".dates", exact_text: "From 2015-07-15 to 2015-07-22" + end + + it "allows customizing the text to display dates" do + poll = create(:poll, starts_at: "2015-07-15", ends_at: "2015-07-22") + create(:i18n_content, key: "polls.dates", value: "Starts someday and finishes who-knows-when") + + render_inline Polls::PollComponent.new(poll) + + expect(page).to have_css ".dates", exact_text: "Starts someday and finishes who-knows-when" + expect(page).not_to have_content "2015-07-15" + expect(page).not_to have_content "2015-07-22" + end end it "shows a link to poll stats if enabled" do