Merge pull request #1425 from consul/fix-null-white-results
fix bug storing null results as white results
This commit is contained in:
@@ -86,13 +86,13 @@ class Officing::ResultsController < Officing::BaseController
|
|||||||
|
|
||||||
def build_null_results
|
def build_null_results
|
||||||
if results_params[:nulls].present?
|
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])
|
date: results_params[:date])
|
||||||
white_result.officer_assignment_id = @officer_assignment.id
|
null_result.officer_assignment_id = @officer_assignment.id
|
||||||
white_result.amount = results_params[:nulls].to_i
|
null_result.amount = results_params[:nulls].to_i
|
||||||
white_result.author = current_user
|
null_result.author = current_user
|
||||||
white_result.origin = 'booth'
|
null_result.origin = 'booth'
|
||||||
@results << white_result
|
@results << null_result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ feature 'Officing Results' do
|
|||||||
|
|
||||||
fill_in "questions[#{@question_1.id}][0]", with: '5555'
|
fill_in "questions[#{@question_1.id}][0]", with: '5555'
|
||||||
fill_in "questions[#{@question_1.id}][1]", with: '200'
|
fill_in "questions[#{@question_1.id}][1]", with: '200'
|
||||||
|
fill_in "whites", with: '6'
|
||||||
|
fill_in "nulls", with: '7'
|
||||||
|
|
||||||
click_button 'Save'
|
click_button 'Save'
|
||||||
|
|
||||||
@@ -109,6 +111,8 @@ feature 'Officing Results' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to_not have_content('7777')
|
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}_0_result") { expect(page).to have_content('5555') }
|
||||||
within("#question_#{@question_1.id}_1_result") { expect(page).to have_content('200') }
|
within("#question_#{@question_1.id}_1_result") { expect(page).to have_content('200') }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user