fixes specs
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
class Officing::ResidenceController < Officing::BaseController
|
class Officing::ResidenceController < Officing::BaseController
|
||||||
|
|
||||||
before_action :load_officer_assignment
|
before_action :validate_officer_assignment
|
||||||
before_action :validate_officer_assignment, only: :create
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@residence = Officing::Residence.new
|
@residence = Officing::Residence.new
|
||||||
@@ -23,13 +22,14 @@ class Officing::ResidenceController < Officing::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def load_officer_assignment
|
def load_officer_assignment
|
||||||
@officer_assignments = current_user.poll_officer.
|
@officer_assignments ||= current_user.poll_officer.
|
||||||
officer_assignments.
|
officer_assignments.
|
||||||
voting_days.
|
voting_days.
|
||||||
where(date: Date.current)
|
where(date: Date.current)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_officer_assignment
|
def validate_officer_assignment
|
||||||
|
load_officer_assignment
|
||||||
if @officer_assignments.blank?
|
if @officer_assignments.blank?
|
||||||
redirect_to officing_root_path, notice: t("officing.residence.flash.not_allowed")
|
redirect_to officing_root_path, notice: t("officing.residence.flash.not_allowed")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<h2><%= t("officing.residence.new.title") %></h2>
|
<h2><%= t("officing.residence.new.title") %></h2>
|
||||||
|
|
||||||
<% if @officer_assignments.present? %>
|
<div class="row verification account">
|
||||||
<div class="row verification account">
|
|
||||||
<div class="small-12 medium-8 column">
|
<div class="small-12 medium-8 column">
|
||||||
<%= form_for @residence, as: "residence", url: officing_residence_path do |f| %>
|
<%= form_for @residence, as: "residence", url: officing_residence_path do |f| %>
|
||||||
<%= render "errors" %>
|
<%= render "errors" %>
|
||||||
@@ -9,7 +8,6 @@
|
|||||||
<div class="small-12 medium-6">
|
<div class="small-12 medium-6">
|
||||||
<%= f.select :document_type, document_types, prompt: "" %>
|
<%= f.select :document_type, document_types, prompt: "" %>
|
||||||
|
|
||||||
|
|
||||||
<%= f.text_field :document_number,
|
<%= f.text_field :document_number,
|
||||||
placeholder: t("officing.residence.new.document_number"),
|
placeholder: t("officing.residence.new.document_number"),
|
||||||
autocomplete: "off" %>
|
autocomplete: "off" %>
|
||||||
@@ -24,9 +22,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
|
||||||
<div class="callout primary">
|
|
||||||
<%= t("officing.residence.new.no_assignments") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ en:
|
|||||||
submit: Validate document
|
submit: Validate document
|
||||||
error_verifying_census: "The Census was unable to verify this document."
|
error_verifying_census: "The Census was unable to verify this document."
|
||||||
form_errors: prevented the verification of this document
|
form_errors: prevented the verification of this document
|
||||||
no_assignments: "You don't have officing shifts today"
|
|
||||||
voters:
|
voters:
|
||||||
new:
|
new:
|
||||||
title: Polls
|
title: Polls
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ es:
|
|||||||
submit: Validar documento
|
submit: Validar documento
|
||||||
error_verifying_census: "El Padrón no pudo verificar este documento."
|
error_verifying_census: "El Padrón no pudo verificar este documento."
|
||||||
form_errors: evitaron verificar este documento
|
form_errors: evitaron verificar este documento
|
||||||
no_assignments: "Hoy no tienes turno de presidente de mesa"
|
|
||||||
voters:
|
voters:
|
||||||
new:
|
new:
|
||||||
title: Votaciones
|
title: Votaciones
|
||||||
|
|||||||
@@ -21,4 +21,9 @@ module CommonActions
|
|||||||
check "user_terms_of_service"
|
check "user_terms_of_service"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_officer
|
||||||
|
allow_any_instance_of(Officing::ResidenceController).
|
||||||
|
to receive(:validate_officer_assignment).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user