Skip to content

Commit

Permalink
fixed supervision specs
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzak committed Oct 5, 2011
1 parent 806e131 commit cb2142b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 27 deletions.
8 changes: 7 additions & 1 deletion app/models/supervision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,23 @@ 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
end

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
Expand All @@ -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
Expand Down Expand Up @@ -229,7 +235,7 @@ def publish_notification_to_redis
protected

def sufficent_users?
members.size > 1
members.count > 1
end

def cancel_supervision?
Expand Down
63 changes: 37 additions & 26 deletions spec/models/supervision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -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!

Expand All @@ -667,25 +681,15 @@
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!

@supervision.giving_solutions_feedback?.should be_true
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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cb2142b

Please sign in to comment.