From 1f4a5f082b9065c74bf19ccd454459302a6f659e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 5 Oct 2018 02:34:27 +0000 Subject: [PATCH 01/14] [Security] Bump nokogiri from 1.8.4 to 1.8.5 Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.8.4 to 1.8.5. **This update includes security fixes.** - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.8.4...v1.8.5) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffea63e66..763677a5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -220,7 +220,7 @@ GEM net-ssh (>= 2.6.5) net-ssh (2.9.2) netrc (0.11.0) - nokogiri (1.8.4) + nokogiri (1.8.5) mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) parallel (1.12.1) From 9385e92c81b34f279ae96d50eba181e9e719960c Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sat, 20 Oct 2018 14:54:24 +0200 Subject: [PATCH 02/14] views: minor refactor in member_card partial --- app/views/users/_member_card.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_member_card.html.erb b/app/views/users/_member_card.html.erb index 0b61420b3..d4e556498 100644 --- a/app/views/users/_member_card.html.erb +++ b/app/views/users/_member_card.html.erb @@ -19,13 +19,13 @@ <%= member.description&.truncate(124) %>
- <% if member.phone.present? && !member.phone.blank? %> + <% if member.phone.present? %>
<%= phone_to member.phone %>
<% end %> - <% if member.mail_to.present? && !member.mail_to.blank? %> + <% if member.mail_to.present? %>
<%= member.mail_to %> From 055ebeb36a17bf4b6b10ca9e55e5f7b57f3ac5d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 6 Nov 2018 06:42:12 +0000 Subject: [PATCH 03/14] [Security] Bump rack from 1.6.10 to 1.6.11 Bumps [rack](https://github.com/rack/rack) from 1.6.10 to 1.6.11. **This update includes security fixes.** - [Release notes](https://github.com/rack/rack/releases) - [Changelog](https://github.com/rack/rack/blob/master/CHANGELOG.md) - [Commits](https://github.com/rack/rack/compare/1.6.10...1.6.11) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffea63e66..e640a15e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -239,7 +239,7 @@ GEM public_suffix (2.0.5) pundit (0.3.0) activesupport (>= 3.0.0) - rack (1.6.10) + rack (1.6.11) rack-protection (2.0.1) rack rack-test (0.6.3) From 80a031aa57cb46fb8295ad41a6847f2aee0ff137 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 27 Nov 2018 22:18:22 +0000 Subject: [PATCH 04/14] [Security] Bump rails from 4.2.10 to 4.2.11 Bumps [rails](https://github.com/rails/rails) from 4.2.10 to 4.2.11. **This update includes security fixes.** - [Release notes](https://github.com/rails/rails/releases) - [Commits](https://github.com/rails/rails/compare/v4.2.10...v4.2.11) Signed-off-by: dependabot[bot] --- Gemfile.lock | 72 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffea63e66..10da475c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,21 +1,21 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.10) - actionpack (= 4.2.10) - actionview (= 4.2.10) - activejob (= 4.2.10) + actionmailer (4.2.11) + actionpack (= 4.2.11) + actionview (= 4.2.11) + activejob (= 4.2.11) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.10) - actionview (= 4.2.10) - activesupport (= 4.2.10) + actionpack (4.2.11) + actionview (= 4.2.11) + activesupport (= 4.2.11) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.10) - activesupport (= 4.2.10) + actionview (4.2.11) + activesupport (= 4.2.11) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) @@ -32,17 +32,17 @@ GEM ransack (~> 1.3) sass (~> 3.1) sprockets (< 4.1) - activejob (4.2.10) - activesupport (= 4.2.10) + activejob (4.2.11) + activesupport (= 4.2.11) globalid (>= 0.3.0) - activemodel (4.2.10) - activesupport (= 4.2.10) + activemodel (4.2.11) + activesupport (= 4.2.11) builder (~> 3.1) - activerecord (4.2.10) - activemodel (= 4.2.10) - activesupport (= 4.2.10) + activerecord (4.2.11) + activemodel (= 4.2.11) + activesupport (= 4.2.11) arel (~> 6.0) - activesupport (4.2.10) + activesupport (4.2.11) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) @@ -111,7 +111,7 @@ GEM execjs coffee-script-source (1.8.0) columnize (0.9.0) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.3) connection_pool (2.2.1) crass (1.0.4) dalli (2.7.2) @@ -203,15 +203,15 @@ GEM i18n (~> 0.4) json rest-client - loofah (2.2.2) + loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_mime (1.0.0) + mini_mime (1.0.1) mini_portile2 (2.3.0) minitest (5.11.3) multi_json (1.11.2) @@ -220,7 +220,7 @@ GEM net-ssh (>= 2.6.5) net-ssh (2.9.2) netrc (0.11.0) - nokogiri (1.8.4) + nokogiri (1.8.5) mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) parallel (1.12.1) @@ -239,21 +239,21 @@ GEM public_suffix (2.0.5) pundit (0.3.0) activesupport (>= 3.0.0) - rack (1.6.10) + rack (1.6.11) rack-protection (2.0.1) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.10) - actionmailer (= 4.2.10) - actionpack (= 4.2.10) - actionview (= 4.2.10) - activejob (= 4.2.10) - activemodel (= 4.2.10) - activerecord (= 4.2.10) - activesupport (= 4.2.10) + rails (4.2.11) + actionmailer (= 4.2.11) + actionpack (= 4.2.11) + actionview (= 4.2.11) + activejob (= 4.2.11) + activemodel (= 4.2.11) + activerecord (= 4.2.11) + activesupport (= 4.2.11) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.10) + railties (= 4.2.11) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -271,9 +271,9 @@ GEM rails_stdout_logging rails_serve_static_assets (0.0.3) rails_stdout_logging (0.0.3) - railties (4.2.10) - actionpack (= 4.2.10) - activesupport (= 4.2.10) + railties (4.2.11) + actionpack (= 4.2.11) + activesupport (= 4.2.11) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (3.0.0) @@ -363,7 +363,7 @@ GEM sshkit (1.8.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) tilt (2.0.8) ttfunk (1.5.1) From bf663c8491845a10aa7c609beceff41d395521be Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Wed, 13 Feb 2019 23:29:59 +0100 Subject: [PATCH 05/14] Remove piwik code (closes #457) + minor layout cleanup --- app/helpers/application_helper.rb | 4 ++++ app/views/layouts/application.html.erb | 31 ++++---------------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6c198475c..260f6da31 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,6 +3,10 @@ module ApplicationHelper TEXT_SUCCESS = 'text-success'.freeze TEXT_DANGER = 'text-danger'.freeze + def page_title + current_organization || 'TimeOverflow' + end + # from gravatar def avatar_url(user, size = 32) gravatar_id = Digest::MD5::hexdigest(user.email).downcase diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0e02f748b..333227399 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,26 +4,17 @@ - - <% if content_for? :window_title %> - <%= content_for :window_title %> - <% else %> - <% if current_organization %> - <%= current_organization %> — - <% end %> - <%= yield :title %> - <% end %> - + <%= page_title %> <%= csrf_meta_tags %> <%= stylesheet_link_tag 'libs', media: 'all' %> <%= stylesheet_link_tag 'application', media: 'all' %> - <%= stylesheet_link_tag 'application', 'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700' %> - <%= stylesheet_link_tag 'application', 'https://fonts.googleapis.com/icon?family=Material+Icons' %> + <%= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700' %> + <%= stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons' %> <%= javascript_include_tag 'libs' %> <%= javascript_include_tag 'application' %> - + <%= render 'navbar' %>
<%= render 'layouts/messages' unless devise_controller? %> @@ -38,19 +29,5 @@ <%= render 'application/footer' %>
- - - From 3a82c02af427ddbb5bd939b06679e16cadeba48a Mon Sep 17 00:00:00 2001 From: sseerrggii Date: Fri, 15 Feb 2019 17:15:47 +0100 Subject: [PATCH 06/14] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a42cdc2ca..107016e16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,8 +5,8 @@ ¿Has encontrado algún bug? ¿Quieres colaborar? Proceso: -* Abrir un hilo en [discourse](http://community.coopdevs.org/) para aclarar si es un bug o una feature :wink: -* Una vez aclarado el bug y detectado los pasos para reproducirlos se crearia una issue en GH con enlaze al hilo original en discourse. +* Abrir un hilo en [discourse](https://community.coopdevs.org/c/timeoverflow) para aclarar si es un bug o una feature :wink: +* Una vez aclarado, si se trata de un bug, abre una issue en Github indicando los pasos para reproducirlo y cómo debería funncionar correctamente, enlaza al hilo original en discourse. * Pull request que resuelve la issue. * Reportar en el hilo de discourse que el bug ha sido resuelto con enlace a PR. From c7eefc47396cf212e12628ecf3f5008136617c4b Mon Sep 17 00:00:00 2001 From: sseerrggii Date: Fri, 15 Feb 2019 17:16:04 +0100 Subject: [PATCH 07/14] Update CONTRIBUTING.en.md --- docs/CONTRIBUTING.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.en.md b/docs/CONTRIBUTING.en.md index 9ed140e25..3e168d3ca 100644 --- a/docs/CONTRIBUTING.en.md +++ b/docs/CONTRIBUTING.en.md @@ -3,7 +3,7 @@ Did you find a bug? Do you want to collaborate? Process: -* Open a thread in [discourse](http://community.coopdevs.org/) to make sure whether it's a bug or a feature :wink: +* Open a thread in [discourse](https://community.coopdevs.org/c/timeoverflow) to make sure whether it's a bug or a feature :wink: * Once we understand what the bug is about and know the steps to reproduce we will create an issue in GitHub linking to the Discourse thread. * Create a pull request to solve the issue. * Report back to the discourse thread the bug has been solved linking to the pull request. From 362db096fe320692fe03f38a0c821151223ba6ab Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Thu, 14 Feb 2019 21:07:05 +0100 Subject: [PATCH 08/14] upgrade capybara and chromedriver-helper --- Gemfile | 8 ++++---- Gemfile.lock | 37 ++++++++++++++++++------------------- spec/spec_helper.rb | 11 +++-------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/Gemfile b/Gemfile index be0f9309f..d7371516b 100644 --- a/Gemfile +++ b/Gemfile @@ -60,10 +60,10 @@ group :test do gem "database_cleaner", '1.6.2' gem 'shoulda-matchers', '~> 3.1.2' gem 'fabrication' - gem 'faker' - gem 'capybara', '~> 2.7' - gem 'capybara-selenium', '~> 0.0.6' - gem 'chromedriver-helper', '~> 1.0' + gem 'faker', '~> 1.9' + gem 'capybara', '~> 3.13' + gem 'selenium-webdriver', '~> 3.141' + gem 'chromedriver-helper', '~> 2.1' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index bb95fa0ac..bc228d404 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,19 +86,17 @@ GEM capistrano-rbenv (2.1.3) capistrano (~> 3.1) sshkit (~> 1.3) - capybara (2.18.0) + capybara (3.13.2) addressable mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) - capybara-selenium (0.0.6) - capybara - selenium-webdriver + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) childprocess (0.9.0) ffi (~> 1.0, >= 1.0.11) - chromedriver-helper (1.2.0) + chromedriver-helper (2.1.0) archive-zip (~> 0.10) nokogiri (~> 1.8) chronic (0.10.2) @@ -149,11 +147,11 @@ GEM tzinfo execjs (2.6.0) fabrication (2.11.3) - faker (1.4.3) - i18n (~> 0.5) + faker (1.9.3) + i18n (>= 0.7) faraday (0.9.1) multipart-post (>= 1.2, < 3) - ffi (1.9.25) + ffi (1.10.0) formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) @@ -288,6 +286,7 @@ GEM polyamorous (~> 1.3.2) rdiscount (2.1.7.1) redis (4.0.1) + regexp_parser (1.3.0) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) @@ -334,9 +333,9 @@ GEM tilt (>= 1.1, < 3) select2-rails (4.0.1) thor (~> 0.14) - selenium-webdriver (3.11.0) + selenium-webdriver (3.141.0) childprocess (~> 0.5) - rubyzip (~> 1.2) + rubyzip (~> 1.2, >= 1.2.2) shoulda-matchers (3.1.2) activesupport (>= 4.0.0) sidekiq (5.1.3) @@ -390,7 +389,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) whenever (0.9.4) chronic (>= 0.6.3) - xpath (3.0.0) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS @@ -406,9 +405,8 @@ DEPENDENCIES capistrano (~> 3.1) capistrano-rails (~> 1.1) capistrano-rbenv (~> 2.1) - capybara (~> 2.7) - capybara-selenium (~> 0.0.6) - chromedriver-helper (~> 1.0) + capybara (~> 3.13) + chromedriver-helper (~> 2.1) coffee-rails dalli database_cleaner (= 1.6.2) @@ -417,7 +415,7 @@ DEPENDENCIES elasticsearch-model elasticsearch-rails fabrication - faker + faker (~> 1.9) has_scope hstore_translate http_accept_language (~> 2.1.1) @@ -439,6 +437,7 @@ DEPENDENCIES rufus-scheduler (~> 3.4.2) sass-rails (~> 5.0.7) select2-rails + selenium-webdriver (~> 3.141) shoulda-matchers (~> 3.1.2) sidekiq (= 5.1.3) sidekiq-cron (= 0.6.3) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 894bd9ac4..fac37f2e5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,16 +8,12 @@ require 'capybara/rspec' require 'database_cleaner' require 'fabrication' +require 'chromedriver-helper' require 'selenium/webdriver' require 'faker' require 'shoulda/matchers' -I18n.reload! - -Capybara.register_driver :chrome do |app| - Capybara::Selenium::Driver.new(app, browser: :chrome) -end - +Capybara.server = :webrick Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: %w(headless disable-gpu) } @@ -29,9 +25,8 @@ desired_capabilities: capabilities ) end - -Capybara.javascript_driver = :headless_chrome Capybara.default_driver = :headless_chrome +Capybara.javascript_driver = Capybara.default_driver # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. From ac2e1cbcfa7be674a151af05784561ae8304f538 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Thu, 14 Feb 2019 21:48:56 +0100 Subject: [PATCH 09/14] capybara: use newer selenium api to configure headless chrome driver --- spec/spec_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fac37f2e5..946559b7a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,14 +15,14 @@ Capybara.server = :webrick Capybara.register_driver :headless_chrome do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - chromeOptions: { args: %w(headless disable-gpu) } + browser_options = Selenium::WebDriver::Chrome::Options.new( + args: %w(headless disable-gpu no-sandbox) ) Capybara::Selenium::Driver.new( app, browser: :chrome, - desired_capabilities: capabilities + options: browser_options ) end Capybara.default_driver = :headless_chrome From 6ec52460d4564189932a05d3934954310566738a Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Sat, 1 Sep 2018 19:26:03 +0200 Subject: [PATCH 10/14] don't allow transfers of 0 hours and 0 minutes --- app/assets/javascripts/give_time.js.coffee | 9 +++++++-- app/controllers/transfers_controller.rb | 2 +- app/models/transfer.rb | 9 +-------- app/views/transfers/new.html.erb | 2 +- spec/controllers/transfers_controller_spec.rb | 17 +++++++++++++++++ 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/give_time.js.coffee b/app/assets/javascripts/give_time.js.coffee index fe067d4ec..76444ad6c 100644 --- a/app/assets/javascripts/give_time.js.coffee +++ b/app/assets/javascripts/give_time.js.coffee @@ -5,8 +5,13 @@ jQuery.validator.addMethod "either-hours-minutes-informed", ((value, element) -> giveTimeReadyFn = () -> config = submitHandler: (form) -> - $(" #transfer_amount ").val($(" #transfer_hours ").val() * 3600 + $(" #transfer_minutes ").val() * 60) - form.submit() + amount = $("#transfer_hours").val() * 3600 + $("#transfer_minutes").val() * 60 + $("#transfer_amount").val(amount) + + if amount > 0 + form.submit() + else + $(form).find('input:submit').after(' ') $( "#new_transfer" ).validate(config) diff --git a/app/controllers/transfers_controller.rb b/app/controllers/transfers_controller.rb index b322f59ab..bd3ae9580 100644 --- a/app/controllers/transfers_controller.rb +++ b/app/controllers/transfers_controller.rb @@ -12,7 +12,7 @@ def create if persister.save redirect_to redirect_target else - flash[:error] = transfer.errors.full_messages.to_sentence + redirect_to :back, alert: transfer.errors.full_messages.to_sentence end end diff --git a/app/models/transfer.rb b/app/models/transfer.rb index b841cce45..c70968485 100644 --- a/app/models/transfer.rb +++ b/app/models/transfer.rb @@ -17,6 +17,7 @@ class Transfer < ActiveRecord::Base has_many :movements, dependent: :destroy has_many :events, dependent: :destroy + validates :amount, numericality: { greater_than: 0 } validate :different_source_and_destination after_create :make_movements @@ -26,14 +27,6 @@ def make_movements movements.create(account: Account.find(destination_id), amount: amount.to_i) end - def movement_from - movements.detect {|m| m.amount < 0 } - end - - def movement_to - movements.detect {|m| m.amount > 0 } - end - def source_id source.respond_to?(:id) ? source.id : source end diff --git a/app/views/transfers/new.html.erb b/app/views/transfers/new.html.erb index 66c74131a..3aff11dac 100644 --- a/app/views/transfers/new.html.erb +++ b/app/views/transfers/new.html.erb @@ -36,7 +36,7 @@
- <%= f.button :submit, class: "btn btn-default", style: "margin-bottom: 20px;" %> + <%= f.button :submit, class: "btn btn-default" %>
<% end %> diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb index 7eff15bb6..c075091ec 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -207,5 +207,22 @@ end end end + + context 'with invalid params' do + let(:user) { member_giver.user } + let(:referer) { "/transfers/new?destination_account_id=#{member_taker.account.id}" } + + before do + request.env["HTTP_REFERER"] = referer + end + + it 'does not create any Transfer and redirects to :back if the amount is 0' do + expect { + post(:create, transfer: { amount: 0, destination: member_taker.account.id }) + }.not_to change(Transfer, :count) + + expect(response).to redirect_to(referer) + end + end end end From 5ae50b3001c3b6eae6aaf2a5b1b45c1c83b1d48f Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Thu, 4 Oct 2018 22:29:40 +0200 Subject: [PATCH 11/14] add model and DB constraint for Movement#amount (can't be equal to 0) --- app/models/movement.rb | 2 ++ ...0181004200104_add_amount_constraint_to_movements.rb | 10 ++++++++++ db/schema.rb | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20181004200104_add_amount_constraint_to_movements.rb diff --git a/app/models/movement.rb b/app/models/movement.rb index 959c45757..3408de8cc 100644 --- a/app/models/movement.rb +++ b/app/models/movement.rb @@ -18,6 +18,8 @@ class Movement < ActiveRecord::Base where(created_at: month.beginning_of_month..month.end_of_month) } + validates :amount, numericality: { other_than: 0 } + after_create do account.update_balance end diff --git a/db/migrate/20181004200104_add_amount_constraint_to_movements.rb b/db/migrate/20181004200104_add_amount_constraint_to_movements.rb new file mode 100644 index 000000000..978eb0269 --- /dev/null +++ b/db/migrate/20181004200104_add_amount_constraint_to_movements.rb @@ -0,0 +1,10 @@ +class AddAmountConstraintToMovements < ActiveRecord::Migration + def change + # Destroy movements (and parent transfer) with amount equal to 0 + Movement.includes(:transfer).where(amount: 0).find_each do |movement| + movement.transfer&.destroy + end + + execute 'ALTER TABLE movements ADD CONSTRAINT non_zero_amount CHECK(amount != 0)' + end +end diff --git a/db/schema.rb b/db/schema.rb index 151afa5d2..38963d039 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180924164456) do +ActiveRecord::Schema.define(version: 20181004200104) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 50851e9e7a1c384eb550e87c46e2ecab1283c098 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Tue, 23 Oct 2018 21:47:00 +0200 Subject: [PATCH 12/14] i18nize error message (transfers with amount 0) --- app/assets/javascripts/give_time.js.coffee | 2 +- app/views/transfers/new.html.erb | 1 + config/locales/ca.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ config/locales/eu.yml | 2 ++ config/locales/pt-BR.yml | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/give_time.js.coffee b/app/assets/javascripts/give_time.js.coffee index 76444ad6c..0465c0dc2 100644 --- a/app/assets/javascripts/give_time.js.coffee +++ b/app/assets/javascripts/give_time.js.coffee @@ -11,7 +11,7 @@ giveTimeReadyFn = () -> if amount > 0 form.submit() else - $(form).find('input:submit').after(' ') + $(form).find('.form-actions .error').removeClass('invisible').show() $( "#new_transfer" ).validate(config) diff --git a/app/views/transfers/new.html.erb b/app/views/transfers/new.html.erb index 3aff11dac..3f349f5f9 100644 --- a/app/views/transfers/new.html.erb +++ b/app/views/transfers/new.html.erb @@ -37,6 +37,7 @@
<%= f.button :submit, class: "btn btn-default" %> +
<% end %> diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 46ba2cd5f..e0cee5efe 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -494,6 +494,8 @@ ca: minute: one: "%{count} minut" other: "%{count} minuts" + new: + error_amount: users: edit: edit_user: Canviar usuari diff --git a/config/locales/en.yml b/config/locales/en.yml index 8c5b4361b..199e837fc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -494,6 +494,8 @@ en: minute: one: "%{count} minute" other: "%{count} minutes" + new: + error_amount: Time must be greater than 0 users: edit: edit_user: Update user diff --git a/config/locales/es.yml b/config/locales/es.yml index 47a045be9..19b9e147e 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -494,6 +494,8 @@ es: minute: one: "%{count} minuto" other: "%{count} minutos" + new: + error_amount: users: edit: edit_user: Cambiar usuario diff --git a/config/locales/eu.yml b/config/locales/eu.yml index ee6060db4..b617383e8 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -500,6 +500,8 @@ eu: minute: one: "%{count}minutu" other: "%{count} minutu" + new: + error_amount: users: edit: edit_user: Erabiltzailea aldatu diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index a1b31f8c6..27e87eae4 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -494,6 +494,8 @@ pt-BR: minute: one: "%{count} minuto" other: "%{count} minutos" + new: + error_amount: users: edit: edit_user: Trocar usuário From 0561ed03477352d68b4d35bb57b5ad2f97dd59d3 Mon Sep 17 00:00:00 2001 From: sseerrggii Date: Mon, 18 Feb 2019 10:46:21 +0100 Subject: [PATCH 13/14] New translations --- config/locales/ca.yml | 2 +- config/locales/es.yml | 2 +- config/locales/eu.yml | 2 +- config/locales/pt-BR.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index e0cee5efe..201011210 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -495,7 +495,7 @@ ca: one: "%{count} minut" other: "%{count} minuts" new: - error_amount: + error_amount: El temps ha de ser més gran que 0 users: edit: edit_user: Canviar usuari diff --git a/config/locales/es.yml b/config/locales/es.yml index 19b9e147e..b9654ca8f 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -495,7 +495,7 @@ es: one: "%{count} minuto" other: "%{count} minutos" new: - error_amount: + error_amount: 'El tiempo debe ser mayor que 0 ' users: edit: edit_user: Cambiar usuario diff --git a/config/locales/eu.yml b/config/locales/eu.yml index b617383e8..b2cf066e8 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -501,7 +501,7 @@ eu: one: "%{count}minutu" other: "%{count} minutu" new: - error_amount: + error_amount: users: edit: edit_user: Erabiltzailea aldatu diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 27e87eae4..b3c5fde3f 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -495,7 +495,7 @@ pt-BR: one: "%{count} minuto" other: "%{count} minutos" new: - error_amount: + error_amount: users: edit: edit_user: Trocar usuário From a681c79045ed1c4dc3d59bbacc8fd9216ea611d7 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Wed, 6 Mar 2019 22:27:43 +0100 Subject: [PATCH 14/14] upgrade rspec-rails and dotenv-rails to latest stable version --- Gemfile | 4 ++-- Gemfile.lock | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index d7371516b..2f4bb81a2 100644 --- a/Gemfile +++ b/Gemfile @@ -48,15 +48,15 @@ group :development do gem 'airbrussh', require: false gem 'localeapp', '2.1.1', require: false gem 'letter_opener', '1.4.1' - gem 'dotenv-rails', '2.5.0' + gem 'dotenv-rails', '~> 2.7.1' end group :development, :test do - gem "rspec-rails", '~> 3.7.2' gem "byebug" end group :test do + gem "rspec-rails", '~> 3.8.2' gem "database_cleaner", '1.6.2' gem 'shoulda-matchers', '~> 3.1.2' gem 'fabrication' diff --git a/Gemfile.lock b/Gemfile.lock index bc228d404..6d0cfa9fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -124,10 +124,10 @@ GEM diff-lcs (1.3) domain_name (0.5.20170223) unf (>= 0.0.5, < 1.0.0) - dotenv (2.5.0) - dotenv-rails (2.5.0) - dotenv (= 2.5.0) - railties (>= 3.2, < 6.0) + dotenv (2.7.1) + dotenv-rails (2.7.1) + dotenv (= 2.7.1) + railties (>= 3.2, < 6.1) elasticsearch (1.0.8) elasticsearch-api (= 1.0.7) elasticsearch-transport (= 1.0.7) @@ -296,23 +296,23 @@ GEM netrc (~> 0.8) rollbar (2.8.3) multi_json - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-rails (3.7.2) + rspec-support (~> 3.8.0) + rspec-rails (3.8.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) rubocop (0.52.1) parallel (~> 1.10) parser (>= 2.4.0.2, < 3.0) @@ -411,7 +411,7 @@ DEPENDENCIES dalli database_cleaner (= 1.6.2) devise (~> 4.5.0) - dotenv-rails (= 2.5.0) + dotenv-rails (~> 2.7.1) elasticsearch-model elasticsearch-rails fabrication @@ -432,7 +432,7 @@ DEPENDENCIES rails_12factor (= 0.0.3) rdiscount rollbar (= 2.8.3) - rspec-rails (~> 3.7.2) + rspec-rails (~> 3.8.2) rubocop (~> 0.52.1) rufus-scheduler (~> 3.4.2) sass-rails (~> 5.0.7)