From 2a7ff2270e2c97f50d6a5991b01b3cedf7676213 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 18 Apr 2016 03:22:53 +0200 Subject: [PATCH 01/39] sends zip file with test data --- Gemfile | 1 + Gemfile.lock | 59 ++++++++++--------- .../admin/newsletters_controller.rb | 17 ++++++ app/views/admin/_menu.html.erb | 7 +++ app/views/admin/newsletters/index.html.erb | 1 + config/routes.rb | 3 + 6 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 app/controllers/admin/newsletters_controller.rb create mode 100644 app/views/admin/newsletters/index.html.erb diff --git a/Gemfile b/Gemfile index 05d1379c5..52c854618 100644 --- a/Gemfile +++ b/Gemfile @@ -64,6 +64,7 @@ gem 'tolk', '~> 2.0.0' # Web interface for translations gem 'browser' gem 'turnout', '~> 2.4.0' gem 'redcarpet', '~> 3.4.0' +gem 'rubyzip', '~> 1.2.0' gem 'paperclip' diff --git a/Gemfile.lock b/Gemfile.lock index 0989276ef..9c05a53e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,8 +35,8 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts-as-taggable-on (4.0.0) - activerecord (>= 4.0) + acts-as-taggable-on (5.0.0) + activerecord (>= 4.2.8) acts_as_votable (0.10.0) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) @@ -65,7 +65,7 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) bcrypt (3.1.11) - browser (2.3.0) + browser (2.4.0) builder (3.2.3) bullet (5.5.1) activesupport (>= 3.0.0) @@ -97,7 +97,7 @@ GEM ckeditor (4.2.3) cocaine orm_adapter (~> 0.5.0) - climate_control (0.1.0) + climate_control (0.2.0) cliver (0.3.2) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) @@ -117,8 +117,8 @@ GEM tins (~> 1.6) daemons (1.2.4) dalli (2.7.6) - database_cleaner (1.5.3) - debug_inspector (0.0.2) + database_cleaner (1.6.1) + debug_inspector (0.0.3) delayed_job (4.1.2) activesupport (>= 3.0, < 5.1) delayed_job_active_record (4.1.1) @@ -142,10 +142,10 @@ GEM json thread thread_safe - email_spec (2.1.0) + email_spec (2.1.1) htmlentities (~> 4.3.3) launchy (~> 2.1) - mail (~> 2.6.3) + mail (~> 2.6) errbase (0.0.3) erubis (2.7.0) execjs (2.7.0) @@ -171,9 +171,9 @@ GEM fuubar (2.2.0) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) - geocoder (1.4.3) - globalid (0.3.7) - activesupport (>= 4.1.0) + geocoder (1.4.4) + globalid (0.4.0) + activesupport (>= 4.2.0) groupdate (3.2.0) activesupport (>= 3) gyoku (1.3.1) @@ -181,8 +181,9 @@ GEM hashie (3.5.5) highline (1.7.8) htmlentities (4.3.4) - httpi (2.4.1) + httpi (2.4.2) rack + socksify i18n (0.8.1) i18n-tasks (0.9.15) activesupport (>= 4.0.2) @@ -239,7 +240,7 @@ GEM mime-types-data (3.2016.0521) mimemagic (0.3.2) mini_portile2 (2.1.0) - minitest (5.10.1) + minitest (5.10.2) multi_json (1.12.1) multi_xml (0.6.0) multipart-post (2.0.0) @@ -250,7 +251,7 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) nori (2.6.0) - oauth (0.5.1) + oauth (0.5.2) oauth2 (1.3.1) faraday (>= 0.8, < 0.12) jwt (~> 1.0) @@ -300,7 +301,7 @@ GEM public_suffix (2.0.5) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.5) + rack (1.6.8) rack-accept (0.4.5) rack (>= 0.4) rack-attack (5.0.1) @@ -368,13 +369,14 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) + rubyzip (1.2.1) rvm1-capistrano3 (1.4.0) capistrano (~> 3.0) sshkit (>= 1.2) safe_yaml (1.0.4) safely_block (0.2.0) errbase - sass (3.4.23) + sass (3.4.24) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) @@ -393,12 +395,13 @@ GEM docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.1) sitemap_generator (5.3.1) builder (~> 3.0) social-share-button (0.10.0) coffee-rails - spring (2.0.1) + socksify (1.7.1) + spring (2.0.2) activesupport (>= 4.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) @@ -418,19 +421,20 @@ GEM net-ssh (>= 2.8.0) term-ansicolor (1.6.0) tins (~> 1.0) - terminal-table (1.7.3) - unicode-display_width (~> 1.1.1) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thor (0.19.4) thread (0.2.2) thread_safe (0.3.6) tilt (2.0.7) timecop (0.8.1) - tins (1.13.2) + tins (1.14.0) tolk (2.0.0) rails (>= 4.0) safe_yaml (>= 0.8.6) - turbolinks (2.5.3) - coffee-rails + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.3) turnout (2.4.0) i18n (~> 0.7) rack (>= 1.3, < 3) @@ -440,14 +444,14 @@ GEM thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.1.3) + unicode-display_width (1.2.1) unicorn (5.3.0) kgio (~> 2.6) raindrops (~> 0.7) uniform_notifier (1.10.0) - user_agent_parser (2.3.0) + user_agent_parser (2.3.1) uuidtools (2.1.5) - warden (1.2.6) + warden (1.2.7) rack (>= 1.0) wasabi (3.5.0) httpi (~> 2.0) @@ -525,6 +529,7 @@ DEPENDENCIES rollbar (~> 2.14.1) rspec-rails (~> 3.6) rubocop (~> 0.48.1) + rubyzip (~> 1.2.0) rvm1-capistrano3 sass-rails (~> 5.0, >= 5.0.4) savon @@ -542,4 +547,4 @@ DEPENDENCIES whenever BUNDLED WITH - 1.14.6 + 1.15.0 diff --git a/app/controllers/admin/newsletters_controller.rb b/app/controllers/admin/newsletters_controller.rb new file mode 100644 index 000000000..f09a92e0c --- /dev/null +++ b/app/controllers/admin/newsletters_controller.rb @@ -0,0 +1,17 @@ +require 'zip' +class Admin::NewslettersController < Admin::BaseController + + def index + end + + def users + folder = Rails.root + "/tmp/" + zipfile_name = folder + "emails.zip" + + Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| + zipfile.get_output_stream("emails.txt") { |os| os.write 'peter@example.com' } + end + send_file(File.join(folder + "emails.zip"), :type => 'application/zip') + end + +end \ No newline at end of file diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 0b9929f46..c02ad4ede 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -162,5 +162,12 @@ <% end %> <% end %> + +
  • > + <%= link_to admin_newsletters_path do %> + + Newsletter + <% end %> +
  • diff --git a/app/views/admin/newsletters/index.html.erb b/app/views/admin/newsletters/index.html.erb new file mode 100644 index 000000000..d851f5fc2 --- /dev/null +++ b/app/views/admin/newsletters/index.html.erb @@ -0,0 +1 @@ +<%= link_to 'users', users_admin_newsletters_path %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4007595db..c016cce56 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -239,6 +239,9 @@ Rails.application.routes.draw do end resource :activity, controller: :activity, only: :show + resources :newsletters, only: :index do + get :users, on: :collection + end resource :stats, only: :show do get :proposal_notifications, on: :collection get :direct_messages, on: :collection From 8f4eec2b8efdf95d2139acc1a68c7b4576c0ee48 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 18 Apr 2016 03:53:23 +0200 Subject: [PATCH 02/39] zips all users with newsletter activated --- app/controllers/admin/newsletters_controller.rb | 4 +++- app/models/user.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/newsletters_controller.rb b/app/controllers/admin/newsletters_controller.rb index f09a92e0c..fb922c3dd 100644 --- a/app/controllers/admin/newsletters_controller.rb +++ b/app/controllers/admin/newsletters_controller.rb @@ -9,7 +9,9 @@ class Admin::NewslettersController < Admin::BaseController zipfile_name = folder + "emails.zip" Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| - zipfile.get_output_stream("emails.txt") { |os| os.write 'peter@example.com' } + zipfile.get_output_stream("emails.txt") do |os| + os.write User.newsletter.pluck(:email).join("\n") + end end send_file(File.join(folder + "emails.zip"), :type => 'application/zip') end diff --git a/app/models/user.rb b/app/models/user.rb index c3038c88a..88651630f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -52,6 +52,7 @@ class User < ActiveRecord::Base scope :moderators, -> { joins(:moderator) } scope :organizations, -> { joins(:organization) } scope :officials, -> { where("official_level > 0") } + scope :newsletter, -> { where(newsletter: true) } scope :for_render, -> { includes(:organization) } scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) } scope :email_digest, -> { where(email_digest: true) } From 80be0c6b65585a9b14cb2ebda90b614190a9c376 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 18 Apr 2016 05:15:16 +0200 Subject: [PATCH 03/39] refactors zip file creation --- .../admin/newsletters_controller.rb | 13 +++------- lib/newsletter_zip.rb | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 lib/newsletter_zip.rb diff --git a/app/controllers/admin/newsletters_controller.rb b/app/controllers/admin/newsletters_controller.rb index fb922c3dd..60895dc0c 100644 --- a/app/controllers/admin/newsletters_controller.rb +++ b/app/controllers/admin/newsletters_controller.rb @@ -1,19 +1,12 @@ -require 'zip' class Admin::NewslettersController < Admin::BaseController def index end def users - folder = Rails.root + "/tmp/" - zipfile_name = folder + "emails.zip" - - Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| - zipfile.get_output_stream("emails.txt") do |os| - os.write User.newsletter.pluck(:email).join("\n") - end - end - send_file(File.join(folder + "emails.zip"), :type => 'application/zip') + zip = NewsletterZip.new('emails') + zip.create + send_file(File.join(zip.path), type: 'application/zip') end end \ No newline at end of file diff --git a/lib/newsletter_zip.rb b/lib/newsletter_zip.rb new file mode 100644 index 000000000..565b9580d --- /dev/null +++ b/lib/newsletter_zip.rb @@ -0,0 +1,25 @@ +require 'zip' +class NewsletterZip + attr_accessor :filename + + def initialize(filename) + @filename = filename + end + + def emails + User.newsletter.pluck(:email).join("\n") + end + + def path + Rails.root + "/tmp/#{filename}.zip" + end + + def create + Zip::File.open("#{filename}.zip", Zip::File::CREATE) do |zipfile| + zipfile.get_output_stream("#{filename}.txt") do |file| + file.write emails + end + end + end + +end \ No newline at end of file From 9110fdad3a08ed6033257051a45c09c1071f024a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 18 Apr 2016 10:30:08 +0200 Subject: [PATCH 04/39] adds translations --- app/views/admin/_menu.html.erb | 2 +- config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index c02ad4ede..4921176c3 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -166,7 +166,7 @@
  • > <%= link_to admin_newsletters_path do %> - Newsletter + <%= t("admin.menu.newsletter") %> <% end %>
  • diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 1d1bf9cb0..fbe8921fd 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -205,6 +205,7 @@ en: hidden_users: Hidden users managers: Managers moderators: Moderators + newsletter: Newsletters valuators: Valuators poll_officers: Poll officers polls: Polls diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index b42843d70..a81e9eed6 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -205,6 +205,7 @@ es: hidden_users: Usuarios bloqueados managers: Gestores moderators: Moderadores + newsletter: Newsletters valuators: Evaluadores poll_officers: Presidentes de mesa polls: Votaciones From 04c33d1327bff12d3f5b8e91d1715ce27e54ff5f Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 18 Apr 2016 11:35:36 +0200 Subject: [PATCH 05/39] Improves styles for admin newsletters --- app/views/admin/_menu.html.erb | 2 +- app/views/admin/newsletters/index.html.erb | 4 +++- config/locales/admin.en.yml | 4 ++++ config/locales/admin.es.yml | 6 +++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 4921176c3..43c53df36 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -165,7 +165,7 @@
  • > <%= link_to admin_newsletters_path do %> - + <%= t("admin.menu.newsletter") %> <% end %>
  • diff --git a/app/views/admin/newsletters/index.html.erb b/app/views/admin/newsletters/index.html.erb index d851f5fc2..b7b43c6fc 100644 --- a/app/views/admin/newsletters/index.html.erb +++ b/app/views/admin/newsletters/index.html.erb @@ -1 +1,3 @@ -<%= link_to 'users', users_admin_newsletters_path %> \ No newline at end of file +

    <%= t("admin.newsletters.index.title") %>

    + +<%= link_to t("admin.newsletters.index.button"), users_admin_newsletters_path, class: "button" %> \ No newline at end of file diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index fbe8921fd..72010670d 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -237,6 +237,10 @@ en: email_placeholder: Search user by email search: Search user_not_found: User not found + newsletters: + index: + title: Newsletters + button: Download zip with users list valuators: index: title: Valuators diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a81e9eed6..5b18eb445 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -205,7 +205,7 @@ es: hidden_users: Usuarios bloqueados managers: Gestores moderators: Moderadores - newsletter: Newsletters + newsletter: Envío de Newsletters valuators: Evaluadores poll_officers: Presidentes de mesa polls: Votaciones @@ -237,6 +237,10 @@ es: email_placeholder: Buscar usuario por email search: Buscar user_not_found: Usuario no encontrado + newsletters: + index: + title: Envío de newsletters + button: Descargar zip con lista de usuarios valuators: index: title: Evaluadores From a05a20b2b67575c961a544f71b2ade53f895358b Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 18 Apr 2016 11:48:19 +0200 Subject: [PATCH 06/39] creates zip file in tmp folder --- lib/newsletter_zip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/newsletter_zip.rb b/lib/newsletter_zip.rb index 565b9580d..dead7cf82 100644 --- a/lib/newsletter_zip.rb +++ b/lib/newsletter_zip.rb @@ -15,7 +15,7 @@ class NewsletterZip end def create - Zip::File.open("#{filename}.zip", Zip::File::CREATE) do |zipfile| + Zip::File.open(path, Zip::File::CREATE) do |zipfile| zipfile.get_output_stream("#{filename}.txt") do |file| file.write emails end From d922d093eec1ee4c209f07af9ec1e57142931cce Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 19:52:14 +0200 Subject: [PATCH 07/39] Add specifiy version to multiple gems that didn't had one at the Gemfile --- Gemfile | 12 ++++++------ Gemfile.lock | 25 ++++++++++++------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index 52c854618..73d7dd4f6 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'coffee-rails', '~> 4.2.1' gem 'jquery-rails', '~> 4.3.1' gem 'jquery-ui-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' +gem 'turbolinks', '~> 2.5.3' # Fix sprockets on the gem 'sprockets', '~> 3.7.1' @@ -33,7 +33,7 @@ gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'kaminari', '~> 1.0.1' gem 'ancestry', '~> 2.2.2' -gem 'acts-as-taggable-on' +gem 'acts-as-taggable-on', '~> 4.0.0' gem 'responders', '~> 2.4.0' gem 'foundation-rails', '~> 6.2.4.0' gem 'foundation_rails_helper', '~> 2.0.0' @@ -61,7 +61,7 @@ gem 'ahoy_matey', '~> 1.6.0' gem 'groupdate', '~> 3.2.0' # group temporary data gem 'tolk', '~> 2.0.0' # Web interface for translations -gem 'browser' +gem 'browser', '~> 2.3.0' gem 'turnout', '~> 2.4.0' gem 'redcarpet', '~> 3.4.0' gem 'rubyzip', '~> 1.2.0' @@ -72,7 +72,7 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' + gem 'spring', '~> 2.0.1' gem 'spring-commands-rspec' gem 'rspec-rails', '~> 3.6' gem 'capybara', '~> 2.14.0' @@ -94,10 +94,10 @@ group :development, :test do end group :test do - gem 'database_cleaner' + gem 'database_cleaner', '~> 1.5.3' gem 'poltergeist', '~> 1.15.0' gem 'coveralls', '~> 0.8.21', require: false - gem 'email_spec' + gem 'email_spec', '~> 2.1.0' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 9c05a53e4..61e7db354 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -35,8 +35,8 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - acts-as-taggable-on (5.0.0) - activerecord (>= 4.2.8) + acts-as-taggable-on (4.0.0) + activerecord (>= 4.0) acts_as_votable (0.10.0) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) @@ -65,7 +65,7 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) bcrypt (3.1.11) - browser (2.4.0) + browser (2.3.0) builder (3.2.3) bullet (5.5.1) activesupport (>= 3.0.0) @@ -117,7 +117,7 @@ GEM tins (~> 1.6) daemons (1.2.4) dalli (2.7.6) - database_cleaner (1.6.1) + database_cleaner (1.5.3) debug_inspector (0.0.3) delayed_job (4.1.2) activesupport (>= 3.0, < 5.1) @@ -432,9 +432,8 @@ GEM tolk (2.0.0) rails (>= 4.0) safe_yaml (>= 0.8.6) - turbolinks (5.0.1) - turbolinks-source (~> 5) - turbolinks-source (5.0.3) + turbolinks (2.5.3) + coffee-rails turnout (2.4.0) i18n (~> 0.7) rack (>= 1.3, < 3) @@ -472,11 +471,11 @@ PLATFORMS ruby DEPENDENCIES - acts-as-taggable-on + acts-as-taggable-on (~> 4.0.0) acts_as_votable ahoy_matey (~> 1.6.0) ancestry (~> 2.2.2) - browser + browser (~> 2.3.0) bullet (~> 5.5.1) byebug cancancan (~> 1.16.0) @@ -490,12 +489,12 @@ DEPENDENCIES coveralls (~> 0.8.21) daemons dalli - database_cleaner + database_cleaner (~> 1.5.3) delayed_job_active_record (~> 4.1.0) devise (~> 3.5.7) devise-async devise_security_extension - email_spec + email_spec (~> 2.1.0) factory_girl_rails (~> 4.8.0) faker (~> 1.7.3) foundation-rails (~> 6.2.4.0) @@ -535,11 +534,11 @@ DEPENDENCIES savon sitemap_generator (~> 5.3.1) social-share-button (~> 0.10) - spring + spring (~> 2.0.1) spring-commands-rspec sprockets (~> 3.7.1) tolk (~> 2.0.0) - turbolinks + turbolinks (~> 2.5.3) turnout (~> 2.4.0) uglifier (~> 3.2.0) unicorn (~> 5.3.0) From 6b89bdd17d7bf5f60ee248553b5e1bc91b133685 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 20:26:39 +0200 Subject: [PATCH 08/39] Revert Gemfile.lock changes by mistake, also remove Gemfile gem version specification --- Gemfile | 12 ++++++------ Gemfile.lock | 54 +++++++++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/Gemfile b/Gemfile index 73d7dd4f6..52c854618 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'coffee-rails', '~> 4.2.1' gem 'jquery-rails', '~> 4.3.1' gem 'jquery-ui-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks', '~> 2.5.3' +gem 'turbolinks' # Fix sprockets on the gem 'sprockets', '~> 3.7.1' @@ -33,7 +33,7 @@ gem 'omniauth-google-oauth2', '~> 0.4.0' gem 'kaminari', '~> 1.0.1' gem 'ancestry', '~> 2.2.2' -gem 'acts-as-taggable-on', '~> 4.0.0' +gem 'acts-as-taggable-on' gem 'responders', '~> 2.4.0' gem 'foundation-rails', '~> 6.2.4.0' gem 'foundation_rails_helper', '~> 2.0.0' @@ -61,7 +61,7 @@ gem 'ahoy_matey', '~> 1.6.0' gem 'groupdate', '~> 3.2.0' # group temporary data gem 'tolk', '~> 2.0.0' # Web interface for translations -gem 'browser', '~> 2.3.0' +gem 'browser' gem 'turnout', '~> 2.4.0' gem 'redcarpet', '~> 3.4.0' gem 'rubyzip', '~> 1.2.0' @@ -72,7 +72,7 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring', '~> 2.0.1' + gem 'spring' gem 'spring-commands-rspec' gem 'rspec-rails', '~> 3.6' gem 'capybara', '~> 2.14.0' @@ -94,10 +94,10 @@ group :development, :test do end group :test do - gem 'database_cleaner', '~> 1.5.3' + gem 'database_cleaner' gem 'poltergeist', '~> 1.15.0' gem 'coveralls', '~> 0.8.21', require: false - gem 'email_spec', '~> 2.1.0' + gem 'email_spec' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 61e7db354..3590726c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,7 +97,7 @@ GEM ckeditor (4.2.3) cocaine orm_adapter (~> 0.5.0) - climate_control (0.2.0) + climate_control (0.1.0) cliver (0.3.2) cocaine (0.5.8) climate_control (>= 0.0.3, < 1.0) @@ -118,7 +118,7 @@ GEM daemons (1.2.4) dalli (2.7.6) database_cleaner (1.5.3) - debug_inspector (0.0.3) + debug_inspector (0.0.2) delayed_job (4.1.2) activesupport (>= 3.0, < 5.1) delayed_job_active_record (4.1.1) @@ -142,10 +142,10 @@ GEM json thread thread_safe - email_spec (2.1.1) + email_spec (2.1.0) htmlentities (~> 4.3.3) launchy (~> 2.1) - mail (~> 2.6) + mail (~> 2.6.3) errbase (0.0.3) erubis (2.7.0) execjs (2.7.0) @@ -171,9 +171,9 @@ GEM fuubar (2.2.0) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) - geocoder (1.4.4) - globalid (0.4.0) - activesupport (>= 4.2.0) + geocoder (1.4.3) + globalid (0.3.7) + activesupport (>= 4.1.0) groupdate (3.2.0) activesupport (>= 3) gyoku (1.3.1) @@ -181,9 +181,8 @@ GEM hashie (3.5.5) highline (1.7.8) htmlentities (4.3.4) - httpi (2.4.2) + httpi (2.4.1) rack - socksify i18n (0.8.1) i18n-tasks (0.9.15) activesupport (>= 4.0.2) @@ -240,7 +239,7 @@ GEM mime-types-data (3.2016.0521) mimemagic (0.3.2) mini_portile2 (2.1.0) - minitest (5.10.2) + minitest (5.10.1) multi_json (1.12.1) multi_xml (0.6.0) multipart-post (2.0.0) @@ -251,7 +250,7 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) nori (2.6.0) - oauth (0.5.2) + oauth (0.5.1) oauth2 (1.3.1) faraday (>= 0.8, < 0.12) jwt (~> 1.0) @@ -301,7 +300,7 @@ GEM public_suffix (2.0.5) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.8) + rack (1.6.5) rack-accept (0.4.5) rack (>= 0.4) rack-attack (5.0.1) @@ -376,7 +375,7 @@ GEM safe_yaml (1.0.4) safely_block (0.2.0) errbase - sass (3.4.24) + sass (3.4.23) sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) @@ -395,13 +394,12 @@ GEM docile (~> 1.1.0) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.1) + simplecov-html (0.10.0) sitemap_generator (5.3.1) builder (~> 3.0) social-share-button (0.10.0) coffee-rails - socksify (1.7.1) - spring (2.0.2) + spring (2.0.1) activesupport (>= 4.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) @@ -421,14 +419,14 @@ GEM net-ssh (>= 2.8.0) term-ansicolor (1.6.0) tins (~> 1.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) + terminal-table (1.7.3) + unicode-display_width (~> 1.1.1) thor (0.19.4) thread (0.2.2) thread_safe (0.3.6) tilt (2.0.7) timecop (0.8.1) - tins (1.14.0) + tins (1.13.2) tolk (2.0.0) rails (>= 4.0) safe_yaml (>= 0.8.6) @@ -443,14 +441,14 @@ GEM thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.2.1) + unicode-display_width (1.1.3) unicorn (5.3.0) kgio (~> 2.6) raindrops (~> 0.7) uniform_notifier (1.10.0) - user_agent_parser (2.3.1) + user_agent_parser (2.3.0) uuidtools (2.1.5) - warden (1.2.7) + warden (1.2.6) rack (>= 1.0) wasabi (3.5.0) httpi (~> 2.0) @@ -471,11 +469,11 @@ PLATFORMS ruby DEPENDENCIES - acts-as-taggable-on (~> 4.0.0) + acts-as-taggable-on acts_as_votable ahoy_matey (~> 1.6.0) ancestry (~> 2.2.2) - browser (~> 2.3.0) + browser bullet (~> 5.5.1) byebug cancancan (~> 1.16.0) @@ -489,12 +487,12 @@ DEPENDENCIES coveralls (~> 0.8.21) daemons dalli - database_cleaner (~> 1.5.3) + database_cleaner delayed_job_active_record (~> 4.1.0) devise (~> 3.5.7) devise-async devise_security_extension - email_spec (~> 2.1.0) + email_spec factory_girl_rails (~> 4.8.0) faker (~> 1.7.3) foundation-rails (~> 6.2.4.0) @@ -534,11 +532,11 @@ DEPENDENCIES savon sitemap_generator (~> 5.3.1) social-share-button (~> 0.10) - spring (~> 2.0.1) + spring spring-commands-rspec sprockets (~> 3.7.1) tolk (~> 2.0.0) - turbolinks (~> 2.5.3) + turbolinks turnout (~> 2.4.0) uglifier (~> 3.2.0) unicorn (~> 5.3.0) From 0df7235cc80b31ad95faacfcf50fd60f5de14a43 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 22:47:37 +0200 Subject: [PATCH 09/39] Add feature spec for new Administrators management in Admin area --- spec/features/admin/administrators_spec.rb | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/features/admin/administrators_spec.rb diff --git a/spec/features/admin/administrators_spec.rb b/spec/features/admin/administrators_spec.rb new file mode 100644 index 000000000..5c1af0036 --- /dev/null +++ b/spec/features/admin/administrators_spec.rb @@ -0,0 +1,37 @@ +require 'rails_helper' + +feature 'Admin administrators' do + background do + @admin = create(:administrator) + @user = create(:user, username: 'Jose Luis Balbin') + @administrator = create(:administrator) + login_as(@admin.user) + visit admin_administrators_path + end + + scenario 'Index' do + expect(page).to have_content @administrator.name + expect(page).to have_content @administrator.email + expect(page).to_not have_content @user.name + end + + scenario 'Create Administrator', :js do + fill_in 'email', with: @user.email + click_button 'Search' + + expect(page).to have_content @user.name + click_link 'Add' + within("#administrators") do + expect(page).to have_content @user.name + end + end + + scenario 'Delete Administrator' do + find(:xpath, "//tr[contains(.,'#{@administrator.name}')]/td/a", text: 'Delete').click + + within("#administrators") do + expect(page).to_not have_content @administrator.name + end + end +end + From 9506855a448d391802dc76cf9a47e7a20affc27b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 22:49:44 +0200 Subject: [PATCH 10/39] Add Admin Administrator route, controller and manage ability for admin users --- .../admin/administrators_controller.rb | 32 +++++++++++++++++++ app/helpers/admin_helper.rb | 2 +- app/models/abilities/administrator.rb | 1 + config/routes.rb | 4 +++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/administrators_controller.rb diff --git a/app/controllers/admin/administrators_controller.rb b/app/controllers/admin/administrators_controller.rb new file mode 100644 index 000000000..35325c5aa --- /dev/null +++ b/app/controllers/admin/administrators_controller.rb @@ -0,0 +1,32 @@ +class Admin::AdministratorsController < Admin::BaseController + load_and_authorize_resource + + def index + @administrators = @administrators.page(params[:page]) + end + + def search + @user = User.find_by(email: params[:email]) + + respond_to do |format| + if @user + @administrator = Administrator.find_or_initialize_by(user: @user) + format.js + else + format.js { render "user_not_found" } + end + end + end + + def create + @administrator.user_id = params[:user_id] + @administrator.save + + redirect_to admin_administrators_path + end + + def destroy + @administrator.destroy + redirect_to admin_administrators_path + end +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 3f0d4db4b..8ca439a1c 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -29,7 +29,7 @@ module AdminHelper end def menu_profiles? - ["organizations", "officials", "moderators", "valuators", "managers"].include? controller_name + ["administrators", "organizations", "officials", "moderators", "valuators", "managers"].include? controller_name end def menu_banners? diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 8df52e6eb..f2fe7aed9 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -34,6 +34,7 @@ module Abilities can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment] + can [:search, :create, :index, :destroy], ::Administrator can [:search, :create, :index, :destroy], ::Moderator can [:search, :create, :index, :summary], ::Valuator can [:search, :create, :index, :destroy], ::Manager diff --git a/config/routes.rb b/config/routes.rb index 4007595db..cdb1ccb2b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -207,6 +207,10 @@ Rails.application.routes.draw do get :search, on: :collection end + resources :administrators, only: [:index, :create, :destroy] do + get :search, on: :collection + end + scope module: :poll do resources :polls do get :search_questions, on: :member From 312e22956961614e392e245295b61c88327d1832 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 22:50:17 +0200 Subject: [PATCH 11/39] Add Administrator management views and en/es translations --- app/views/admin/_menu.html.erb | 4 ++ .../administrators/_administrator.html.erb | 26 +++++++++++ app/views/admin/administrators/index.html.erb | 46 +++++++++++++++++++ app/views/admin/administrators/search.js.erb | 1 + .../administrators/user_not_found.js.erb | 1 + config/locales/admin.en.yml | 10 ++++ config/locales/admin.es.yml | 10 ++++ 7 files changed, 98 insertions(+) create mode 100644 app/views/admin/administrators/_administrator.html.erb create mode 100644 app/views/admin/administrators/index.html.erb create mode 100644 app/views/admin/administrators/search.js.erb create mode 100644 app/views/admin/administrators/user_not_found.js.erb diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 0b9929f46..4e49cb7ed 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -95,6 +95,10 @@ <%= t("admin.menu.title_profiles") %>
      > +
    • > + <%= link_to t("admin.menu.administrators"), admin_administrators_path %> +
    • +
    • > <%= link_to t("admin.menu.organizations"), admin_organizations_path %>
    • diff --git a/app/views/admin/administrators/_administrator.html.erb b/app/views/admin/administrators/_administrator.html.erb new file mode 100644 index 000000000..d948e1eed --- /dev/null +++ b/app/views/admin/administrators/_administrator.html.erb @@ -0,0 +1,26 @@ +
      + + + + + + + + +
      + <%= administrator.name %> + + <%= administrator.email %> + + <% if administrator.persisted? %> + <%= link_to t('admin.administrators.administrator.delete'), + admin_administrator_path(administrator), + method: :delete, + class: "button hollow alert" %> + <% else %> + <%= link_to t('admin.administrators.administrator.add'),{ controller: "admin/administrators", action: :create, user_id: administrator.user_id }, + method: :post, + class: "button success" %> + <% end %> +
      +
      diff --git a/app/views/admin/administrators/index.html.erb b/app/views/admin/administrators/index.html.erb new file mode 100644 index 000000000..1cfbf5079 --- /dev/null +++ b/app/views/admin/administrators/index.html.erb @@ -0,0 +1,46 @@ +

      <%= t("admin.administrators.index.title") %>

      + +
      + <%= form_tag search_admin_administrators_path, method: :get, remote: true do %> +
      + <%= text_field_tag :email, '', placeholder: t('admin.administrators.search.email_placeholder') %> +
      +
      + <%= submit_tag t('admin.administrators.search.search'), class: 'button' %> +
      + <% end %> +
      + +
      + +

      <%= page_entries_info @administrators %>

      + + + <% @administrators.each do |administrator| %> + + + + + + <% end %> +
      + <%= administrator.name %> + + <%= administrator.email %> + + <% if administrator.persisted? %> + <%= link_to t('admin.administrators.administrator.delete'), + admin_administrator_path(administrator), + method: :delete, + class: "button hollow alert" + %> + <% else %> + <%= link_to t('admin.administrators.administrator.add'), + { controller: "admin/administrators", action: :create, + user_id: administrator.user_id }, + method: :post, + class: "button success" %> + <% end %> +
      + +<%= paginate @administrators %> diff --git a/app/views/admin/administrators/search.js.erb b/app/views/admin/administrators/search.js.erb new file mode 100644 index 000000000..1c30d9595 --- /dev/null +++ b/app/views/admin/administrators/search.js.erb @@ -0,0 +1 @@ +$("#search-result").html("<%= j render 'administrator', administrator: @administrator %>"); diff --git a/app/views/admin/administrators/user_not_found.js.erb b/app/views/admin/administrators/user_not_found.js.erb new file mode 100644 index 000000000..ba707fc9d --- /dev/null +++ b/app/views/admin/administrators/user_not_found.js.erb @@ -0,0 +1 @@ +$("#search-result").html("
      <%= j t('admin.administrators.search.user_not_found') %>
      "); diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 1d1bf9cb0..612b4db59 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -226,6 +226,16 @@ en: title_profiles: Profiles title_banners: Banners title_site_customization: Site customization + administrators: + index: + title: Administrators + moderator: + add: Add + delete: Delete + search: + email_placeholder: Search user by email + search: Search + user_not_found: User not found moderators: index: title: Moderators diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index b42843d70..da56e101c 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -181,6 +181,16 @@ es: with_confirmed_hide: Confirmados without_confirmed_hide: Pendientes title: Debates ocultos + administrators: + index: + title: Administradores + manager: + add: Añadir como Administrador + delete: Borrar + search: + email_placeholder: Buscar usuario por email + search: Buscar + user_not_found: Usuario no encontrado managers: index: title: Gestores From d10e5ad01de2652992043f5d6c2efdfe7ff478d4 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 23:27:55 +0200 Subject: [PATCH 12/39] Add missing Imagemagick brew install command on dev test setup for osx --- doc/en/dev_test_setup_osx.md | 6 ++++++ doc/es/dev_test_setup_osx.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/doc/en/dev_test_setup_osx.md b/doc/en/dev_test_setup_osx.md index 67845510f..b579ce4a6 100644 --- a/doc/en/dev_test_setup_osx.md +++ b/doc/en/dev_test_setup_osx.md @@ -98,6 +98,12 @@ brew install ghostscript brew install phantomjs ``` +## Imagemagick + +``` +brew install imagemagick +``` + ## Cloning the repository Now that we have all the dependencies installed we can download the repository: diff --git a/doc/es/dev_test_setup_osx.md b/doc/es/dev_test_setup_osx.md index 01ad29a2b..5fb251a0c 100644 --- a/doc/es/dev_test_setup_osx.md +++ b/doc/es/dev_test_setup_osx.md @@ -100,6 +100,12 @@ brew install ghostscript brew install phantomjs ``` +## Imagemagick + +``` +brew install imagemagick +``` + ## Clonar el repositorio Ahora que ya tenemos todas las dependencias instalado podemos bajarnos el proyecto: From 879f57396dcb1fb395c35d5da49178a40b656913 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 23:28:54 +0200 Subject: [PATCH 13/39] Add missing spanish guide for dev test setup on Linux --- doc/es/dev_test_setup.md | 2 + doc/es/dev_test_setup_linux.md | 146 +++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 doc/es/dev_test_setup_linux.md diff --git a/doc/es/dev_test_setup.md b/doc/es/dev_test_setup.md index 30f5d12d3..cda2613e7 100644 --- a/doc/es/dev_test_setup.md +++ b/doc/es/dev_test_setup.md @@ -2,6 +2,8 @@ ## Linux +Consultar [aqui](dev_test_setup_linux.md) + ## Mac OS X Consultar [aquí](dev_test_setup_osx.md) diff --git a/doc/es/dev_test_setup_linux.md b/doc/es/dev_test_setup_linux.md new file mode 100644 index 000000000..170871913 --- /dev/null +++ b/doc/es/dev_test_setup_linux.md @@ -0,0 +1,146 @@ +# Configuración para los entornos de desarrollo y pruebas (GNU/Linux) + +## Git + +Git es mantenido oficialmente en Debian/Ubuntu: + +``` +sudo apt-get install git +``` + +## Ruby + +Las versiones de Ruby versions empaquetadas en repositorios oficiales no son aptas para trabajar con consul (al menos Debian 7 y 8), así que debemos instalar manualmente. + +El método recomendado es via rvm: + +(sólo la opción multiusuario instala todas las dependencias automáticamente, al usar 'sudo'.) + +###como usuario local: + +``` +curl -L https://get.rvm.io | bash -s stable +``` +###para todos los usuarios del sistema: + +``` +curl -L https://get.rvm.io | sudo bash -s stable +``` + +añadismos nuestro usuario al grupo de rvm + +``` +sudo usermod -a -G rvm +``` + +y finalmente, añadimos el script rvm a nuestro bash (~/.bashrc) (este paso sólo es necesario si no puedes ejecutar el comando rvm) + +``` +[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm +``` + +con todo esto, deberías poder instalar la versión de ruby con rvm, por ejemplo la 2.3.2: + +``` +sudo rvm install 2.3.2 +``` + +## Bundler + +usando + +``` +gem install bundler +``` + +hay varios métodos alternativos [aquí](https://rvm.io/integration/bundler) que podrían ser mejores como: + +``` +gem install rubygems-bundler +``` + +## PostgreSQL (>=9.4) + +La versión 9.4 de PostgreSQL no es oficial en Debian 7 (wheezy), pero en Debian 8 parece ser mantenida oficialmente. + +Así que debemos añadir el respositorio oficial de postgresql a apt, por ejemplo creando el fichero */etc/apt/sources.list.d/pgdg.list* con: + +``` +deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main +``` + +después deberás descargar la key e instalarla: + +``` +wget https://www.postgresql.org/media/keys/ACCC4CF8.asc +apt-key add ACCC4CF8.asc +``` + +y finalmente instalar postgresql + +``` +apt-get update +apt-get install postgresql-9.4 +``` + +## Ghostscript + +``` +apt-get install ghostscript +``` + +## Clonar el repositorio + +Ahora que ya tenemos todas las dependencias instalado podemos bajarnos el proyecto: + +``` +git clone https://github.com/consul/consul.git +cd consul +bundle install +cp config/database.yml.example config/database.yml +cp config/secrets.yml.example config/secrets.yml +``` + +Ahora copia en `database.yml` el usuario y la contraseña que pusiste para *consul*. Cuando ya lo hayas hecho: + +``` +rake db:create +rake db:setup +rake db:dev_seed +RAILS_ENV=test bin/rake db:setup +``` + +Para ejecutar los tests: + +``` +bundle exec rspec +``` + +Quizás necesites crear un rol de superusuario en postgresql, y completar en el fichero*/config/database.yml* los campos 'user:' y 'password:'. + +Además, parece que postgresql usa un socket unix por defecto para las comunicaciones en local. Si te encuentras este problema creando la base de datos, cambia en */config/database.yml* la linea: + +``` +host: localhost +``` + +por: + +``` +host: /var/run/postgresql +``` + +Tras esto en el terminal ejecutaremos: + +``` +rake db:create +rake db:setup +rake db:dev_seed +RAILS_ENV=test bin/rake db:setup +``` + +Y por último para comprobar que todo esta bien, lanza los tests: + +``` +bundle exec rspec +``` From cafb6837d6cb5dcabd97f89bb8590f3ba13ccc10 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 23:29:12 +0200 Subject: [PATCH 14/39] Fix trailing single quote on admin english translations --- config/locales/admin.en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 1d1bf9cb0..a4bae05f4 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -491,7 +491,7 @@ en: placeholder: Search spending proposals by title or description user_search: button: Search - placeholder: Search user by name or email' + placeholder: Search user by name or email search_results: "Search results" no_search_results: "No results found." spending_proposals: From 115feb20aef78b347393766c0bb1ada3c17fb9e2 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 May 2017 23:33:50 +0200 Subject: [PATCH 15/39] Fix admin translations for administrators management panel actions --- config/locales/admin.en.yml | 2 +- config/locales/admin.es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 612b4db59..be415ad7f 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -229,7 +229,7 @@ en: administrators: index: title: Administrators - moderator: + administrator: add: Add delete: Delete search: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index da56e101c..79e55ccad 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -184,7 +184,7 @@ es: administrators: index: title: Administradores - manager: + administrator: add: Añadir como Administrador delete: Borrar search: From 7cc1745a29ada9460672d06f81db2dcae4db7cff Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 May 2017 00:00:44 +0200 Subject: [PATCH 16/39] Add missing Admin menu administrator translation --- config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index be415ad7f..2c39dc283 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -203,6 +203,7 @@ en: hidden_debates: Hidden debates hidden_proposals: Hidden proposals hidden_users: Hidden users + administrators: Administrators managers: Managers moderators: Moderators valuators: Valuators diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 79e55ccad..f569b84a0 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -214,6 +214,7 @@ es: hidden_proposals: Propuestas ocultas hidden_users: Usuarios bloqueados managers: Gestores + administrators: Administradores moderators: Moderadores valuators: Evaluadores poll_officers: Presidentes de mesa From 9e74249b02ea57bd3fce9c2ae0cc97020ffefae3 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 May 2017 07:54:48 +0200 Subject: [PATCH 17/39] Always use Time.current (aliases internally to Time.zone.now) Some specs where breaking close to midnight because 30.years.ago uses zone.now and Time.now.utc.to_date doesn't. Also this will make all codebase consistent in the way time is deal with --- app/models/poll/voter.rb | 4 ++-- db/dev_seeds.rb | 4 ++-- lib/age.rb | 2 +- spec/features/budgets/votes_spec.rb | 2 +- spec/models/direct_message_spec.rb | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/poll/voter.rb b/app/models/poll/voter.rb index 8fe612151..b05839501 100644 --- a/app/models/poll/voter.rb +++ b/app/models/poll/voter.rb @@ -50,10 +50,10 @@ class Poll if dob.blank? nil else - now = Time.now.utc.to_date + now = Time.current.to_date now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1) end end end -end \ No newline at end of file +end diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 9898ad46f..baf137c2d 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -407,7 +407,7 @@ tags = Faker::Lorem.words(10) title: Faker::Lorem.sentence(3).truncate(60), external_url: Faker::Internet.url, description: "

      #{Faker::Lorem.paragraphs.join('

      ')}

      ", - created_at: rand((Time.now - 1.week) .. Time.now), + created_at: rand((Time.current - 1.week) .. Time.current), feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample, unfeasibility_explanation: Faker::Lorem.paragraph, valuation_finished: [false, true].sample, @@ -436,7 +436,7 @@ budget = Budget.where(phase: "finished").last title: Faker::Lorem.sentence(3).truncate(60), external_url: Faker::Internet.url, description: "

      #{Faker::Lorem.paragraphs.join('

      ')}

      ", - created_at: rand((Time.now - 1.week) .. Time.now), + created_at: rand((Time.current - 1.week) .. Time.current), feasibility: "feasible", valuation_finished: true, selected: true, diff --git a/lib/age.rb b/lib/age.rb index c6ae6fe18..f0ca9abe0 100644 --- a/lib/age.rb +++ b/lib/age.rb @@ -1,5 +1,5 @@ module Age - def self.in_years(dob, now = Time.now.utc.to_date) + def self.in_years(dob, now = Time.current.to_date) return nil unless dob.present? # reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263 now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1) diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index 497046891..95f040bb3 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Votes' do background do - @manuela = create(:user, verified_at: Time.now) + @manuela = create(:user, verified_at: Time.current) end feature 'Investments' do diff --git a/spec/models/direct_message_spec.rb b/spec/models/direct_message_spec.rb index e982f9e56..05c3f75cd 100644 --- a/spec/models/direct_message_spec.rb +++ b/spec/models/direct_message_spec.rb @@ -65,9 +65,9 @@ describe DirectMessage do describe "today" do it "should return direct messages created today" do - direct_message1 = create(:direct_message, created_at: Time.zone.now.beginning_of_day + 3.hours) - direct_message2 = create(:direct_message, created_at: Time.zone.now) - direct_message3 = create(:direct_message, created_at: Time.zone.now.end_of_day) + direct_message1 = create(:direct_message, created_at: Time.current.beginning_of_day + 3.hours) + direct_message2 = create(:direct_message, created_at: Time.current) + direct_message3 = create(:direct_message, created_at: Time.current.end_of_day) expect(DirectMessage.today.count).to eq 3 end @@ -82,4 +82,4 @@ describe DirectMessage do end -end \ No newline at end of file +end From 02098755163581df8a6ca3112e4fa7d1ea9667cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 24 May 2017 12:08:29 +0200 Subject: [PATCH 18/39] fixes flaky specs in admin stats --- app/views/admin/stats/show.html.erb | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/views/admin/stats/show.html.erb b/app/views/admin/stats/show.html.erb index 137f3ce81..5df7b5df2 100644 --- a/app/views/admin/stats/show.html.erb +++ b/app/views/admin/stats/show.html.erb @@ -20,29 +20,29 @@

      - <%= t "admin.stats.show.summary.debates" %>
      + <%= t "admin.stats.show.summary.debates" %>
      <%= number_with_delimiter(@debates) %>

      - <%= t "admin.stats.show.summary.proposals" %>
      + <%= t "admin.stats.show.summary.proposals" %>
      <%= number_with_delimiter(@proposals) %>

      - <%= t "admin.stats.show.summary.comments" %>
      + <%= t "admin.stats.show.summary.comments" %>
      <%= number_with_delimiter(@comments) %>

      <% if feature?(:budgets) %>

      - <%= t "admin.stats.show.summary.budgets" %>
      + <%= t "admin.stats.show.summary.budgets" %>
      <%= number_with_delimiter(@budgets) %>

      <% end %> @@ -50,56 +50,56 @@

      - <%= t "admin.stats.show.summary.debate_votes" %>
      + <%= t "admin.stats.show.summary.debate_votes" %>
      <%= number_with_delimiter(@debate_votes) %>

      - <%= t "admin.stats.show.summary.comment_votes" %>
      + <%= t "admin.stats.show.summary.comment_votes" %>
      <%= number_with_delimiter(@comment_votes) %>

      - <%= t "admin.stats.show.summary.votes" %>
      + <%= t "admin.stats.show.summary.votes" %>
      <%= number_with_delimiter(@votes) %>

      - <%= t "admin.stats.show.summary.user_level_two" %>
      + <%= t "admin.stats.show.summary.user_level_two" %>
      <%= number_with_delimiter(@user_level_two) %>

      - <%= t "admin.stats.show.summary.user_level_three" %>
      + <%= t "admin.stats.show.summary.user_level_three" %>
      <%= number_with_delimiter(@user_level_three) %>

      - <%= t "admin.stats.show.summary.verified_users_who_didnt_vote_proposals" %>
      + <%= t "admin.stats.show.summary.verified_users_who_didnt_vote_proposals" %>
      <%=number_with_delimiter(@user_ids_who_didnt_vote_proposals)%> @@ -109,7 +109,7 @@ <% if feature?(:spending_proposals) %>

      From 9ba29fef8cc0b5abb283d840d03e8d064643d0e8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 May 2017 12:23:05 +0200 Subject: [PATCH 19/39] Add feature scenario for Newsletter admin section, including email zip download --- spec/features/admin/newsletters_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/features/admin/newsletters_spec.rb diff --git a/spec/features/admin/newsletters_spec.rb b/spec/features/admin/newsletters_spec.rb new file mode 100644 index 000000000..0357cbd52 --- /dev/null +++ b/spec/features/admin/newsletters_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +feature 'Admin newsletters emails' do + + let(:download_button_text) { 'Download zip with users list' } + + background do + @admin = create(:administrator) + login_as(@admin.user) + visit admin_newsletters_path + end + + scenario 'Index' do + expect(page).to have_content download_button_text + end + + scenario 'Download newsletter email zip' do + click_link download_button_text + expect( Zip::InputStream.open(StringIO.new(page.body)).get_next_entry.get_input_stream {|is| is.read } ).to include @admin.user.email + end +end + From 4ab92731b6e2f2a6abf31b757e918ed5639c3ba9 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 May 2017 12:56:03 +0200 Subject: [PATCH 20/39] Add expectations for newsletter users and non-newsletter users on email zip download scenario --- spec/features/admin/newsletters_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/newsletters_spec.rb b/spec/features/admin/newsletters_spec.rb index 0357cbd52..fccb63dc8 100644 --- a/spec/features/admin/newsletters_spec.rb +++ b/spec/features/admin/newsletters_spec.rb @@ -6,6 +6,8 @@ feature 'Admin newsletters emails' do background do @admin = create(:administrator) + @newsletter_user = create(:user, newsletter: true) + @non_newsletter_user = create(:user, newsletter: false) login_as(@admin.user) visit admin_newsletters_path end @@ -16,7 +18,9 @@ feature 'Admin newsletters emails' do scenario 'Download newsletter email zip' do click_link download_button_text - expect( Zip::InputStream.open(StringIO.new(page.body)).get_next_entry.get_input_stream {|is| is.read } ).to include @admin.user.email + downloaded_file_content = Zip::InputStream.open(StringIO.new(page.body)).get_next_entry.get_input_stream {|is| is.read } + expect(downloaded_file_content).to include(@admin.user.email, @newsletter_user.email) + expect(downloaded_file_content).not_to include(@non_newsletter_user.email) end end From 9dca1940abfd8a34098c2ca9c73caf21f37850e1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 25 May 2017 11:12:09 +0200 Subject: [PATCH 21/39] fixes admin geozones tables --- app/assets/stylesheets/admin.scss | 4 ++++ app/views/admin/geozones/index.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index fd6ed0815..1fd3ddfb2 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -95,6 +95,10 @@ body.admin { } } + td.break { + word-break: break-word; + } + &.fixed { table-layout: fixed; } diff --git a/app/views/admin/geozones/index.html.erb b/app/views/admin/geozones/index.html.erb index 5a524e46e..555d00ebe 100644 --- a/app/views/admin/geozones/index.html.erb +++ b/app/views/admin/geozones/index.html.erb @@ -20,7 +20,7 @@ <%= geozone.name %> <%= geozone.external_code %> <%= geozone.census_code %> - <%= geozone.html_map_coordinates %> + <%= geozone.html_map_coordinates %> <%= link_to t("admin.geozones.index.edit"), edit_admin_geozone_path(geozone), class: 'edit-banner button hollow' %> From e9ea72113b30968e46225315e5e42ac97caea46b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 25 May 2017 11:28:36 +0200 Subject: [PATCH 22/39] Add spec scenario for current user trying to remove himself from administrators list --- spec/features/admin/administrators_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/features/admin/administrators_spec.rb b/spec/features/admin/administrators_spec.rb index 5c1af0036..bef57b75d 100644 --- a/spec/features/admin/administrators_spec.rb +++ b/spec/features/admin/administrators_spec.rb @@ -33,5 +33,13 @@ feature 'Admin administrators' do expect(page).to_not have_content @administrator.name end end + + scenario 'Delete Administrator when its the current user' do + find(:xpath, "//tr[contains(.,'#{@admin.name}')]/td/a", text: 'Delete').click + + within("#error") do + expect(page).to have_content I18n.t("admin.administrators.administrator.restricted_removal") + end + end end From fe5ddd019bc66fc95dffa8233b31b4552bcdf5a6 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 25 May 2017 11:29:39 +0200 Subject: [PATCH 23/39] Add logic to prevent the current user from removing himself from the administrator list, and a flash error notice for that scenario --- app/controllers/admin/administrators_controller.rb | 7 ++++++- config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/administrators_controller.rb b/app/controllers/admin/administrators_controller.rb index 35325c5aa..938a7570d 100644 --- a/app/controllers/admin/administrators_controller.rb +++ b/app/controllers/admin/administrators_controller.rb @@ -26,7 +26,12 @@ class Admin::AdministratorsController < Admin::BaseController end def destroy - @administrator.destroy + if current_user.id == @administrator.user_id + flash[:error] = I18n.t("admin.administrators.administrator.restricted_removal") + else + @administrator.destroy + end + redirect_to admin_administrators_path end end diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 2c39dc283..aa6980510 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -233,6 +233,7 @@ en: administrator: add: Add delete: Delete + restricted_removal: "Sorry, you can't remove yourself from the administrators" search: email_placeholder: Search user by email search: Search diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index f569b84a0..9e30742bc 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -187,6 +187,7 @@ es: administrator: add: Añadir como Administrador delete: Borrar + restricted_removal: "Lo sentimos, no puedes te eliminar a ti mismo de la lista" search: email_placeholder: Buscar usuario por email search: Buscar From 3dde935051a0fefd1b5aaf9fad6407de7913fcbd Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 25 May 2017 11:58:15 +0200 Subject: [PATCH 24/39] Avoid creating objects, on poll recount spec, with fixed id numbers This was generating a flaky test that sometimes generated a unique key value constraint violation --- spec/models/poll/recount_spec.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spec/models/poll/recount_spec.rb b/spec/models/poll/recount_spec.rb index fb2c80704..2469354c2 100644 --- a/spec/models/poll/recount_spec.rb +++ b/spec/models/poll/recount_spec.rb @@ -23,18 +23,21 @@ describe :recount do expect(recount.count_log).to eq("") recount.count = 33 - recount.officer_assignment = create(:poll_officer_assignment, id: 11) + poll_officer_assignment_1 = create(:poll_officer_assignment) + recount.officer_assignment = poll_officer_assignment_1 recount.save recount.count = 32 - recount.officer_assignment = create(:poll_officer_assignment, id: 12) + poll_officer_assignment_2 = create(:poll_officer_assignment) + recount.officer_assignment = poll_officer_assignment_2 recount.save recount.count = 34 - recount.officer_assignment = create(:poll_officer_assignment, id: 13) + poll_officer_assignment_3 = create(:poll_officer_assignment) + recount.officer_assignment = poll_officer_assignment_3 recount.save - expect(recount.officer_assignment_id_log).to eq(":11:12") + expect(recount.officer_assignment_id_log).to eq(":#{poll_officer_assignment_1.id}:#{poll_officer_assignment_2.id}") end -end \ No newline at end of file +end From 6cda0d52d54912bca55dc87358f5fc1f0fed69e6 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 25 May 2017 12:28:53 +0200 Subject: [PATCH 25/39] Use a random word on the Poll factory name attribute to avoid flaky tests --- spec/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories.rb b/spec/factories.rb index 5f3061bf4..150dc0f62 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -388,7 +388,7 @@ FactoryGirl.define do end factory :poll do - sequence(:name) { |n| "Poll #{n}" } + sequence(:name) { |n| "Poll #{Faker::StarWars.character}" } starts_at { 1.month.ago } ends_at { 1.month.from_now } From e31a1ea39e2f139560c40a676e82f9d60f940ce3 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 26 May 2017 14:40:25 +0200 Subject: [PATCH 26/39] fixes height of participation not allowed message --- app/assets/stylesheets/participation.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 0c3ff069a..4b1ef6700 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -206,9 +206,9 @@ .participation-not-allowed { background: $warning-bg; color: $color-warning; - height: 100%; left: 0; line-height: $line-height; + min-height: 100%; padding: $line-height $line-height/2; position: absolute; text-align: center; From a49b206b424110ed24340d29e28de72edc92d1d1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 26 May 2017 14:55:27 +0200 Subject: [PATCH 27/39] adds help message to how change ballot --- app/views/budgets/investments/_header.html.erb | 6 ++++++ app/views/budgets/investments/_sidebar.html.erb | 12 ++++++++++-- config/locales/budgets.en.yml | 4 ++++ config/locales/budgets.es.yml | 4 ++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb index 2ed01d989..42e133d5a 100644 --- a/app/views/budgets/investments/_header.html.erb +++ b/app/views/budgets/investments/_header.html.erb @@ -42,6 +42,12 @@ @assigned_heading.name, budget_investments_path(@budget, heading_id: @assigned_heading.try(:id))) ) %> +
      + + <%= t("budgets.investments.header.change_ballot", + check_ballot: link_to(t("budgets.investments.header.check_ballot_link"), + budget_ballot_path(@budget))).html_safe %> +
      <% end %> diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb index 06d3b9d81..4ae9104d5 100644 --- a/app/views/budgets/investments/_sidebar.html.erb +++ b/app/views/budgets/investments/_sidebar.html.erb @@ -41,11 +41,19 @@

      <% elsif @assigned_heading.present? %> -

      <%= t("budgets.investments.index.sidebar.different_heading_assigned_html", +

      + <%= t("budgets.investments.index.sidebar.different_heading_assigned_html", heading_link: link_to( @assigned_heading.name, budget_investments_path(@budget, heading_id: @assigned_heading.try(:id))) - ) %>

      + ) %> +
      + + <%= t("budgets.investments.index.sidebar.change_ballot", + check_ballot: link_to(t("budgets.investments.index.sidebar.check_ballot_link"), + budget_ballot_path(@budget))).html_safe %> + +

      <% else %>

      <%= t("budgets.investments.index.sidebar.zero") %>

      <% end %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 570f9da35..19b52e976 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -64,6 +64,8 @@ en: voted_info: You can %{link} at any time until the close of this phase. No need to spend all the money available. voted_info_link: change your vote different_heading_assigned_html: "You have active votes in another heading: %{heading_link}" + change_ballot: "If your change your mind you can remove your votes in %{check_ballot} and start again." + check_ballot_link: "check my ballot" zero: You have not voted any investment project in this group. verified_only: "To create a new budget investment %{verify}." verify_account: "verify your account" @@ -106,6 +108,8 @@ en: header: check_ballot: Check my ballot different_heading_assigned_html: "You have active votes in another heading: %{heading_link}" + change_ballot: "If your change your mind you can remove your votes in %{check_ballot} and start again." + check_ballot_link: "check my ballot" progress_bar: available: "Available: " show: diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index a8e7fa5fa..6475eea79 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -64,6 +64,8 @@ es: voted_info: Puedes %{link} en cualquier momento hasta el cierre de esta fase. No hace falta que gastes todo el dinero disponible. voted_info_link: cambiar tus votos different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}" + change_ballot: "Si cambias de opinión puedes borrar tus votos en %{check_ballot} y volver a empezar." + check_ballot_link: "revisar mis votos" zero: "Todavía no has votado ninguna propuesta de inversión en este ámbito del presupuesto." verified_only: "Para crear una nueva propuesta de inversión %{verify}." verify_account: "verifica tu cuenta" @@ -106,6 +108,8 @@ es: header: check_ballot: Revisar mis votos different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}" + change_ballot: "Si cambias de opinión puedes borrar tus votos en %{check_ballot} y volver a empezar." + check_ballot_link: "revisar mis votos" progress_bar: available: "Disponible: " show: From 0e581896c0041e83965194d0182dfc9ee037051a Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 26 May 2017 17:12:21 +0200 Subject: [PATCH 28/39] improves message when not enough money --- app/models/budget/investment.rb | 2 +- app/views/budgets/investments/_ballot.html.erb | 5 +++-- config/locales/budgets.en.yml | 3 ++- config/locales/budgets.es.yml | 3 ++- spec/models/budget/investment_spec.rb | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 56a50deec..7aabf7093 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -145,7 +145,7 @@ class Budget return :not_selected unless selected? return :no_ballots_allowed unless budget.balloting? return :different_heading_assigned unless ballot.valid_heading?(heading) - return :not_enough_money if ballot.present? && !enough_money?(ballot) + return :not_enough_money_html if ballot.present? && !enough_money?(ballot) end def permission_problem(user) diff --git a/app/views/budgets/investments/_ballot.html.erb b/app/views/budgets/investments/_ballot.html.erb index 0ad43ab43..605caebc7 100644 --- a/app/views/budgets/investments/_ballot.html.erb +++ b/app/views/budgets/investments/_ballot.html.erb @@ -50,8 +50,9 @@ signup: link_to(t("votes.signup"), new_user_registration_path), my_heading: link_to(investment.heading.name, budget_investments_path(budget_id: investment.budget_id, - heading_id: investment.heading_id)) - ).html_safe %> + heading_id: investment.heading_id)), + change_ballot: link_to(t("budgets.ballots.reasons_for_not_balloting.change_ballot"), + budget_ballot_path(@budget))).html_safe %>

      diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 19b52e976..6fba08534 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -17,9 +17,10 @@ en: not_verified: Only verified users can vote on investments; %{verify_account}. organization: Organizations are not permitted to vote not_selected: Unselected investment projects can not be supported - not_enough_money: "Price is higher than the available amount left." + not_enough_money_html: "You have already assigned the available budget.
      Remember you can %{change_ballot} at any time" no_ballots_allowed: Selecting phase is closed different_heading_assigned: You have already voted a different heading + change_ballot: change your votes groups: show: title: Select an option diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 6475eea79..1cb308472 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -17,9 +17,10 @@ es: not_verified: Las propuestas de inversión sólo pueden ser apoyadas por usuarios verificados, %{verify_account}. organization: Las organizaciones no pueden votar. not_selected: No se pueden votar propuestas inviables. - not_enough_money: No hay fondos suficientes. + not_enough_money_html: "Ya has asignado el presupuesto disponible.
      Recuerda que puedes %{change_ballot} en cualquier momento" no_ballots_allowed: El periodo de votación está cerrado. different_heading_assigned: Ya votaste en una sección distinta del presupuesto. + change_ballot: cambiar tus votos groups: show: title: Selecciona una opción diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index b811e8061..2290abba9 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -712,7 +712,7 @@ describe Budget::Investment do ballot = create(:budget_ballot, user: user, budget: budget) ballot.investments << inv1 - expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money) + expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money_html) end end From 75841a71bed02e481020c1b16cd07a630d26ae14 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 26 May 2017 17:28:04 +0200 Subject: [PATCH 29/39] updates texts on specs --- spec/features/budgets/ballots_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/features/budgets/ballots_spec.rb b/spec/features/budgets/ballots_spec.rb index b8f40acf0..35e74a9a6 100644 --- a/spec/features/budgets/ballots_spec.rb +++ b/spec/features/budgets/ballots_spec.rb @@ -536,7 +536,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").hover - expect(page).to have_content('Price is higher than the available amount left') + expect(page).to have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: false) end end @@ -550,7 +550,7 @@ feature 'Ballots' do within("#budget_investment_#{bi1.id}") do find("div.ballot").hover - expect(page).to_not have_content('Price is higher than the available amount left') + expect(page).to_not have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: true) end @@ -558,7 +558,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").trigger("mouseover") - expect(page).to have_content('Price is higher than the available amount left') + expect(page).to have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: false) end @@ -576,7 +576,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").hover - expect(page).to have_content('Price is higher than the available amount left') + expect(page).to have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: false) end @@ -587,7 +587,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").hover - expect(page).to_not have_content('Price is higher than the available amount left') + expect(page).to_not have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: true) end end @@ -604,7 +604,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").hover - expect(page).to have_content('Price is higher than the available amount left') + expect(page).to have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: false) end @@ -616,7 +616,7 @@ feature 'Ballots' do within("#budget_investment_#{bi2.id}") do find("div.ballot").hover - expect(page).to_not have_content('Price is higher than the available amount left') + expect(page).to_not have_content('You have already assigned the available budget') expect(page).to have_selector('.in-favor a', visible: true) end end From ca94176837e51ab77bb42c2dbeefbc1701364063 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 28 May 2017 11:22:30 +0200 Subject: [PATCH 30/39] Rename rubocop cop name in excluding rubocop_todo list to avoid it from failing --- .rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 443782795..8258cf9c9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -461,7 +461,7 @@ Style/Lambda: # Offense count: 1 # Cop supports --auto-correct. -Style/MethodCallParentheses: +Style/MethodCallWithoutArgsParentheses: Exclude: - 'app/controllers/management/document_verifications_controller.rb' From 41fb640f927afd8a12d758509a131b3a13107993 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 May 2017 09:58:37 +0200 Subject: [PATCH 31/39] Add missing data-equalizer-watch attribute Why: * There is a data-equalizer attribute on the parent div, and a data-equalizer-watch on a sibiling div, and that breakes both the purpose of those values (Resize child elements of data-equalizer to have the same height. Ref: http://foundation.zurb.com/sites/docs/equalizer.html) * That lack of attribute was breaking many specs consistently on localhost with phantomjs 2.1.1 on macos sierra (and ubuntu as reported by @amaia) How: * Just adding the missing 'data-equalizer-watch' attribute on the div child of the one using 'data-equalizer' --- app/views/layouts/admin.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 198bf3adf..79ae4f090 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -31,7 +31,7 @@ <%= render 'layouts/admin_header' %>
      -
      +
      From 1254f684fd28f01efa02196a4ca0b88ad088b114 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 May 2017 10:44:10 +0200 Subject: [PATCH 32/39] Fix Poll factory name generation to guarantee uniqueness with SecureRandom.hex --- spec/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories.rb b/spec/factories.rb index 150dc0f62..5b7a76f28 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -388,7 +388,7 @@ FactoryGirl.define do end factory :poll do - sequence(:name) { |n| "Poll #{Faker::StarWars.character}" } + sequence(:name) { |n| "Poll #{SecureRandom.hex}" } starts_at { 1.month.ago } ends_at { 1.month.from_now } From 9607346e570e614ee5e37d9eba65b613cd052679 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 12:13:24 +0200 Subject: [PATCH 33/39] adds heading_id on investment show back link --- app/views/budgets/investments/_investment_show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index f9a371585..ebc37b584 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -2,7 +2,7 @@
      - <%= back_link_to budget_investments_path(investment.budget) %> + <%= back_link_to budget_investments_path(heading_id: investment.heading.id) %>

      <%= investment.title %>

      From 7e0be26ad60b414b37d45805c9e3f5bb924edcf0 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 12:56:34 +0200 Subject: [PATCH 34/39] adds specs --- spec/features/budgets/investments_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index a0f65a012..f07e96528 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -278,6 +278,16 @@ feature 'Budget Investments' do end end + scenario "Show back link contains heading id" do + investment = create(:budget_investment, heading: heading) + visit budget_investment_path(budget, investment) + + expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: heading.id) + + click_link 'Go back' + expected_path = budget_investments_path(budget, heading_id: heading.id) + end + context "Show (feasible budget investment)" do let(:investment) { create(:budget_investment, :feasible, From 9663582124b15bff5d02a628f05c7150cca2eb88 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 13:19:28 +0200 Subject: [PATCH 35/39] fixes color contrast on officials levels labels --- app/assets/stylesheets/layout.scss | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index fa0fd3455..b3c2f78d7 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1140,10 +1140,8 @@ img.avatar, img.admin-avatar, img.moderator-avatar, img.initialjs-avatar { // 10. Officials levels // -------------------- -[class^="level-"] { - color: black; -} - +.level-1, .level-2, .level-3, +.level-4, .level-5, .is-author, .is-association { color: black; } From e78b675cdffb444452f7c07cfb71ffebbdc9d820 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 13:22:40 +0200 Subject: [PATCH 36/39] fixes color contrast on close button alerts --- app/assets/stylesheets/layout.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index b3c2f78d7..71a7b9434 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -257,6 +257,7 @@ a { } .close-button { + color: $text; top: $line-height/2; } From 599ef6e9da1a9af97357f846a32863012c6c65b3 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 14:35:57 +0200 Subject: [PATCH 37/39] removes redundant spec --- spec/features/budgets/investments_spec.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index f07e96528..c2afe1e6f 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -283,9 +283,6 @@ feature 'Budget Investments' do visit budget_investment_path(budget, investment) expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: heading.id) - - click_link 'Go back' - expected_path = budget_investments_path(budget, heading_id: heading.id) end context "Show (feasible budget investment)" do From 0622ad1f2472cbac9c2646677e8eaca80d850e10 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 29 May 2017 18:01:22 +0200 Subject: [PATCH 38/39] polish budgets investment show back link --- app/views/budgets/investments/_investment_show.html.erb | 2 +- spec/features/budgets/investments_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index ebc37b584..a6a4fe8cb 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -2,7 +2,7 @@
      - <%= back_link_to budget_investments_path(heading_id: investment.heading.id) %> + <%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>

      <%= investment.title %>

      diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index c2afe1e6f..ef84cc6fc 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -282,7 +282,7 @@ feature 'Budget Investments' do investment = create(:budget_investment, heading: heading) visit budget_investment_path(budget, investment) - expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: heading.id) + expect(page).to have_link "Go back", href: budget_investments_path(budget, heading_id: investment.heading) end context "Show (feasible budget investment)" do From 2382dc56b5d434e6d39128a02f1bcd682c341ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Tue, 30 May 2017 10:46:34 +0200 Subject: [PATCH 39/39] fixes wording --- config/locales/admin.es.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 94e9f0494..82699875b 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -187,7 +187,7 @@ es: administrator: add: Añadir como Administrador delete: Borrar - restricted_removal: "Lo sentimos, no puedes te eliminar a ti mismo de la lista" + restricted_removal: "Lo sentimos, no puedes eliminarte a ti mismo de la lista" search: email_placeholder: Buscar usuario por email search: Buscar