Merge branch 'master' into dashboard-master

This commit is contained in:
decabeza
2018-10-19 01:48:37 +02:00
1586 changed files with 126348 additions and 9884 deletions

View File

@@ -28,8 +28,8 @@ feature 'Answers' do
visit admin_question_path(question)
click_link "Add answer"
fill_in "poll_question_answer_title", with: "¿Would you like to reform Central Park?"
fill_in "poll_question_answer_description", with: "Adding more trees, creating a play area..."
fill_in "poll_question_answer_title_en", with: "¿Would you like to reform Central Park?"
fill_in "poll_question_answer_description_en", with: "Adding more trees, creating a play area..."
click_button "Save"
expect(page).to have_content "Answer created successfully"

View File

@@ -75,6 +75,43 @@ feature 'Polls' do
expect(page).not_to have_link('Expired')
end
scenario "Displays icon correctly", :js do
polls = create_list(:poll, 3)
visit polls_path
expect(page).to have_css(".not-logged-in", count: 3)
expect(page).to have_content("You must sign in or sign up to participate")
user = create(:user)
login_as(user)
visit polls_path
expect(page).to have_css(".unverified", count: 3)
expect(page).to have_content("You must verify your account to participate")
poll_district = create(:poll, geozone_restricted: true)
verified = create(:user, :level_two)
login_as(verified)
visit polls_path
expect(page).to have_css(".cant-answer", count: 1)
expect(page).to have_content("This poll is not available on your geozone")
poll_with_question = create(:poll)
question = create(:poll_question, poll: poll_with_question)
answer1 = create(:poll_question_answer, question: question, title: 'Yes')
answer2 = create(:poll_question_answer, question: question, title: 'No')
vote_for_poll_via_web(poll_with_question, question, 'Yes')
visit polls_path
expect(page).to have_css(".already-answer", count: 1)
expect(page).to have_content("You already have participated in this poll")
end
scenario "Poll title link to stats if enabled" do
poll = create(:poll, name: "Poll with stats", stats_enabled: true)
@@ -358,18 +395,12 @@ feature 'Polls' do
end
end
context 'Booth & Website' do
context 'Booth & Website', :with_frozen_time do
let(:poll) { create(:poll, summary: "Summary", description: "Description", starts_at: '2017-12-01', ends_at: '2018-02-01') }
let(:poll) { create(:poll, summary: "Summary", description: "Description") }
let(:booth) { create(:poll_booth) }
let(:officer) { create(:poll_officer) }
before do
allow(Date).to receive(:current).and_return Date.new(2018,1,1)
allow(Date).to receive(:today).and_return Date.new(2018,1,1)
allow(Time).to receive(:current).and_return Time.zone.parse("2018-01-01 12:00:00")
end
scenario 'Already voted on booth cannot vote on website', :js do
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection)

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
feature "Voter" do
context "Origin" do
context "Origin", :with_frozen_time do
let(:poll) { create(:poll, :current) }
let(:question) { create(:poll_question, poll: poll) }
@@ -125,12 +125,18 @@ feature "Voter" do
click_link "Sign out"
login_as user
visit poll_path(poll)
# Time needs to pass between the moment we vote and the moment
# we log in; otherwise the link to vote won't be available.
# It's safe to advance one second because this test isn't
# affected by possible date changes.
travel 1.second do
login_as user
visit poll_path(poll)
within("#poll_question_#{question.id}_answers") do
expect(page).to have_link(answer_yes.title)
expect(page).to have_link(answer_no.title)
within("#poll_question_#{question.id}_answers") do
expect(page).to have_link(answer_yes.title)
expect(page).to have_link(answer_no.title)
end
end
end
end