diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index e405fb023..bd8759c98 100644 --- a/app/assets/stylesheets/participacion.scss +++ b/app/assets/stylesheets/participacion.scss @@ -16,6 +16,7 @@ // 14. Tables // 15. Social // 16. Pages +// 17. Verification // // 01. Variables @@ -126,6 +127,7 @@ h6 { } .button { + font-size: rem-calc(13); padding: rem-calc(15) rem-calc(32); } @@ -221,6 +223,11 @@ h6 { } } +.progress { + background-color: rgba(0,0,0,.06); + border: 0; +} + // 04. Header // - - - - - - - - - - - - - - - - - - - - - - - - - @@ -866,22 +873,8 @@ form { margin-right: rem-calc(12); } - .date { - - select { - float: left; - width: 25%; - } - } - .verify-account { padding-right: rem-calc(12); - - .verified { - color: $check; - font-weight: bold; - line-height: rem-calc(42); - } } } @@ -1180,3 +1173,92 @@ table { } } } + +// 17. Verification +// - - - - - - - - - - - - - - - - - - - - - - - - - + +.verification { + min-height: 60%; + + @media (min-width: $small-breakpoint) { + .left + .left { + margin-left: rem-calc(12); + } + } + + .verify-account { + padding-right: rem-calc(12); + + .verified { + color: $check; + font-weight: bold; + line-height: rem-calc(42); + } + } + + .date { + + select { + float: left; + width: 30%; + + @media (min-width: $small-breakpoint) { + width: 25%; + } + } + } + + .progress { + height: rem-calc(48); + + @media (min-width: $small-breakpoint) { + height: rem-calc(24); + } + + .meter { + background: #63D1C4; + } + } + + .verification-step { + font-size: rem-calc(11); + padding-top: rem-calc(10); + + @media (min-width: $small-breakpoint) { + line-height: $line-height; + padding-top: 0; + } + + &.active { + color: white; + } + + &.completed { + color: rgba(255,255,255,.5); + } + } + + .send-letter { + background: none; + color: $link; + + &:hover { + color: $link-hover; + } + } + + .button + form { + display: inline-block; + margin-left: rem-calc(12); + } + + .verification-list { + font-size: rem-calc(13); + list-style-type: none; + margin-left: 0; + + span { + display: inline-block; + } + } +} diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 40f9b31dc..0399ccd63 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,11 +1,11 @@ class Admin::CommentsController < Admin::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + + has_filters %w{all with_confirmed_hide} before_filter :load_comment, only: [:confirm_hide, :restore] def index - @comments = Comment.only_hidden.send(@filter).page(params[:page]) + @comments = Comment.only_hidden.send(@current_filter).page(params[:page]) end def confirm_hide @@ -23,13 +23,4 @@ class Admin::CommentsController < Admin::BaseController @comment = Comment.with_hidden.find(params[:id]) end - def set_valid_filters - @valid_filters = %w{all with_confirmed_hide} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/admin/debates_controller.rb b/app/controllers/admin/debates_controller.rb index 4487fcf81..23edb01f5 100644 --- a/app/controllers/admin/debates_controller.rb +++ b/app/controllers/admin/debates_controller.rb @@ -1,11 +1,10 @@ class Admin::DebatesController < Admin::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + has_filters %w{all with_confirmed_hide}, only: :index before_filter :load_debate, only: [:confirm_hide, :restore] def index - @debates = Debate.only_hidden.send(@filter).page(params[:page]) + @debates = Debate.only_hidden.send(@current_filter).page(params[:page]) end def confirm_hide @@ -24,13 +23,4 @@ class Admin::DebatesController < Admin::BaseController @debate = Debate.with_hidden.find(params[:id]) end - def set_valid_filters - @valid_filters = %w{all with_confirmed_hide} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index bb623702a..0e704e9a1 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -1,11 +1,11 @@ class Admin::OrganizationsController < Admin::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + + has_filters %w{all pending verified rejected}, only: :index load_and_authorize_resource except: :search def index - @organizations = @organizations.send(@filter) + @organizations = @organizations.send(@current_filter) @organizations = @organizations.includes(:user).order(:name, 'users.email').page(params[:page]) end @@ -23,14 +23,4 @@ class Admin::OrganizationsController < Admin::BaseController redirect_to request.query_parameters.merge(action: :index) end - private - def set_valid_filters - @valid_filters = %w{all pending verified rejected} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 61c0f5650..ecf7f206a 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,11 +1,11 @@ class Admin::UsersController < Admin::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + + has_filters %w{all with_confirmed_hide}, only: :index before_filter :load_user, only: [:confirm_hide, :restore] def index - @users = User.only_hidden.send(@filter).page(params[:page]) + @users = User.only_hidden.send(@current_filter).page(params[:page]) end def show @@ -30,13 +30,4 @@ class Admin::UsersController < Admin::BaseController @user = User.with_hidden.find(params[:id]) end - def set_valid_filters - @valid_filters = %w{all with_confirmed_hide} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5d207e463..86219f0ad 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ require "application_responder" class ApplicationController < ActionController::Base + include HasFilters + before_filter :authenticate_http_basic before_filter :authenticate_user!, unless: :devise_controller?, if: :beta_site? diff --git a/app/controllers/concerns/has_filters.rb b/app/controllers/concerns/has_filters.rb new file mode 100644 index 000000000..3dd3cc295 --- /dev/null +++ b/app/controllers/concerns/has_filters.rb @@ -0,0 +1,13 @@ +module HasFilters + extend ActiveSupport::Concern + + class_methods do + def has_filters(valid_filters, *args) + before_filter(*args) do + @valid_filters = valid_filters + @current_filter = params[:filter] + @current_filter = @valid_filters.first unless @valid_filters.include?(@current_filter) + end + end + end +end diff --git a/app/controllers/moderation/comments_controller.rb b/app/controllers/moderation/comments_controller.rb index 3622d02ac..065516531 100644 --- a/app/controllers/moderation/comments_controller.rb +++ b/app/controllers/moderation/comments_controller.rb @@ -1,12 +1,12 @@ class Moderation::CommentsController < Moderation::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + + has_filters %w{all pending_flag_review with_ignored_flag}, only: :index before_filter :load_comments, only: :index load_and_authorize_resource def index - @comments = @comments.send(@filter) + @comments = @comments.send(@current_filter) @comments = @comments.page(params[:page]) end @@ -30,13 +30,4 @@ class Moderation::CommentsController < Moderation::BaseController @comments = Comment.accessible_by(current_ability, :hide).flagged.sorted_for_moderation.includes(:commentable) end - def set_valid_filters - @valid_filters = %w{all pending_flag_review with_ignored_flag} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/moderation/debates_controller.rb b/app/controllers/moderation/debates_controller.rb index abb8e964b..5fdd19049 100644 --- a/app/controllers/moderation/debates_controller.rb +++ b/app/controllers/moderation/debates_controller.rb @@ -1,13 +1,13 @@ class Moderation::DebatesController < Moderation::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index + + has_filters %w{all pending_flag_review with_ignored_flag}, only: :index + before_filter :load_debates, only: :index load_and_authorize_resource def index - @debates = @debates.send(@filter) - @debates = @debates.page(params[:page]) + @debates = @debates.send(@current_filter).page(params[:page]) end def hide @@ -30,13 +30,4 @@ class Moderation::DebatesController < Moderation::BaseController @debates = Debate.accessible_by(current_ability, :hide).flagged.sorted_for_moderation end - def set_valid_filters - @valid_filters = %w{all pending_flag_review with_ignored_flag} - end - - def parse_filter - @filter = params[:filter] - @filter = 'all' unless @valid_filters.include?(@filter) - end - end diff --git a/app/controllers/verification/letter_controller.rb b/app/controllers/verification/letter_controller.rb index 401ae0ed2..152590b20 100644 --- a/app/controllers/verification/letter_controller.rb +++ b/app/controllers/verification/letter_controller.rb @@ -26,7 +26,7 @@ class Verification::LetterController < ApplicationController def verify_phone_or_email! unless current_user.confirmed_phone? - redirect_to verified_user_path, alert: t('verification.letter.alert.unconfirmed_personal_data') + redirect_to verified_user_path, alert: t('verification.letter.alert.unconfirmed_code') end end end \ No newline at end of file diff --git a/app/models/debate.rb b/app/models/debate.rb index e088d8141..9c96c812c 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -75,7 +75,9 @@ class Debate < ActiveRecord::Base end def votable_by?(user) - !user.unverified? || + total_votes <= 100 || + !user.unverified? || + Setting.value_for('max_ratio_anon_votes_on_debates').to_i == 100 || anonymous_votes_ratio < Setting.value_for('max_ratio_anon_votes_on_debates').to_i || user.voted_for?(self) end diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index bf749bbd2..41ae068c0 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -1,21 +1,26 @@
<%= t("account.show.level_three_user") %>
- <% elsif current_user.level_two_verified? %> -<%= t("account.show.level_two_user") %>
- <% else %> - <%= link_to t("account.show.verify_my_account"), new_residence_path, class: 'button radius small success right' %> - <% end %> - ++ + <%= t("account.show.verified_account") %> +
+ <% elsif current_user.level_two_verified? %> + <%= link_to t("account.show.finish_verification"), new_letter_path, class: "button radius small success right" %> + <% else %> + <%= link_to t("account.show.verify_my_account"), new_residence_path, class: "button radius small success right" %> + <% end %> + +<%= @error %>
- <%= f.text_field :confirmation_code %> + <% if @error %> +<%= t("verification.verified_user.show.explanation") %>
<% if @verified_users.map(&:email).any? %> -Congratulations! You can now participate in discussions or support proposals of others.
To finish we need to verify your account completely provide you with a maximum security code, we ensure that no one is using your data on your behalf.
This requirement is essential to participate in final votes on motions. This can approach any Office of Citizen where you will verify in person, or in case you is impossible, we can send you a letter home with the code.
" + offices: "See Office of Citizen" + offices_url: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD" + send_letter: "Send me a letter with the code" + introduce_code: "Enter the security code" + send_code: "Send" create: flash: - success: "You will receive a letter to your home address in the next couple of days" + success: "Thank you for requesting a code maximum security in a few days we will send it to the address on your census data. Remember that you can save shipping collecting your code in any of the Office of Citizen Services." alert: failure: "We could not verify your address with the Census please try again later" alert: - unconfirmed_personal_data: 'You have not yet confirmed your personal data' + unconfirmed_code: "You have not yet enter the confirmation code" verified_user: show: - title: Available information - email_title: Emails - phone_title: Phones - use_another_phone: Use another phone + title: "Available information" + explanation: "We currently have the following data in the Census, choose where you want to send the confirmation code." + email_title: "Emails" + phone_title: "Phones" + use_another_phone: "Use another phone" form: - submit_button: Send \ No newline at end of file + submit_button: "Send code" \ No newline at end of file diff --git a/config/locales/verification.es.yml b/config/locales/verification.es.yml index afb547f16..29f61621c 100644 --- a/config/locales/verification.es.yml +++ b/config/locales/verification.es.yml @@ -1,49 +1,59 @@ es: verification: + step_1: "1. Residencia" + step_2: "2. Código de confirmación" + step_3: "3. Verificación final" residence: new: - title: 'Verificar residencia' + title: "Verificar residencia" + document_type_label: "Tipo de documento" document_type: - spanish_id: 'DNI' - passport: 'Pasaporte' - residence_card: 'Tarjeta de residencia' - accept_terms_text: "Acepto los terminos de acceso al Padrón" - accept_terms_link: "Leer términos" - form_errors: 'evitaron verificar tu residencia' - error_verifying_census: 'El Padrón de Madrid no pudo verificar tu información. Revisa la información ó ponte en contacto con nosotros.' + spanish_id: "DNI" + passport: "Pasaporte" + residence_card: "Tarjeta de residencia" + document_number: "Número de documento" + date_of_birth: "Fecha de nacimiento" + postal_code: "Código postal" + accept_terms_text: "Acepto %{terms_url} al Padrón" + terms: "los terminos de acceso" + verify_residence: "Verificar residencia" + form_errors: "evitaron verificar tu residencia" + error_verifying_census: "El Padrón de Madrid no pudo verificar tu información. Revisa la información ó ponte en contacto con nosotros." create: flash: - success: 'Residencia verificada' + success: "Residencia verificada" alert: - verify_attemps_left: 'Has llegado al máximo número de intentos de verificar tu residencia.' - unconfirmed_residency: 'Aún no has verificado tu residencia' + verify_attemps_left: "Has llegado al máximo número de intentos de verificar tu residencia." + unconfirmed_residency: "Aún no has verificado tu residencia" sms: new: - title: Verificación de teléfono móvil - submit_button: Enviar + title: "Recibir código de confirmación" + phone: "Introduce tu teléfono móvil para recibir el código" + submit_button: "Enviar" create: flash: - success: 'Introduce el código de confirmación que te hemos enviado por mensaje de texto' + success: "Introduce el código de confirmación que te hemos enviado por mensaje de texto" edit: - title: 'Confirmación de código de seguridad' - resend_sms_text: '¿No has recibido un mensaje de texto con tu código de confirmación?' - resend_sms_link: 'Haz click aquí para volver a enviártelo' - submit_button: Enviar + title: "Confirmación de código de seguridad" + confirmation_code: "Introduce el código que has recibido en tu móvil" + resend_sms_text: "¿No has recibido un mensaje de texto con tu código de confirmación?" + resend_sms_link: "Haz click aquí para volver a enviártelo" + submit_button: "Enviar" update: - error: 'Código de confirmación incorrecto' + error: "Código de confirmación incorrecto" flash: level_three: - success: 'Código correcto. Ya eres un usuario verificado' + success: "Código correcto. Tu cuenta ya está verificada" level_two: - success: 'Código correcto' + success: "Código correcto" alert: - verify_attemps_left: 'Has llegado al máximo número de intentos de verificar tu teléfono.' + verify_attemps_left: "Has llegado al máximo número de intentos de verificar tu teléfono." email: show: flash: - success: 'Eres un usuario verificado' + success: "Eres un usuario verificado" alert: - failure: 'Código de verificación incorrecto' + failure: "Código de verificación incorrecto" create: flash: success: "Te hemos enviado un email de confirmación a tu cuenta: %{email}" @@ -51,21 +61,27 @@ es: failure: "Hubo un problema enviándote un email a tu cuenta" letter: new: - title: Final Verification - explanation: 'To completely verify your account we need to go to one of these offices or send you a letter with a special code to your home address' - submit_button: 'Send me a letter' + title: "Verificación Final" + explanation_html: + "¡Felicidades! Ya puedes participar en debates o apoyar propuestas de otras personas.
Para terminar de verificar tu cuenta completamente necesitamos proporcionarte un código de máxima seguridad, que nos asegure que nadie está utilizando tus datos en tu nombre.
Este requerimiento es esencial para participar en las votaciones finales de las propuestas. Para ello puedes acercarte a cualquier Oficina de Atención al Ciudadano donde te verificarán presencialmente, o en caso de que te sea imposible, podemos mandarte una carta a casa con el código.
" + offices: "Ver Oficinas de Atención al Ciudadano" + offices_url: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD" + send_letter: "Enviarme una carta con el código" + introduce_code: "Introduce el código de seguridad" + send_code: "Enviar" create: flash: - success: "You will receive a letter to your home address in the next couple of days" + success: "Gracias por solicitar tu código de máxima seguridad, en unos días te lo enviaremos a la dirección que figura en tus datos del padrón. Recuerda que puedes ahorrar el envío recogiendo tu código en cualquiera de las Oficinas de Atención al Ciudadano." alert: - failure: "We could not verify your address with the Census please try again later" + failure: "No podemos verificar tu dirección con el Padrón, por favor inténtalo otra vez más tarde" alert: - unconfirmed_personal_data: 'You have not yet confirmed your personal data' + unconfirmed_code: "Todavía no has introducido el código de confirmación" verified_user: show: - title: Información disponible - email_title: Emails - phone_title: Teléfonos - use_another_phone: Utilizar otro teléfono + title: "Información disponible" + explanation: "Actualmente disponemos de los siguientes datos en el Padrón, selecciona donde quieres que enviemos el código de confirmación." + email_title: "Emails" + phone_title: "Teléfonos" + use_another_phone: "Utilizar otro teléfono" form: - submit_button: Enviar \ No newline at end of file + submit_button: "Enviar código" diff --git a/db/seeds.rb b/db/seeds.rb index 600808d1b..78d873c53 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,7 @@ +# Default admin user (change password after first deploy to a server!) +admin = User.create!(username: 'admin', email: 'admin@madrid.es', password: '12345678', password_confirmation: '12345678', confirmed_at: Time.now) +admin.create_administrator + # Names for the moderation console, as a hint for moderators # to know better how to assign users with official positions Setting.create(key: 'official_level_1_name', value: 'Empleados públicos') @@ -7,4 +11,4 @@ Setting.create(key: 'official_level_4_name', value: 'Concejales') Setting.create(key: 'official_level_5_name', value: 'Alcaldesa') # Max percentage of allowed anonymous votes on a debate -Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50') \ No newline at end of file +Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50') diff --git a/spec/controllers/concerns/has_filters_spec.rb b/spec/controllers/concerns/has_filters_spec.rb new file mode 100644 index 000000000..af094e9ec --- /dev/null +++ b/spec/controllers/concerns/has_filters_spec.rb @@ -0,0 +1,37 @@ +require 'rails_helper' + +describe 'HasFilters' do + + class FakeController < ActionController::Base; end + + controller(FakeController) do + include HasFilters + has_filters ['all', 'pending', 'reviewed'], only: :index + + def index + render text: "#{@current_filter} (#{@valid_filters.join(' ')})" + end + end + + it "has the valid filters set up" do + get :index + expect(response.body).to eq('all (all pending reviewed)') + end + + describe "the current filter" do + it "defaults to the first one on the list" do + get :index + expect(response.body).to eq('all (all pending reviewed)') + end + + it "can be changed by the filter param" do + get :index, filter: 'pending' + expect(response.body).to eq('pending (all pending reviewed)') + end + + it "defaults to the first one on the list if given a bogus filter" do + get :index, filter: 'foobar' + expect(response.body).to eq('all (all pending reviewed)') + end + end +end diff --git a/spec/controllers/debates_controller_spec.rb b/spec/controllers/debates_controller_spec.rb index 1628c9bcf..f87635a6b 100644 --- a/spec/controllers/debates_controller_spec.rb +++ b/spec/controllers/debates_controller_spec.rb @@ -35,7 +35,7 @@ describe DebatesController do it 'should not allow vote if user is not allowed' do Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 0) - debate = create(:debate) + debate = create(:debate, cached_votes_total: 1000) sign_in create(:user) expect do diff --git a/spec/features/verification/email_spec.rb b/spec/features/verification/email_spec.rb index 336f4946a..12d248838 100644 --- a/spec/features/verification/email_spec.rb +++ b/spec/features/verification/email_spec.rb @@ -30,7 +30,7 @@ feature 'Verify email' do expect(page).to have_content "You are now a verified user" expect(page).to_not have_link "Verify my account" - expect(page).to have_content "You are a level 3 user" + expect(page).to have_content "Verified account" end scenario "Errors on token verification" do diff --git a/spec/features/verification/letter_spec.rb b/spec/features/verification/letter_spec.rb index fa4a451db..9a462feaf 100644 --- a/spec/features/verification/letter_spec.rb +++ b/spec/features/verification/letter_spec.rb @@ -10,7 +10,7 @@ feature 'Verify Letter' do click_button "Send me a letter" - expect(page).to have_content "You will receive a letter to your home address" + expect(page).to have_content "Thank you for requesting a code maximum security in a few days we will send it to the address on your census data. Remember that you can save shipping collecting your code in any of the Office of Citizen Services." end scenario "Error accessing address from CensusApi" do @@ -34,7 +34,7 @@ feature 'Verify Letter' do click_button "Send me a letter" - expect(page).to have_content "You will receive a letter to your home address" + expect(page).to have_content "Thank you for requesting a code maximum security in a few days we will send it to the address on your census data. Remember that you can save shipping collecting your code in any of the Office of Citizen Services." end scenario "Deny access unless verified residence" do @@ -53,7 +53,7 @@ feature 'Verify Letter' do login_as(user) visit new_letter_path - expect(page).to have_content 'You have not yet confirmed your personal data' + expect(page).to have_content 'You have not yet enter the confirmation code' expect(URI.parse(current_url).path).to eq(new_sms_path) end diff --git a/spec/features/verification/level_three_verification_spec.rb b/spec/features/verification/level_three_verification_spec.rb index 4f7cc9bf3..112fd859b 100644 --- a/spec/features/verification/level_three_verification_spec.rb +++ b/spec/features/verification/level_three_verification_spec.rb @@ -28,10 +28,10 @@ feature 'Level three verification' do expect(page).to have_content 'Correct code' - expect(page).to have_content "You are now a verified user" + expect(page).to have_content "Correct code. Your account is verified" expect(page).to_not have_link "Verify my account" - expect(page).to have_content "You are a level 3 user" + expect(page).to have_content "Verified account" end scenario 'Verification with residency and verified email' do @@ -61,7 +61,7 @@ feature 'Level three verification' do expect(page).to have_content "You are now a verified user" expect(page).to_not have_link "Verify my account" - expect(page).to have_content "You are a level 3 user" + expect(page).to have_content "Verified account" end scenario 'Verification with residency and sms and letter' do @@ -87,6 +87,6 @@ feature 'Level three verification' do click_button "Send me a letter" - expect(page).to have_content "You will receive a letter to your home address" + expect(page).to have_content "Thank you for requesting a code maximum security in a few days we will send it to the address on your census data. Remember that you can save shipping collecting your code in any of the Office of Citizen Services." end end \ No newline at end of file diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 96e3b3c96..0378dabab 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -124,7 +124,7 @@ describe Debate do end describe "from anonymous users when there are too many anonymous votes" do - before(:each) {debate.update(cached_anonymous_votes_total: 52, cached_votes_total: 100)} + before(:each) {debate.update(cached_anonymous_votes_total: 520, cached_votes_total: 1000)} it "should not register vote " do user = create(:user) @@ -156,13 +156,19 @@ describe Debate do end it "should be true for anonymous users if allowed anonymous votes" do - debate.update(cached_anonymous_votes_total: 42, cached_votes_total: 100) + debate.update(cached_anonymous_votes_total: 420, cached_votes_total: 1000) + user = create(:user) + expect(debate.votable_by?(user)).to be true + end + + it "should be true for anonymous users if less than 100 votes" do + debate.update(cached_anonymous_votes_total: 90, cached_votes_total: 92) user = create(:user) expect(debate.votable_by?(user)).to be true end it "should be false for anonymous users if too many anonymous votes" do - debate.update(cached_anonymous_votes_total: 52, cached_votes_total: 100) + debate.update(cached_anonymous_votes_total: 520, cached_votes_total: 1000) user = create(:user) expect(debate.votable_by?(user)).to be false end