From 58b1ad950af889b9dd2358368780bc42ebefecba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Sat, 18 Feb 2017 12:11:49 +0100 Subject: [PATCH] fix bug storing null results as white results --- app/controllers/officing/results_controller.rb | 12 ++++++------ spec/features/officing/results_spec.rb | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb index 125dc9448..b6377e25b 100644 --- a/app/controllers/officing/results_controller.rb +++ b/app/controllers/officing/results_controller.rb @@ -86,13 +86,13 @@ class Officing::ResultsController < Officing::BaseController def build_null_results if results_params[:nulls].present? - white_result = ::Poll::WhiteResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, + null_result = ::Poll::NullResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: results_params[:date]) - white_result.officer_assignment_id = @officer_assignment.id - white_result.amount = results_params[:nulls].to_i - white_result.author = current_user - white_result.origin = 'booth' - @results << white_result + null_result.officer_assignment_id = @officer_assignment.id + null_result.amount = results_params[:nulls].to_i + null_result.author = current_user + null_result.origin = 'booth' + @results << null_result end end diff --git a/spec/features/officing/results_spec.rb b/spec/features/officing/results_spec.rb index e918edd59..1de3f4bdb 100644 --- a/spec/features/officing/results_spec.rb +++ b/spec/features/officing/results_spec.rb @@ -99,6 +99,8 @@ feature 'Officing Results' do fill_in "questions[#{@question_1.id}][0]", with: '5555' fill_in "questions[#{@question_1.id}][1]", with: '200' + fill_in "whites", with: '6' + fill_in "nulls", with: '7' click_button 'Save' @@ -109,6 +111,8 @@ feature 'Officing Results' do end expect(page).to_not have_content('7777') + within("#white_results") { expect(page).to have_content('6') } + within("#null_results") { expect(page).to have_content('7') } within("#question_#{@question_1.id}_0_result") { expect(page).to have_content('5555') } within("#question_#{@question_1.id}_1_result") { expect(page).to have_content('200') } end