diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index 0b027001b..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 // - - - - - - - - - - - - - - - - - - - - - - - - - @@ -229,7 +236,7 @@ header { background-position: 50% 50%; background-size: cover; color: $text; - min-height: rem-calc(600); + min-height: rem-calc(624); &.results { min-height: rem-calc(48); @@ -543,9 +550,14 @@ footer { a { color: white; - &.link:hover { + &:hover { color: white; opacity: .5; + transition: opacity 275ms; + } + + &:active, &:focus { + color: white; } } @@ -554,7 +566,14 @@ footer { text-decoration: underline; &:hover { - color: rgba(255,255,255,.6); + color: white; + opacity: .5; + transition: opacity 275ms; + } + + &:active, &:focus { + color: white; + opacity: 1; } } } @@ -752,6 +771,13 @@ form { } } +.captcha { + + label { + display: none; + } +} + // 09. Alerts // - - - - - - - - - - - - - - - - - - - - - - - - - @@ -847,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); - } } } @@ -1122,13 +1134,23 @@ table { .page { background: white; - min-height: 100%; + min-height: rem-calc(600); .menu { margin-top: rem-calc(24); + ul { + list-style-type: none; + margin-left: 0; + + & ul { + margin-left: rem-calc(12); + } + } + a { display: block; + font-size: rem-calc(13); margin-bottom: rem-calc(12); } } @@ -1137,7 +1159,12 @@ table { margin-top: rem-calc(24); text-align: justify; - ul { + h1, h2, h3, h4, h5, h6 { + text-align: left; + } + + ul, ol { + margin-left: rem-calc(12); li { font-size: rem-calc(13); @@ -1147,7 +1174,91 @@ 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/account_controller.rb b/app/controllers/account_controller.rb index 23af8c91b..625452196 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -1,5 +1,4 @@ class AccountController < ApplicationController - before_action :authenticate_user! before_action :set_account load_and_authorize_resource class: "User" diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 40f9b31dc..3ca25b23a 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -1,11 +1,10 @@ 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] + before_action :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 +22,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..da1acc7fe 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] + before_action :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/moderators_controller.rb b/app/controllers/admin/moderators_controller.rb index f2ef6f1c3..e15e9273f 100644 --- a/app/controllers/admin/moderators_controller.rb +++ b/app/controllers/admin/moderators_controller.rb @@ -1,5 +1,4 @@ class Admin::ModeratorsController < Admin::BaseController - load_and_authorize_resource def index diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index bb623702a..e5ba390e1 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -1,11 +1,10 @@ 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 +22,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..8bbbcdc8c 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,11 +1,10 @@ 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] + before_action :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 +29,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/api/stats_controller.rb b/app/controllers/api/stats_controller.rb index d44262b45..fc0bf3563 100644 --- a/app/controllers/api/stats_controller.rb +++ b/app/controllers/api/stats_controller.rb @@ -1,4 +1,5 @@ class Api::StatsController < Api::ApiController + def show unless params[:events].present? || params[:visits].present? return render json: {}, status: :bad_request @@ -19,4 +20,5 @@ class Api::StatsController < Api::ApiController render json: ds.build end + end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5d207e463..d5b05c6ae 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,29 +1,28 @@ require "application_responder" class ApplicationController < ActionController::Base - before_filter :authenticate_http_basic - - before_filter :authenticate_user!, unless: :devise_controller?, if: :beta_site? - before_filter :authenticate_beta_tester!, unless: :devise_controller?, if: :beta_site? - - check_authorization unless: :devise_controller? include SimpleCaptcha::ControllerHelpers - self.responder = ApplicationResponder - respond_to :html + include HasFilters - before_action :set_locale - layout :set_layout - - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + before_action :authenticate_http_basic + before_action :authenticate_user!, unless: :devise_controller?, if: :beta_site? + before_action :authenticate_beta_tester!, unless: :devise_controller?, if: :beta_site? before_action :ensure_signup_complete + before_action :set_locale + + check_authorization unless: :devise_controller? + self.responder = ApplicationResponder + + protect_from_forgery with: :exception rescue_from CanCan::AccessDenied do |exception| redirect_to main_app.root_url, alert: exception.message end + layout :set_layout + respond_to :html + private def authenticate_http_basic diff --git a/app/controllers/concerns/has_filters.rb b/app/controllers/concerns/has_filters.rb new file mode 100644 index 000000000..eeca1745f --- /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_action(*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/debates_controller.rb b/app/controllers/debates_controller.rb index a9e7325eb..3845afebf 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -1,14 +1,16 @@ class DebatesController < ApplicationController - before_action :parse_order, :parse_tag_filter, only: :index + before_action :parse_order, only: :index + before_action :parse_tag_filter, only: :index before_action :authenticate_user!, except: [:index, :show] load_and_authorize_resource respond_to :html, :js def index - @debates = Debate.search(params).page(params[:page]).for_render.send("sort_by_#{@order}") - @tags = ActsAsTaggableOn::Tag.all - @tag_cloud = Debate.tag_counts.order('count desc, name asc') + @debates = Debate.all + @debates = @debates.tagged_with(@tag_filter) if @tag_filter + @debates = @debates.page(params[:page]).for_render.send("sort_by_#{@order}") + @tag_cloud = Debate.tag_counts.order(taggings_count: :desc, name: :asc).limit(20) set_debate_votes(@debates) end @@ -85,8 +87,9 @@ class DebatesController < ApplicationController end def parse_tag_filter - valid_tags = ActsAsTaggableOn::Tag.all.map(&:name) - @tag_filter = params[:tag] if valid_tags.include?(params[:tag]) + if params[:tag].present? + @tag_filter = params[:tag] if ActsAsTaggableOn::Tag.where(name: params[:tag]).exists? + end end end diff --git a/app/controllers/moderation/base_controller.rb b/app/controllers/moderation/base_controller.rb index f2a794526..de0c46a79 100644 --- a/app/controllers/moderation/base_controller.rb +++ b/app/controllers/moderation/base_controller.rb @@ -2,9 +2,9 @@ class Moderation::BaseController < ApplicationController layout 'admin' before_action :authenticate_user! + before_action :verify_moderator skip_authorization_check - before_action :verify_moderator private diff --git a/app/controllers/moderation/comments_controller.rb b/app/controllers/moderation/comments_controller.rb index 3622d02ac..b53785e81 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 - before_filter :load_comments, only: :index + has_filters %w{all pending_flag_review with_ignored_flag}, only: :index + + before_action :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..85441d3f2 100644 --- a/app/controllers/moderation/debates_controller.rb +++ b/app/controllers/moderation/debates_controller.rb @@ -1,13 +1,12 @@ class Moderation::DebatesController < Moderation::BaseController - before_filter :set_valid_filters, only: :index - before_filter :parse_filter, only: :index - before_filter :load_debates, only: :index + has_filters %w{all pending_flag_review with_ignored_flag}, only: :index + + before_action :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 +29,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/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index 630cc64e4..6445622e2 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -1,4 +1,5 @@ class Organizations::RegistrationsController < Devise::RegistrationsController + def new super do |user| user.build_organization diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 845f82920..11f715960 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,25 +1,36 @@ class PagesController < ApplicationController - skip_authorization_check - def help + def census_terms end - def privacy + def conditions end - def legal + def cooming_soon end def general_terms end - def census_terms + def how_it_works end - def transparency + def how_to_use + end + + def more_information end def opendata end + + def participation + end + + def privacy + end + + def transparency + end end diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 1e76feb42..fe224eb8d 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -1,6 +1,6 @@ class StatsController < ApplicationController - skip_authorization_check before_action :verify_administrator + skip_authorization_check def show @event_types = Ahoy::Event.select(:name).uniq.pluck(:name) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 8588ba243..423ecedad 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,4 +1,5 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController + def self.provides_callback_for(provider) class_eval %Q{ def #{provider} @@ -26,4 +27,5 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController finish_signup_path end end + end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 7c8ad9535..112d8f8b0 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,5 +1,5 @@ class Users::RegistrationsController < Devise::RegistrationsController - prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup] + prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup] def create build_resource(sign_up_params) diff --git a/app/controllers/verification/letter_controller.rb b/app/controllers/verification/letter_controller.rb index 401ae0ed2..e302a1bc6 100644 --- a/app/controllers/verification/letter_controller.rb +++ b/app/controllers/verification/letter_controller.rb @@ -1,7 +1,7 @@ class Verification::LetterController < ApplicationController before_action :authenticate_user! before_action :verify_resident! - before_action :verify_phone_or_email! + before_action :verify_phone! skip_authorization_check def new @@ -11,22 +11,37 @@ class Verification::LetterController < ApplicationController def create @letter = Verification::Letter.new(user: current_user) if @letter.save - redirect_to account_path, notice: t('verification.letter.create.flash.success') + redirect_to edit_letter_path, notice: t('verification.letter.create.flash.success') else flash.now.alert = t('verification.letter.create.alert.failure') render :new end end + def edit + @letter = Verification::Letter.new(user: current_user) + end + + def update + @letter = Verification::Letter.new(letter_params.merge(user: current_user)) + if @letter.verify? + current_user.update(verified_at: Time.now) + redirect_to account_path, notice: t('verification.letter.update.flash.success') + else + @error = t('verification.letter.update.error') + render :edit + end + end + private def letter_params - params.require(:letter).permit() + params.require(:letter).permit(:verification_code) end - def verify_phone_or_email! + def verify_phone! 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/helpers/application_helper.rb b/app/helpers/application_helper.rb index 77afc1317..33fc7e0fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ module ApplicationHelper + def percentage(vote, debate) return "0%" if debate.total_votes == 0 debate.send(vote).percent_of(debate.total_votes).to_s + "%" diff --git a/app/helpers/cache_keys_helper.rb b/app/helpers/cache_keys_helper.rb index 9aa6000cc..38445ae02 100644 --- a/app/helpers/cache_keys_helper.rb +++ b/app/helpers/cache_keys_helper.rb @@ -1,4 +1,5 @@ module CacheKeysHelper + def locale_and_user_status @cache_key_user ||= calculate_user_status "#{I18n.locale}/#{@cache_key_user}" @@ -17,4 +18,5 @@ module CacheKeysHelper user_status end + end \ No newline at end of file diff --git a/app/helpers/flags_helper.rb b/app/helpers/flags_helper.rb index b54c86b48..b5ba67f41 100644 --- a/app/helpers/flags_helper.rb +++ b/app/helpers/flags_helper.rb @@ -1,4 +1,5 @@ module FlagsHelper + def show_flag_action?(flaggable) current_user && !own_flaggable?(flaggable) && !flagged?(flaggable) end @@ -24,4 +25,5 @@ module FlagsHelper flaggable.author_id == current_user.id end end + end diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index e517767e3..b852afe9c 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -1,4 +1,5 @@ module StatsHelper + def events_chart_tag(events, opt={}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} diff --git a/app/models/debate.rb b/app/models/debate.rb index 6f0543caf..61e6546b4 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -35,14 +35,6 @@ class Debate < ActiveRecord::Base # Ahoy setup visitable # Ahoy will automatically assign visit_id on create - def self.search(params) - if params[:tag] - tagged_with(params[:tag]) - else - all - end - end - def likes cached_votes_up end diff --git a/app/models/flag.rb b/app/models/flag.rb index a8be6da76..2d13d26d9 100644 --- a/app/models/flag.rb +++ b/app/models/flag.rb @@ -1,5 +1,4 @@ class Flag < ActiveRecord::Base - belongs_to :user belongs_to :flaggable, polymorphic: true, counter_cache: true diff --git a/app/models/organization.rb b/app/models/organization.rb index a4561ba7f..fa991fc05 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,5 +1,4 @@ class Organization < ActiveRecord::Base - belongs_to :user validates :name, presence: true diff --git a/app/models/setting.rb b/app/models/setting.rb index 8e1504bf3..f696ceefd 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -1,5 +1,4 @@ class Setting < ActiveRecord::Base - validates :key, presence: true, uniqueness: true default_scope { order(key: :desc) } diff --git a/app/models/verification/letter.rb b/app/models/verification/letter.rb index 566fe1fd7..077890600 100644 --- a/app/models/verification/letter.rb +++ b/app/models/verification/letter.rb @@ -1,16 +1,12 @@ class Verification::Letter include ActiveModel::Model - attr_accessor :user, :address + attr_accessor :user, :address, :verification_code validates :user, presence: true validates :address, presence: true validate :correct_address - def initialize(attrs={}) - @user = attrs[:user] - end - def save valid? && letter_requested! && @@ -22,7 +18,11 @@ class Verification::Letter end def letter_requested! - user.update(letter_requested_at: Time.now) + user.update(letter_requested_at: Time.now, letter_verification_code: four_digit_code) + end + + def verify? + user.letter_verification_code == verification_code end def update_user_address @@ -50,4 +50,8 @@ class Verification::Letter district: address[:nombre_distrito] } end + def four_digit_code + rand.to_s[2..5] + end + end diff --git a/app/models/verified_user.rb b/app/models/verified_user.rb index ca32eea5c..2113ef238 100644 --- a/app/models/verified_user.rb +++ b/app/models/verified_user.rb @@ -1,4 +1,3 @@ -# make sure document_type is being stored and queried in the correct format (Is it DNI? a number, a string?) class VerifiedUser < ActiveRecord::Base scope :by_user, -> (user) { where(document_number: user.document_number, document_type: user.document_type) } 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 %> + +En breve inauguraremos la sección de propuestas ciudadanas. Una sección que permitirá que entre todos decidamos qué debe ser Madrid. Cualquiera podrá presentar propuestas, que en caso de que sean aceptadas mayoritariamente se llevarán a cabo por parte del Ayuntamiento. Debate, propón, decide.
+La participación (entendiéndola como participación activa más allá de la lectura del contenido presente) en el Portal de Gobierno Abierto del Ayuntamiento de Madrid se regula por las presentes condiciones de uso que vinculan a todas las personas que participen en este sitio web. Por ello, cualquier persona que desee participar deberá registrarse, a cuyo fin se solicitará la aceptación de estas condiciones de uso.
+El Ayuntamiento de Madrid se reserva la facultad de modificar las presentes condiciones de uso para la participación en el Portal de Gobierno Abierto del Ayuntamiento de Madrid, cuya última versión se publicará en este sitio web.
+La participación en el Portal de Gobierno Abierto del Ayuntamiento de Madrid se regula por las presentes condiciones de uso que vinculan a todas las personas que participen en este sitio web. Cualquier persona que desee participar deberá registrarse, a cuyo fin se solicitará la aceptación de estas condiciones de uso.
+El Ayuntamiento de Madrid se reserva la facultad de modificar las presentes condiciones de uso del Portal de Gobierno Abierto del Ayuntamiento de Madrid cuya última versión se publicará en este sitio web.
+ + +A través del Portal de Gobierno Abierto, el Ayuntamiento de Madrid quiere fomentar la participación de los ciudadanos en la gestión de la ciudad, implicándoles en la generación de ideas y propuestas novedosas y viables, con el objeto de mejorar su calidad de vida. Es una apuesta decidida por una gestión más cercana a los ciudadanos que permitirá recibir sus propuestas y además, crear canales directos de comunicación con el gobierno municipal, contribuyendo a tomar las decisiones más acertadas para el interés general.
+Podrá participar cualquier persona física a partir de los 16 años que se haya registrado previamente en el Portal de Gobierno Abierto. Mediante la aceptación de estas condiciones de uso se declara tener 16 años o más. Los mayores de edad a cuyo cargo se encuentran los menores, son los plenos responsables de la actuación que tengan éstos en el Portal de Gobierno Abierto. No existe limitación en cuanto al número de debates, comentarios o propuestas a presentar por los participantes.
+Al introducir el título de las propuestas, se recomienda escribir una descripción breve y precisa con un máximo de 2000 caracteres. Para completar la argumentación se podrán asociar documentos adjuntos o de las Redes Sociales Vimeo, Youtube, Slideshare, Flickr o SoundCloud.
+ +Al ser el Ayuntamiento de Madrid un punto de encuentro cuyo objetivo es debatir, y compartir y valorar propuestas relacionadas con la mejora de la ciudad, los usuarios están obligados a hacer un uso diligente y acorde a dicho objetivo.
+El Ayuntamiento de Madrid no es responsable del uso incorrecto del Portal de Gobierno Abierto por los usuarios o de los contenidos localizados en el mismo, siendo cada usuario responsable de su uso correcto y de la legalidad de los contenidos y opiniones que haya compartido.
+El Ayuntamiento de Madrid se reserva, por lo tanto, el derecho a limitar el acceso al Portal de Gobierno Abierto del Ayuntamiento de Madrid de opiniones, informaciones, comentarios o documentos que los usuarios quieran incorporar, pudiendo instalar filtros a tal efecto. Todo ello se realizará únicamente mientras tenga el fin de preservar el objetivo fundamental del Portal de Gobierno Abierto.
+De acuerdo a la normativa legal vigente queda prohibida la utilización del Portal de Gobierno Abierto del Ayuntamiento de Madrid con fines distintos a los de debatir, compartir y valorar propuestas, y específicamente:
+Compartir cualquier contenido que pueda ser considerado como una vulneración en cualquier forma de los derechos fundamentales al honor, imagen e intimidad personal y familiar de terceros o contra la dignidad de las personas.
+Compartir imágenes o fotografías que recojan imágenes o datos personales de terceros sin haber obtenido el oportuno consentimiento de sus titulares.
+Compartir cualquier contenido que vulnere el secreto en las comunicaciones, la infracción de derechos de propiedad industrial e intelectual o de las normas reguladoras de la protección de datos de carácter personal.
+Reproducir, distribuir, compartir contenidos, informaciones o imágenes que hayan sido puestas a disposición por otros usuarios sin la autorización expresa de estos.
+Su utilización con fines de publicidad.
+La realización de cualquiera de los anteriores comportamientos permitirá al Ayuntamiento de Madrid suspender temporalmente la actividad de un participante, inhabilitar su cuenta o borrar su contenido, sin perjuicio de otras responsabilidades que puedan ser reclamadas.
+En caso de que el contenido introducido por los usuarios incorpore un enlace a otro sitio web, el Ayuntamiento de Madrid no será responsable por los daños o perjuicios derivados del acceso al enlace o a sus contenidos.
+En caso de litigio de cualquier clase o por cualquier motivo entre los participantes en el sitio web y/o un tercero, el Ayuntamiento de Madrid quedará exento de cualquier responsabilidad por reclamaciones, demandas o daños de cualquier naturaleza relacionados o derivados del litigio.
+ +Los participantes podrán acceder y navegar por el Portal de Gobierno Abierto libremente y de forma anónima. Sólo cuando quieran realizar alguna acción que implique la creación, apoyo o comentario de una propuesta, o a la participación en un debate, se le solicitará que introduzca sus credenciales, para cuya obtención será necesario registrarse previamente. El registro que permitirá participar comentando en cualquiera de las secciones, creando debates o propuestas, se realizará introduciendo los siguientes datos:
+El Portal de Gobierno Abierto también permite la identificación mediante el usuario de Facebook, Twitter y Google+.
+Para participar apoyando propuestas, al usuario se le requerirá que verifique su cuenta cumpliendo que tiene 16 años o más y está empadronado en Madrid, para lo cual se le guiará a través de una serie de pasos donde se le solicitarán datos relativos al padrón y un medio de comunicación a través del cual facilitarle uno o dos códigos seguros para completar la verificación de su cuenta (dependiendo del medio de comunicación elegido por el usuario).
+ +El usuario podrá interactuar con la herramienta interviniendo, al menos, de las siguientes formas:
+En el apartado de debates el usuario podrá participar:
+En el apartado de propuestas ciudadanas el usuario podrá participar:
+Las presentes condiciones regulan los términos aplicables al contenido remitido por los usuarios de esta plataforma a través del formulario correspondiente (en adelante, el contenido). Estas condiciones se aplican tanto al contenido inicialmente remitido al Portal de Gobierno Abierto como a cualquier contenido que se envíe con posterioridad o se manifieste al Ayuntamiento de Madrid, debiendo significarse lo siguiente:
+Como principio general, los datos personales no serán comunicados a terceros, excepto cuando la comunicación haya sido autorizada por el usuario, o la información sea requerida por la autoridad judicial, ministerio fiscal o la policía judicial, o se de alguno de los supuestos regulados en el artículo 11 de la Ley Orgánica 15/1999, de 13 de diciembre, de Protección de Datos de Carácter Personal.
+
Las normas del ordenamiento jurídico español rigen de manera exclusiva estas condiciones de uso. Cualquier disputa, controversia o reclamación derivada de estas condiciones de uso, o el incumplimiento, rescisión o invalidación de estas, se resolverán exclusivamente ante los juzgados competentes.
+ +El Ayuntamiento de Madrid se reserva el derecho de revisar las presentes condiciones de uso y la política de privacidad en cualquier momento y por cualquier razón. En dicho caso, los usuarios registrados serán avisados a través de este espacio en línea y, si continúan utilizando el Portal de Gobierno Abierto, se entenderán aceptadas las modificaciones introducidas.
+Este Portal de Gobierno Abierto es software libre, con licencia AGPLv3, esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica, cuando se libera.
- -No sólo puedes utilizar libremente este portal en tu municipio, sino que desde el Ayuntamiento de Madrid vamos a ayudarte todo lo posible a que lo hagas, así que si estás interesado, escríbenos a ag.gobiernoabierto@madrid.es [imagen o algo así del e-mail para que no nos troléen demasiado los spammers]
- -Si eres programador, puedes ver el código y ayudarnos a mejorarlo en https://github.com/ayuntamientomadrid
- -En breve inauguraremos la sección de propuestas ciudadanas. Una sección que permitirá que entre todos decidamos qué debe ser Madrid. Cualquiera podrá presentar propuestas, que en caso de que sean aceptadas mayoritariamente se llevarán a cabo por parte del Ayuntamiento. Debate, propón, decide.
- -El nuevo gobierno del Ayuntamiento de Madrid ha creado un nuevo área de gobierno: Participación Ciudadana, Transparencia y Gobierno Abierto. El objetivo de este área es claro: que los madrileños puedan decidir directamente la política de la ciudad, y que todo lo que ocurra en el Ayuntamiento, hasta el último rincón, esté a la vista de todos.
- -Iremos publicando nuestros avances, las novedades y cualquier otra cosa que queramos compartir con vosotros en nuestro blog: [URL todavía pendiente]
- -Y podéis escribirnos para cualquier cosa a: ag.gobiernoabierto@madrid.es [imagen o algo así del e-mail para que no nos troléen demasiado los spammers]
- -A continuación os presentamos algunas de los principales novedades que tenemos planeadas poner en marcha, aparte de las que vayamos diseñando o se nos vayan proponiendo durante la legislatura:
- -Utilízalo en tu municipio libremente o ayúdanos a mejorarlo, es software libre.
+ +Este Portal de Gobierno Abierto es software libre, con licencia AGPLv3, esto significa en palabras sencillas, que cualquiera puede libremente usar el código, copiarlo, verlo en detalle, modificarlo, y redistribuirlo al mundo con las modificaciones que quiera (manteniendo el que otros puedan a su vez hacer lo mismo). Porque creemos que la cultura es mejor y más rica cuando se libera.
+ +No sólo puedes utilizar libremente este portal en tu municipio, sino que desde el Ayuntamiento de Madrid vamos a ayudarte todo lo posible a que lo hagas, así que si estás interesado, escríbenos a ag.gobiernoabierto@madrid.es
+ +Si eres programador, puedes ver el código y ayudarnos a mejorarlo en github.
+El nuevo gobierno del Ayuntamiento de Madrid ha creado un nuevo área de gobierno: Participación Ciudadana, Transparencia y Gobierno Abierto. El objetivo de este área es claro: que los madrileños puedan decidir directamente la política de la ciudad, y que todo lo que ocurra en el Ayuntamiento, hasta el último rincón, esté a la vista de todos.
+ +Iremos publicando nuestros avances, las novedades y cualquier otra cosa que queramos compartir con vosotros en nuestro blog.
+ +Y podéis escribirnos para cualquier cosa a la dirección ag.gobiernoabierto@madrid.es
+ +A continuación os presentamos algunas de los principales novedades que tenemos planeadas poner en marcha, aparte de las que vayamos diseñando o se nos vayan proponiendo durante la legislatura:
+ +<%= @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" + 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 maximum security code 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" + edit: + title: "Security code confirmation" + confirmation_code: "Enter the security code in your letter" + update: + error: "Incorrect confirmation code" + flash: + success: "Correct code. Your account is verified" 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 169decc9b..5da534899 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 incorrecto' + 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,33 @@ 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" + 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" + edit: + title: "Confirmación de código de seguridad" + confirmation_code: "Introduce el código que has recibido en tu carta" + update: + error: "Código de verificación incorrecto" + flash: + success: "Código correcto. Tu cuenta ya está verificada" 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/config/routes.rb b/config/routes.rb index 3bef1e3d9..98c88894d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,7 +48,7 @@ Rails.application.routes.draw do resource :sms, controller: "sms", only: [:new, :create, :edit, :update] resource :verified_user, controller: "verified_user", only: [:show] resource :email, controller: "email", only: [:new, :show, :create] - resource :letter, controller: "letter", only: [:new, :create] + resource :letter, controller: "letter", only: [:new, :create, :edit, :update] end namespace :admin do diff --git a/db/migrate/20150902191315_add_letter_verification_code_to_users.rb b/db/migrate/20150902191315_add_letter_verification_code_to_users.rb new file mode 100644 index 000000000..83142122e --- /dev/null +++ b/db/migrate/20150902191315_add_letter_verification_code_to_users.rb @@ -0,0 +1,5 @@ +class AddLetterVerificationCodeToUsers < ActiveRecord::Migration + def change + add_column :users, :letter_verification_code, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index dce574423..64eb92dda 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -65,6 +65,7 @@ ActiveRecord::Schema.define(version: 20150903142924) do t.datetime "created_at" t.datetime "updated_at" t.datetime "hidden_at" + t.integer "children_count", default: 0 t.integer "flags_count", default: 0 t.datetime "ignored_flag_at" t.integer "moderator_id" @@ -90,8 +91,8 @@ ActiveRecord::Schema.define(version: 20150903142924) do t.integer "author_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.datetime "hidden_at" t.string "visit_id" + t.datetime "hidden_at" t.integer "flags_count", default: 0 t.datetime "ignored_flag_at" t.integer "cached_votes_total", default: 0 @@ -198,13 +199,12 @@ ActiveRecord::Schema.define(version: 20150903142924) do t.string "unconfirmed_email" t.boolean "email_on_debate_comment", default: false t.boolean "email_on_comment_reply", default: false + t.string "phone_number", limit: 30 t.string "official_position" t.integer "official_level", default: 0 t.datetime "hidden_at" - t.string "phone_number", limit: 30 - t.string "username" - t.datetime "confirmed_hide_at" t.string "sms_confirmation_code" + t.string "username" t.string "document_number" t.string "document_type" t.datetime "residence_verified_at" @@ -216,6 +216,8 @@ ActiveRecord::Schema.define(version: 20150903142924) do t.string "unconfirmed_phone" t.string "confirmed_phone" t.datetime "letter_requested_at" + t.datetime "confirmed_hide_at" + t.string "letter_verification_code" end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree 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/lib/application_responder.rb b/lib/application_responder.rb index cc3e58885..daef415e3 100644 --- a/lib/application_responder.rb +++ b/lib/application_responder.rb @@ -1,8 +1,4 @@ class ApplicationResponder < ActionController::Responder include Responders::FlashResponder include Responders::HttpCacheResponder - - # Redirects resources to the collection path (index action) instead - # of the resource path (show action) for POST/PUT/DELETE requests. - # include Responders::CollectionResponder end 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/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index e85b7c54d..760e57ce6 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -8,8 +8,8 @@ describe PagesController do expect(response).to be_ok end - it 'should include a legal page' do - get :legal + it 'should include a conditions page' do + get :conditions expect(response).to be_ok end diff --git a/spec/features/admin/officials_spec.rb b/spec/features/admin/officials_spec.rb index e57da3c03..926f6681e 100644 --- a/spec/features/admin/officials_spec.rb +++ b/spec/features/admin/officials_spec.rb @@ -29,7 +29,7 @@ feature 'Admin officials' do expect(page).to have_content @official.email fill_in 'user_official_position', with: 'School Teacher' - select '3', from: 'user_official_level' + select '3', from: 'user_official_level', exact: false click_button 'Update User' expect(page).to have_content 'Official position saved!' @@ -52,7 +52,7 @@ feature 'Admin officials' do click_link @citizen.name fill_in 'user_official_position', with: 'Hospital manager' - select '4', from: 'user_official_level' + select '4', from: 'user_official_level', exact: false click_button 'Update User' expect(page).to have_content 'Official position saved!' @@ -75,4 +75,4 @@ feature 'Admin officials' do expect(page).to_not have_content @citizen.name expect(page).to_not have_content @official.name end -end \ No newline at end of file +end diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb index b7a53eeb7..f7e62c067 100644 --- a/spec/features/comments_spec.rb +++ b/spec/features/comments_spec.rb @@ -31,7 +31,7 @@ feature 'Comments' do expect(page).to have_content("1") expect(page).to have_content("2") expect(page).to_not have_content("3") - click_link "Next" + click_link "Next", exact: false end expect(page).to have_css('.comment', count: 2) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index f6e07b844..005232bb0 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -28,7 +28,7 @@ feature 'Debates' do expect(page).to have_content("1") expect(page).to have_content("2") expect(page).to_not have_content("3") - click_link "Next" + click_link "Next", exact: false end expect(page).to have_selector('#debates .debate', count: 2) @@ -60,7 +60,7 @@ feature 'Debates' do fill_in 'debate_captcha', with: correct_captcha_text check 'debate_terms_of_service' - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully created.' expect(page).to have_content 'Acabar con los desahucios' @@ -78,13 +78,13 @@ feature 'Debates' do fill_in 'debate_captcha', with: "wrongText!" check 'debate_terms_of_service' - click_button "Create Debate" + click_button "Start a debate" expect(page).to_not have_content "Debate was successfully created." expect(page).to have_content "1 error" fill_in 'debate_captcha', with: correct_captcha_text - click_button "Create Debate" + click_button "Start a debate" expect(page).to have_content "Debate was successfully created." end @@ -100,7 +100,7 @@ feature 'Debates' do fill_in 'debate_captcha', with: correct_captcha_text check 'debate_terms_of_service' - click_button "Create Debate" + click_button "Start a debate" expect(page).to_not have_content "Debate was successfully created." expect(page).to have_content "1 error" @@ -115,7 +115,7 @@ feature 'Debates' do login_as(author) visit new_debate_path - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content error_message end @@ -129,7 +129,7 @@ feature 'Debates' do fill_in 'debate_captcha', with: correct_captcha_text check 'debate_terms_of_service' - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully created.' expect(page).to have_content 'A test' @@ -161,7 +161,7 @@ feature 'Debates' do find('.js-add-tag-link', text: tag_name).click end - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully created.' ['Medio Ambiente', 'Ciencia'].each do |tag_name| @@ -179,7 +179,7 @@ feature 'Debates' do fill_in 'debate_tag_list', with: 'user_id=1, &a=3, ' - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully created.' expect(page).to have_content 'user_id1' @@ -222,7 +222,7 @@ feature 'Debates' do fill_in 'debate_description', with: "Let's..." fill_in 'debate_captcha', with: correct_captcha_text - click_button "Update Debate" + click_button "Start a debate" expect(page).to have_content "Debate was successfully updated." expect(page).to have_content "End child poverty" @@ -235,7 +235,7 @@ feature 'Debates' do visit edit_debate_path(debate) fill_in 'debate_title', with: "" - click_button 'Update Debate' + click_button 'Start a debate' expect(page).to have_content error_message end @@ -249,13 +249,13 @@ feature 'Debates' do fill_in 'debate_title', with: "New title" fill_in 'debate_captcha', with: "wrong!" - click_button "Update Debate" + click_button "Start a debate" expect(page).to_not have_content "Debate was successfully updated." expect(page).to have_content "1 error" fill_in 'debate_captcha', with: correct_captcha_text - click_button "Update Debate" + click_button "Start a debate" expect(page).to have_content "Debate was successfully updated." end @@ -271,7 +271,7 @@ feature 'Debates' do fill_in 'debate_title', with: "" fill_in 'debate_captcha', with: correct_captcha_text - click_button "Update Debate" + click_button "Start a debate" expect(page).to_not have_content "Debate was successfully updated." expect(page).to have_content "1 error" @@ -407,34 +407,4 @@ feature 'Debates' do expect(@most_liked_debate.title).to appear_before(@most_voted_debate.title) end end - - feature 'Debates can be filtered by tags', :js do - let!(:debate1) { create(:debate, tag_list: ["Deporte", "Corrupción"]) } - let!(:debate2) { create(:debate, tag_list: ["Deporte", "Fiestas populares"]) } - let!(:debate3) { create(:debate, tag_list: ["Corrupción", "Fiestas populares"]) } - - scenario 'By default no tag filter is applied' do - visit debates_path - - expect(page).to have_content('Filter by topic') - expect(page).not_to have_content('with the topic') - expect(page).to have_selector('#debates .debate', count: 3) - end - - scenario 'Debates are filtered by single tag' do - visit debates_path - - select('Deporte', from: 'tag-filter') - - expect(page).not_to have_content('Filter by topic') - expect(page).not_to have_select('tag-filter') - expect(page).to have_content('with the topic') - expect(current_url).to include('tag=Deporte') - - expect(page).to have_selector('#debates .debate', count: 2) - expect(page).to_not have_content(debate3.title) - expect(page).to have_content(debate1.title) - expect(page).to have_content(debate2.title) - end - end end diff --git a/spec/features/organizations_spec.rb b/spec/features/organizations_spec.rb index dcbaaab51..a710b0646 100644 --- a/spec/features/organizations_spec.rb +++ b/spec/features/organizations_spec.rb @@ -32,7 +32,7 @@ feature 'Organizations' do scenario 'Shared links' do visit new_user_registration_path - expect(page).to have_link "Sign up as an organization" + expect(page).to have_link "Sign up as an organization / collective" visit new_organization_registration_path expect(page).to have_link "Sign up" diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index d6c1eba8b..80106cf3b 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -72,7 +72,7 @@ feature 'Tags' do fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda" - click_button 'Create Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully created.' expect(page).to have_content 'Economía' @@ -90,7 +90,7 @@ feature 'Tags' do fill_in 'debate_tag_list', with: "Economía, Hacienda" fill_in 'debate_captcha', with: correct_captcha_text - click_button 'Update Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully updated.' within('.tags') do @@ -107,7 +107,7 @@ feature 'Tags' do fill_in 'debate_tag_list', with: "" fill_in 'debate_captcha', with: correct_captcha_text - click_button 'Update Debate' + click_button 'Start a debate' expect(page).to have_content 'Debate was successfully updated.' expect(page).to_not have_content 'Economía' diff --git a/spec/features/verification/email_spec.rb b/spec/features/verification/email_spec.rb index 336f4946a..95f6360c5 100644 --- a/spec/features/verification/email_spec.rb +++ b/spec/features/verification/email_spec.rb @@ -19,7 +19,7 @@ feature 'Verify email' do within("#verified_user_#{verified_user.id}_email") do expect(page).to have_content 'roc*@example.com' - click_button "Send" + click_button "Send code" end expect(page).to have_content 'We have send you a confirmation email to your email account: rock@example.com' @@ -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 @@ -58,7 +58,7 @@ feature 'Verify email' do visit verified_user_path verified_user.destroy - click_button "Send" + click_button "Send code" expect(page).to have_content "There was a problem sending you an email to your account" end diff --git a/spec/features/verification/letter_spec.rb b/spec/features/verification/letter_spec.rb index fa4a451db..b62ae00f8 100644 --- a/spec/features/verification/letter_spec.rb +++ b/spec/features/verification/letter_spec.rb @@ -2,15 +2,45 @@ require 'rails_helper' feature 'Verify Letter' do - scenario 'Send letter level 2 verified with phone' do + scenario 'Verify' do user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111") login_as(user) visit new_letter_path - click_button "Send me a letter" + click_button "Send me a letter with the code" - expect(page).to have_content "You will receive a letter to your home address" + expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data." + + user.reload + fill_in "letter_verification_code", with: user.letter_verification_code + click_button "Send" + + expect(page).to have_content "Correct code. Your account is verified" + end + + scenario 'Go to office instead of send letter' do + user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111") + + login_as(user) + visit new_letter_path + + expect(page).to have_link "See Office of Citizen", href: "http://www.madrid.es/portales/munimadrid/es/Inicio/El-Ayuntamiento/Atencion-al-ciudadano/Oficinas-de-Atencion-al-Ciudadano?vgnextfmt=default&vgnextchannel=5b99cde2e09a4310VgnVCM1000000b205a0aRCRD" + end + + scenario 'Errors on verification code' do + user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111") + + login_as(user) + visit new_letter_path + + click_button "Send me a letter with the code" + expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data." + + fill_in "letter_verification_code", with: "1" + click_button "Send" + + expect(page).to have_content "Incorrect confirmation code" end scenario "Error accessing address from CensusApi" do @@ -21,22 +51,11 @@ feature 'Verify Letter' do allow_any_instance_of(CensusApi).to receive(:address).and_return(nil) - click_button "Send me a letter" + click_button "Send me a letter with the code" expect(page).to have_content "We could not verify your address with the Census please try again later" end - scenario 'Send letter level 2 user verified with email' do - user = create(:user, residence_verified_at: Time.now, confirmed_phone: "611111111") - - login_as(user) - visit new_letter_path - - click_button "Send me a letter" - - expect(page).to have_content "You will receive a letter to your home address" - end - scenario "Deny access unless verified residence" do user = create(:user) @@ -53,7 +72,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..d755cf424 100644 --- a/spec/features/verification/level_three_verification_spec.rb +++ b/spec/features/verification/level_three_verification_spec.rb @@ -17,7 +17,7 @@ feature 'Level three verification' do verify_residence within("#verified_user_#{verified_user.id}_phone") do - click_button "Send" + click_button "Send code" end expect(page).to have_content 'Security code confirmation' @@ -26,12 +26,10 @@ feature 'Level three verification' do fill_in 'sms_confirmation_code', with: user.sms_confirmation_code click_button 'Send' - 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 @@ -50,7 +48,7 @@ feature 'Level three verification' do verify_residence within("#verified_user_#{verified_user.id}_email") do - click_button "Send" + click_button "Send code" end expect(page).to have_content 'We have send you a confirmation email to your email account: rock@example.com' @@ -61,7 +59,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 @@ -85,8 +83,14 @@ feature 'Level three verification' do expect(page).to have_content 'Correct code' - click_button "Send me a letter" + click_button "Send me a letter with the code" - expect(page).to have_content "You will receive a letter to your home address" + expect(page).to have_content "Thank you for requesting a maximum security code in a few days we will send it to the address on your census data." + + user.reload + fill_in "letter_verification_code", with: user.letter_verification_code + click_button "Send" + + expect(page).to have_content "Correct code. Your account is verified" end end \ No newline at end of file diff --git a/spec/features/verification/residence_spec.rb b/spec/features/verification/residence_spec.rb index 61231ea7d..fa11fa48b 100644 --- a/spec/features/verification/residence_spec.rb +++ b/spec/features/verification/residence_spec.rb @@ -15,7 +15,7 @@ feature 'Residence' do fill_in 'residence_postal_code', with: '28013' check 'residence_terms_of_service' - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content 'Residence verified' end @@ -27,7 +27,7 @@ feature 'Residence' do visit account_path click_link 'Verify my account' - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content /\d errors? prevented your residence verification/ end @@ -47,7 +47,7 @@ feature 'Residence' do fill_in 'residence_postal_code', with: '28013' check 'residence_terms_of_service' - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content 'The census of the city of Madrid could not verify your information' end @@ -68,11 +68,11 @@ feature 'Residence' do fill_in 'residence_postal_code', with: '28013' check 'residence_terms_of_service' - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content 'The census of the city of Madrid could not verify your information' end - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content 'You have reached the maximum number of Census verification tries' expect(URI.parse(current_url).path).to eq(account_path) diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index e68bb3ee1..c0989e180 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -73,7 +73,7 @@ feature 'Verified users' do visit verified_user_path within("#verified_user_#{verified_user.id}_email") do - click_button "Send" + click_button "Send code" end expect(page).to have_content 'We have send you a confirmation email to your email account: rock@example.com' @@ -95,7 +95,7 @@ feature 'Verified users' do visit verified_user_path within("#verified_user_#{verified_user.id}_phone") do - click_button "Send" + click_button "Send code" end expect(page).to have_content 'Enter the confirmation code' diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 0378dabab..fc4130354 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -174,21 +174,6 @@ describe Debate do end end - describe "#search" do - let!(:economy) { create(:debate, tag_list: "Economy") } - let!(:health) { create(:debate, tag_list: "Health") } - - it "returns debates tagged with params tag" do - params = {tag: "Economy"} - expect(Debate.search(params)).to match_array([economy]) - end - - it "returns all debates if no parameters" do - params = {} - expect(Debate.search(params)).to match_array([economy, health]) - end - end - describe '#default_order' do let!(:economy) { create(:debate) } let!(:health) { create(:debate) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c2f5db0fe..b0257d60c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -22,5 +22,6 @@ RSpec.configure do |config| end Capybara.javascript_driver = :poltergeist +Capybara.exact = true OmniAuth.config.test_mode = true diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index d8b45ffc2..1bcc971f4 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -106,7 +106,7 @@ module CommonActions fill_in 'residence_postal_code', with: '28013' check 'residence_terms_of_service' - click_button 'Verify' + click_button 'Verify residence' expect(page).to have_content 'Residence verified' end end