Commit bfb34f2d0ef0a40d79cad1a91cfc972e29ee089e

Authored by Luke Baker
1 parent 0a38626f

fix bug in question creation

we were trying to create prompts before there was enough enabled
app/models/choice.rb
... ... @@ -29,7 +29,9 @@ class Choice < ActiveRecord::Base
29 29 def update_prompt_queue
30 30 if self.changed.include?('active') && self.active?
31 31 self.question.mark_prompt_queue_for_refill
32   - self.question.choose_prompt
  32 + if self.question.choices.size - self.question.inactive_choices_count > 1
  33 + self.question.choose_prompt
  34 + end
33 35 end
34 36 end
35 37  
... ...
spec/models/choice_spec.rb
... ... @@ -88,7 +88,7 @@ describe Choice do
88 88  
89 89 it "should create a delayed job on activation" do
90 90 choice1 = Choice.create!(@valid_attributes.merge(:data => '1234'))
91   - proc { choice1.deactivate! }.should change(Delayed::Job, :count).by(1)
  91 + proc { choice1.activate! }.should change(Delayed::Job, :count).by(1)
92 92 end
93 93  
94 94 it "should update a question's counter cache on deactivation" do
... ...