We accidentally introduced a typo in commit f497227e3 which caused the
dates to be rendered outside the element where the dates styles are
applied.
82 lines
2.7 KiB
Ruby
82 lines
2.7 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Polls::PollComponent do
|
|
include Rails.application.routes.url_helpers
|
|
|
|
describe "status message" do
|
|
it "asks anonymous users to sign in" do
|
|
render_inline Polls::PollComponent.new(create(:poll))
|
|
|
|
expect(page).to have_css ".not-logged-in", count: 1
|
|
expect(page).to have_content "You must sign in or sign up to participate"
|
|
end
|
|
|
|
it "asks unverified users to verify their account" do
|
|
sign_in(create(:user))
|
|
|
|
render_inline Polls::PollComponent.new(create(:poll))
|
|
|
|
expect(page).to have_css ".unverified", count: 1
|
|
expect(page).to have_content "You must verify your account to participate"
|
|
end
|
|
|
|
it "tell users from different geozones that the poll isn't available" do
|
|
sign_in(create(:user, :level_two))
|
|
|
|
render_inline Polls::PollComponent.new(create(:poll, geozone_restricted: true))
|
|
|
|
expect(page).to have_css ".cant-answer", count: 1
|
|
expect(page).to have_content "This poll is not available on your geozone"
|
|
end
|
|
|
|
it "informs users when they've already participated" do
|
|
user = create(:user, :level_two)
|
|
poll = create(:poll)
|
|
create(:poll_voter, user: user, poll: poll)
|
|
|
|
sign_in(user)
|
|
render_inline Polls::PollComponent.new(poll)
|
|
|
|
expect(page).to have_css ".already-answer", count: 1
|
|
expect(page).to have_content "You already have participated in this poll"
|
|
end
|
|
end
|
|
|
|
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)
|
|
|
|
expect(page).to have_css ".dates", exact_text: "From 2015-07-15 to 2015-07-22"
|
|
end
|
|
|
|
it "shows a link to poll stats if enabled" do
|
|
poll = create(:poll, :expired, name: "Poll with stats", stats_enabled: true)
|
|
|
|
render_inline Polls::PollComponent.new(poll)
|
|
|
|
expect(page).to have_link "Poll with stats", href: stats_poll_path(poll.slug)
|
|
expect(page).to have_link "Poll ended", href: stats_poll_path(poll.slug)
|
|
end
|
|
|
|
it "shows a link to poll results if enabled" do
|
|
poll = create(:poll, :expired, name: "Poll with results", stats_enabled: true, results_enabled: true)
|
|
|
|
render_inline Polls::PollComponent.new(poll)
|
|
|
|
expect(page).to have_link "Poll with results", href: results_poll_path(poll.slug)
|
|
expect(page).to have_link "Poll ended", href: results_poll_path(poll.slug)
|
|
end
|
|
|
|
it "shows SDG tags when that feature is enabled" do
|
|
Setting["feature.sdg"] = true
|
|
Setting["sdg.process.polls"] = true
|
|
poll = create(:poll, sdg_goals: [SDG::Goal[1]], sdg_targets: [SDG::Target["1.1"]])
|
|
|
|
render_inline Polls::PollComponent.new(poll)
|
|
|
|
expect(page).to have_css "img[alt='1. No Poverty']"
|
|
expect(page).to have_content "target 1.1"
|
|
end
|
|
end
|