Merge pull request #1976 from consul/feature/add_officer_to_poll_voter

Add officer to Poll::Voter
This commit is contained in:
BertoCQ
2017-10-04 02:03:51 +02:00
committed by GitHub
7 changed files with 14 additions and 2 deletions

View File

@@ -13,7 +13,8 @@ class Officing::VotersController < Officing::BaseController
document_number: @user.document_number,
user: @user,
poll: @poll,
origin: "booth")
origin: "booth",
officer: current_user.poll_officer)
@voter.save!
end

View File

@@ -8,6 +8,7 @@ class Poll
belongs_to :geozone
belongs_to :booth_assignment
belongs_to :officer_assignment
belongs_to :officer
validates :poll_id, presence: true
validates :user_id, presence: true

View File

@@ -0,0 +1,5 @@
class AddOfficerToPollVoter < ActiveRecord::Migration
def change
add_column :poll_voters, :officer_id, :integer
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171003212958) do
ActiveRecord::Schema.define(version: 20171003223152) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -752,6 +752,7 @@ ActiveRecord::Schema.define(version: 20171003212958) do
t.integer "officer_assignment_id"
t.integer "user_id"
t.string "origin"
t.integer "officer_id"
end
add_index "poll_voters", ["booth_assignment_id"], name: "index_poll_voters_on_booth_assignment_id", using: :btree

View File

@@ -531,6 +531,7 @@ FactoryGirl.define do
factory :poll_voter, class: 'Poll::Voter' do
poll
association :user, :level_two
association :officer, factory: :poll_officer
origin "web"
trait :from_booth do

View File

@@ -26,6 +26,8 @@ feature 'Voters' do
page.evaluate_script("window.location.reload()")
expect(page).to have_content "Has already participated in this poll"
expect(page).to_not have_button "Confirm vote"
expect(Poll::Voter.last.officer_id).to eq(officer.id)
end
scenario "Already voted", :js do

View File

@@ -51,6 +51,7 @@ describe Poll::Answer do
expect(voter.document_number).to eq(answer.author.document_number)
expect(voter.poll_id).to eq(answer.poll.id)
expect(voter.officer_id).to eq(nil)
end
it "updates a poll_voter with user and poll data" do