forked from consuldemocracy/consuldemocracy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #48 display tags * #51 fix some tests * #51 fix some tests * #51 fix some tests related to census_api * #51 fix some tests related to age * #51 fix some tests related to age
- Loading branch information
Showing
26 changed files
with
474 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require_dependency Rails.root.join('app', 'models', 'tag_cloud').to_s | ||
|
||
class TagCloud | ||
|
||
def tags | ||
resource_model_scoped. | ||
tag_counts. | ||
where("lower(name) NOT IN (?)", category_names + geozone_names + default_blacklist). | ||
order("#{table_name}_count": :desc, name: :asc). | ||
limit(10) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<div class="row"> | ||
<div class="small-12 column"> | ||
|
||
<%= f.hidden_field :use_redeemable_code %> | ||
<%= f.hidden_field :locale, value: I18n.locale %> | ||
<%= f.text_field :lastname, autofocus: true, | ||
placeholder: t("devise_views.users.registrations.new.lastname_label") | ||
%> | ||
<%= f.text_field :firstname, placeholder: t("devise_views.users.registrations.new.firstname_label") | ||
%> | ||
<%= f.label :username %> | ||
<p class="help-text" id="username-help-text"><%= t("devise_views.users.registrations.new.username_note") %></p> | ||
<%= f.text_field :username, maxlength: User.username_max_length, | ||
placeholder: t("devise_views.users.registrations.new.username_label"), | ||
label: false, | ||
aria: {describedby: "username-help-text"} %> | ||
<%= f.invisible_captcha :family_name %> | ||
|
||
|
||
<div class="date-of-birth"> | ||
<%= f.label t("devise_views.users.registrations.new.date_of_birth") %> | ||
<p class="help-text" id="date-of-birth-help-text"><%= t("devise_views.users.registrations.new.date_of_birth_note") %></p> | ||
<%= f.date_select :date_of_birth, | ||
prompt: true, | ||
start_year: 26.years.ago.year, end_year: 16.years.ago.year, | ||
label: false, | ||
aria: {describedby: "date-of-birth-help-text"} %> | ||
</div> | ||
|
||
<div class="gender"> | ||
<%= f.select :gender, user_genders_select_options, label: t("devise_views.users.registrations.new.gender_label"), prompt: t("devise_views.users.registrations.new.gender_placeholder") %> | ||
</div> | ||
|
||
<!-- Address --> | ||
|
||
<%= f.text_field :address, label: t("devise_views.users.registrations.new.address_label") %> | ||
|
||
<div class="medium-6"> | ||
<%= f.text_field :postal_code %> | ||
</div> | ||
|
||
<%= f.text_field :city, label: t("devise_views.users.registrations.new.city_label") %> | ||
|
||
<!-- Connexion info --> | ||
|
||
<%= f.text_field :phone_number, placeholder: t("devise_views.organizations.registrations.new.phone_number_label"), label: t("devise_views.users.registrations.new.phone_label") %> | ||
<%= f.email_field :email, placeholder: t("devise_views.users.registrations.new.email_label") %> | ||
<% if resource.use_redeemable_code %> | ||
<%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %> | ||
<% end %> | ||
<%= f.label :ca_wanabee do %> | ||
<%= f.check_box :ca_wanabee, title: t('devise_views.users.registrations.new.ca_wanabee'), label: false %> | ||
<span class="checkbox"> | ||
<%= t("devise_views.users.registrations.new.ca_wanabee", title: "devise_views.users.registrations.new.ca_wanabee").html_safe %> | ||
</span> | ||
<% end %> | ||
<%= f.label :terms_of_service do %> | ||
<%= f.check_box :terms_of_service, title: t('devise_views.users.registrations.new.terms_title'), label: false %> | ||
<span class="checkbox"> | ||
<%= t("devise_views.users.registrations.new.terms", | ||
terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", | ||
title: t('shared.target_blank_html'), | ||
target: "_blank")).html_safe %> | ||
</span> | ||
<% end %> | ||
<div class="small-12 medium-6 small-centered"> | ||
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded", id: "register-btn" %> | ||
</div> | ||
</div> | ||
</div> |
16 changes: 16 additions & 0 deletions
16
app/views/custom/users/registrations/finish_signup.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h2><%= t('omniauth.finish_signup.title') %></h2> | ||
|
||
<%= form_for current_user, as: :user, url: do_finish_signup_path, html: { role: 'form'} do |f| %> | ||
<%= render 'shared/errors', resource: current_user %> | ||
|
||
<div class='callout primary'> | ||
<%= t("omniauth.finish_signup.username_warning") %> | ||
</div> | ||
|
||
<%= render 'custom/users/registrations/new_form', f: f %> | ||
|
||
|
||
<div class="text-center"> | ||
<%= link_to t("devise_views.users.registrations.new.cancel"), destroy_user_session_path, class: 'delete', method: :delete %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
|
||
fill_in 'user_username', with: 'pepe' | ||
fill_in 'user_email', with: '[email protected]' | ||
select_date '31-December-1980', from: 'user_date_of_birth' | ||
select_date "31-December-#{valid_date_of_birth_year}", from: 'user_date_of_birth' | ||
fill_in 'user_lastname', with: 'mirza' | ||
fill_in 'user_firstname', with: 'zuliani' | ||
fill_in 'user_postal_code', with: '11000' | ||
|
@@ -32,7 +32,7 @@ | |
expect(user).to be_level_three_verified | ||
expect(user).to be_residence_verified | ||
expect(user).not_to be_confirmed | ||
expect(user.date_of_birth).to have_content Date.new(1980, 12, 31) | ||
expect(user.date_of_birth).to have_content Date.new(valid_date_of_birth_year, 12, 31) | ||
|
||
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1] | ||
visit user_confirmation_path(confirmation_token: sent_token) | ||
|
@@ -60,7 +60,7 @@ | |
|
||
fill_in 'user_username', with: 'Kelly Sue' | ||
fill_in 'user_email', with: '' | ||
select_date '31-December-1980', from: 'user_date_of_birth' | ||
select_date "31-December-#{valid_date_of_birth_year}", from: 'user_date_of_birth' | ||
fill_in 'user_lastname', with: 'mirza' | ||
fill_in 'user_firstname', with: 'zuliani' | ||
fill_in 'user_postal_code', with: '11000' | ||
|
@@ -75,7 +75,7 @@ | |
expect(user).to be_level_three_verified | ||
expect(user).to be_residence_verified | ||
expect(user).to be_confirmed | ||
expect(user.date_of_birth).to have_content Date.new(1980, 12, 31) | ||
expect(user.date_of_birth).to have_content Date.new(valid_date_of_birth_year, 12, 31) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'rails_helper' | ||
|
||
feature 'Residence' do | ||
let(:officer) { create(:poll_officer) } | ||
|
||
|
||
|
||
feature "Assigned officers" do | ||
|
||
background do | ||
create(:poll_officer_assignment, officer: officer) | ||
login_as(officer.user) | ||
visit officing_root_path | ||
end | ||
|
||
scenario "Verify voter" do | ||
within("#side_menu") do | ||
click_link "Validate document" | ||
end | ||
|
||
select 'DNI', from: 'residence_document_type' | ||
fill_in 'residence_document_number', with: "12345678Z" | ||
fill_in 'residence_year_of_birth', with: "#{valid_date_of_birth_year}" | ||
|
||
click_button 'Validate document' | ||
|
||
expect(page).to have_content 'Document verified with Census' | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
require 'rails_helper' | ||
require 'sessions_helper' | ||
|
||
feature 'Poll Officing' do | ||
let(:user) { create(:user) } | ||
|
||
scenario 'Officing dashboard available for multiple sessions', :js do | ||
poll = create(:poll) | ||
booth = create(:poll_booth) | ||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) | ||
|
||
user1 = create(:user) | ||
user2 = create(:user) | ||
officer1 = create(:poll_officer, user: user1) | ||
officer2 = create(:poll_officer, user: user2) | ||
|
||
create(:poll_shift, officer: officer1, booth: booth, date: Date.current, task: :vote_collection) | ||
create(:poll_shift, officer: officer2, booth: booth, date: Date.current, task: :vote_collection) | ||
|
||
officer_assignment_1 = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer1) | ||
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer2) | ||
|
||
in_browser(:one) do | ||
login_as user1 | ||
visit officing_root_path | ||
end | ||
|
||
in_browser(:two) do | ||
login_as user2 | ||
visit officing_root_path | ||
end | ||
|
||
in_browser(:one) do | ||
expect(page).to have_content("Here you can validate user documents and store voting results") | ||
|
||
visit new_officing_residence_path | ||
select 'DNI', from: 'residence_document_type' | ||
fill_in 'residence_document_number', with: "12345678Z" | ||
fill_in 'residence_year_of_birth', with: "#{valid_date_of_birth_year}" | ||
click_button 'Validate document' | ||
expect(page).to have_content 'Document verified with Census' | ||
click_button "Confirm vote" | ||
expect(page).to have_content "Vote introduced!" | ||
expect(Poll::Voter.where(document_number: '12345678Z', poll_id: poll, origin: 'booth', officer_id: officer1).count).to be(1) | ||
|
||
visit final_officing_polls_path | ||
expect(page).to have_content("Polls ready for final recounting") | ||
end | ||
|
||
in_browser(:two) do | ||
expect(page).to have_content("Here you can validate user documents and store voting results") | ||
|
||
visit new_officing_residence_path | ||
select 'DNI', from: 'residence_document_type' | ||
fill_in 'residence_document_number', with: "12345678Y" | ||
fill_in 'residence_year_of_birth', with: "#{valid_date_of_birth_year}" | ||
click_button 'Validate document' | ||
expect(page).to have_content 'Document verified with Census' | ||
click_button "Confirm vote" | ||
expect(page).to have_content "Vote introduced!" | ||
expect(Poll::Voter.where(document_number: '12345678Y', poll_id: poll, origin: 'booth', officer_id: officer2).count).to be(1) | ||
|
||
visit final_officing_polls_path | ||
expect(page).to have_content("Polls ready for final recounting") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'rails_helper' | ||
|
||
feature 'Residence' do | ||
|
||
background { create(:geozone) } | ||
|
||
scenario 'Verify resident' do | ||
user = create(:user) | ||
login_as(user) | ||
|
||
visit account_path | ||
click_link 'Verify my account' | ||
|
||
fill_in 'residence_document_number', with: "12345678Z" | ||
select 'DNI', from: 'residence_document_type' | ||
select_date "31-December-#{valid_date_of_birth_year}", from: 'residence_date_of_birth' | ||
fill_in 'residence_postal_code', with: '28013' | ||
check 'residence_terms_of_service' | ||
|
||
click_button 'Verify residence' | ||
|
||
expect(page).to have_content 'Residence verified' | ||
end | ||
|
||
xscenario 'When trying to verify a deregistered account old votes are reassigned' do | ||
erased_user = create(:user, document_number: '12345678Z', document_type: '1', erased_at: Time.current) | ||
vote = create(:vote, voter: erased_user) | ||
new_user = create(:user) | ||
|
||
login_as(new_user) | ||
|
||
visit account_path | ||
click_link 'Verify my account' | ||
|
||
fill_in 'residence_document_number', with: '12345678Z' | ||
select 'DNI', from: 'residence_document_type' | ||
select_date '31-December-1980', from: 'residence_date_of_birth' | ||
fill_in 'residence_postal_code', with: '28013' | ||
check 'residence_terms_of_service' | ||
|
||
click_button 'Verify residence' | ||
|
||
expect(page).to have_content 'Residence verified' | ||
|
||
expect(vote.reload.voter).to eq(new_user) | ||
expect(erased_user.reload.document_number).to be_blank | ||
expect(new_user.reload.document_number).to eq('12345678Z') | ||
end | ||
|
||
end |
Oops, something went wrong.