diff --git a/app/models/supervision.rb b/app/models/supervision.rb index f271299..78da051 100644 --- a/app/models/supervision.rb +++ b/app/models/supervision.rb @@ -101,9 +101,12 @@ def supervision_id; id; end # aliasing doesn't work event :step_back_to_asking_questions do transition [ :asking_questions, + :giving_answers, :providing_ideas, + :voting_ideas, :giving_ideas_feedback, :providing_solutions, + :voting_solutions, :giving_solutions_feedback, :giving_supervision_feedbacks ] => :asking_questions @@ -111,8 +114,10 @@ def supervision_id; id; end # aliasing doesn't work event :step_back_to_providing_ideas do transition [ + :voting_ideas, :giving_ideas_feedback, :providing_solutions, + :voting_solutions, :giving_solutions_feedback, :giving_supervision_feedbacks ] => :providing_ideas @@ -121,6 +126,7 @@ def supervision_id; id; end # aliasing doesn't work event :step_back_to_giving_ideas_feedback do transition [ :providing_solutions, + :voting_solutions, :giving_solutions_feedback, :giving_supervision_feedbacks ] => :giving_ideas_feedback @@ -229,7 +235,7 @@ def publish_notification_to_redis protected def sufficent_users? - members.size > 1 + members.count > 1 end def cancel_supervision? diff --git a/spec/models/supervision_spec.rb b/spec/models/supervision_spec.rb index a14469c..8366f95 100644 --- a/spec/models/supervision_spec.rb +++ b/spec/models/supervision_spec.rb @@ -533,7 +533,8 @@ describe "step back to asking_questions" do it "should be allowed from providing_ideas" do @supervision = FactoryGirl.build(:supervision, :state => "providing_ideas") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_asking_questions! @@ -542,7 +543,8 @@ it "should be allowed from giving_ideas_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_ideas_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_asking_questions! @@ -551,7 +553,8 @@ it "should be allowed from providing_solutions" do @supervision = FactoryGirl.build(:supervision, :state => "providing_solutions") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_asking_questions! @@ -560,7 +563,8 @@ it "should be allowed from giving_solutions_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_solutions_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_asking_questions! @@ -569,7 +573,8 @@ it "should be allowed from giving_supervision_feedbacks" do @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_asking_questions! @@ -580,7 +585,8 @@ describe "step back to providing_ideas" do it "should be allowed from giving_ideas_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_ideas_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_ideas! @@ -589,7 +595,8 @@ it "should be allowed from providing_solutions" do @supervision = FactoryGirl.build(:supervision, :state => "providing_solutions") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_ideas! @@ -598,7 +605,8 @@ it "should be allowed from giving_solutions_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_solutions_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_ideas! @@ -607,7 +615,8 @@ it "should be allowed from giving_supervision_feedbacks" do @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_ideas! @@ -618,7 +627,8 @@ describe "step back to giving_ideas_feedback" do it "should be allowed from providing_solutions" do @supervision = FactoryGirl.build(:supervision, :state => "providing_solutions") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_giving_ideas_feedback! @@ -627,7 +637,8 @@ it "should be allowed from giving_solutions_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_solutions_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_giving_ideas_feedback! @@ -636,7 +647,8 @@ it "should be allowed from giving_supervision_feedbacks" do @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_giving_ideas_feedback! @@ -647,7 +659,8 @@ describe "step back to providing_solutions" do it "should be allowed from giving_solutions_feedback" do @supervision = FactoryGirl.build(:supervision, :state => "giving_solutions_feedback") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_solutions! @@ -656,7 +669,8 @@ it "should be allowed from giving_supervision_feedbacks" do @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_providing_solutions! @@ -667,7 +681,8 @@ describe "step back to giving_solutions_feedback" do it "should be allowed from giving_supervision_feedbacks" do @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.should_receive(:publish_to_redis) @supervision.step_back_to_giving_solutions_feedback! @@ -675,17 +690,6 @@ end end - describe "#join_member" do - it "should not change state" do - @supervision = FactoryGirl.build(:supervision, :state => "giving_supervision_feedbacks") - - @supervision.should_receive(:publish_to_redis) - @supervision.join_member! - - @supervision.giving_supervision_feedbacks?.should be_true - end - end - describe "#remove_member" do before do @alice = FactoryGirl.create(:user) @@ -756,8 +760,15 @@ end describe "state_event attribute" do + before do + @alice = FactoryGirl.create(:user) + @bob = FactoryGirl.create(:user) + end + it "should be accessible to mass assignment" do @supervision = FactoryGirl.create(:supervision, :state => "providing_ideas") + @bob.join_supervision(@supervision) + @alice.join_supervision(@supervision) @supervision.update_attributes({:state_event => "step_back_to_asking_questions"}) @supervision.state.should == "asking_questions" @supervision.asking_questions?.should be_true