From cbee536313f5dd5bd970417b735afe01e4c010e2 Mon Sep 17 00:00:00 2001 From: Derek Ekins Date: Fri, 20 Aug 2021 08:59:06 +0100 Subject: [PATCH] fix up failing tests --- .exrc | 30 +++++++++++++++++++---- app/controllers/initiatives_controller.rb | 2 ++ test/models/initiative_test.rb | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.exrc b/.exrc index 6edac40..e1fc3b0 100644 --- a/.exrc +++ b/.exrc @@ -1,9 +1,29 @@ -let g:vigun_extra_keywords = ['test'] +let g:vigun_test_keywords = ['test', 'it', 'context', 'describe'] +let g:vjs_tags_enabled = 0 -let g:vigun_commands = [ +fun! s:watch(cmd) + return "rg --files | entr -r -c sh -c 'echo ".escape('"'.a:cmd.'"', '"')." && ".a:cmd."'" +endf + +let g:vigun_mappings = [ + \ { + \ 'pattern': 'test/.*_test.rb$', + \ 'all': 'rails test #{file}', + \ 'nearest': 'rails test #{file}:#{line}', + \ 'watch-all': s:watch('rails test #{file}'), + \ 'watch-nearest': s:watch('rails test #{file}:#{line}'), + \ }, \ { - \ 'pattern': 'test/.*_test.rb$', - \ 'normal': 'rails test', - \ 'debug': 'BACKTRACE=1 rails test', + \ 'pattern': 'test/javascript/.*_test.js$', + \ 'all': 'yarn test #{file}', + \ 'nearest': 'yarn test --fgrep #{nearest_test} #{file}', + \ 'debug-all': 'yarn test --interactive #{file}', + \ 'debug-nearest': 'yarn test --interactive --fgrep #{nearest_test} #{file}', \ } \] + +command! -nargs=0 Fixturex :cexpr system('./bin/fixturex.rb '. expand('%:t:r') .' '.shellescape(expand(''))) | copen + +" open report fixture in a split to the right +" nnoremap gj :exec "botright vnew +" test/fixtures/reports/".expand('').".json" diff --git a/app/controllers/initiatives_controller.rb b/app/controllers/initiatives_controller.rb index 5fb11a6..684b740 100644 --- a/app/controllers/initiatives_controller.rb +++ b/app/controllers/initiatives_controller.rb @@ -2,6 +2,8 @@ # rubocop:disable Metrics/ClassLength class InitiativesController < ApplicationController + include ApplicationHelper + before_action :set_initiative, only: %i[edit update] before_action :set_edit_data, only: %i[edit new create update] skip_before_action :authenticate_user!, only: %i[index show] diff --git a/test/models/initiative_test.rb b/test/models/initiative_test.rb index 6c65d2e..798d12d 100644 --- a/test/models/initiative_test.rb +++ b/test/models/initiative_test.rb @@ -64,6 +64,7 @@ class InitiativeTest < ActiveSupport::TestCase def expected_initiative_attributes [ { + id: Initiative.first.id, name: 'The Fruit Exchange', description_what: 'Connecting people with surplus food', description_how: 'Bringing food to the people',