diff --git a/spec/factories.rb b/spec/factories.rb index de2e509..0512148 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -20,6 +20,12 @@ Factory.define(:aoi_question, :parent => :question) do |f| :creator => question.creator, :active => true) end + 2.times do + result << Factory.build(:choice, + :question => question.result, + :creator => question.creator, + :active => false) + end result end f.prompts do |question| diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb index 33da502..4901ce6 100644 --- a/spec/models/question_spec.rb +++ b/spec/models/question_spec.rb @@ -47,7 +47,7 @@ describe Question do end it "should raise runtime exception if there is no possible prompt to choose" do - @question.choices.first.deactivate! + @question.choices.active.each{|c| c.deactivate!} @question.reload lambda { @question.choose_prompt}.should raise_error(RuntimeError) @@ -211,8 +211,8 @@ describe Question do @catchup_q.uses_catchup = true @catchup_q.save! - # 2 ideas already exist, so this will make an even hundred - 98.times.each do |num| + # 4 ideas already exist, so this will make an even hundred + 96.times.each do |num| @catchup_q.site.create_choice("visitor identifier", @catchup_q, {:data => num.to_s, :local_identifier => "exmaple"}) end @catchup_q.reload @@ -241,6 +241,17 @@ describe Question do (sum - 1.0).abs.should < 0.000001 end + it "should not have any inactive choices in the the vector of weights" do + weights = @catchup_q.catchup_prompts_weights + weights.each do |items, value| + left_choice_id, right_choice_id = items.split(", ") + cl = Choice.find(left_choice_id) + cr = Choice.find(right_choice_id) + cl.active?.should == true + cr.active?.should == true + end + end + it "should allow the prompt queue to be cleared" do @catchup_q.add_prompt_to_queue @catchup_q.clear_prompt_queue -- libgit2 0.21.2