diff options
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r-- | spec/models/info_request_spec.rb | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index c9ee57c74..3451e018f 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -670,7 +670,7 @@ describe InfoRequest do events[0].calculated_state.should == "waiting_response" events[1].event_type.should == "response" events[1].described_state.should be_nil - events[1].calculated_state.should be_nil + events[1].calculated_state.should == 'waiting_response' events[2].event_type.should == "status_update" events[2].described_state.should == "waiting_response" events[2].calculated_state.should == "waiting_response" @@ -698,7 +698,7 @@ describe InfoRequest do events[0].calculated_state.should == "waiting_response" events[1].event_type.should == "response" events[1].described_state.should be_nil - events[1].calculated_state.should be_nil + events[1].calculated_state.should == 'waiting_response' events[2].event_type.should == "status_update" events[2].described_state.should == "waiting_response" events[2].calculated_state.should == "waiting_response" @@ -731,7 +731,7 @@ describe InfoRequest do events[0].calculated_state.should == "waiting_response" events[1].event_type.should == "response" events[1].described_state.should be_nil - events[1].calculated_state.should be_nil + events[1].calculated_state.should == 'waiting_response' events[2].event_type.should == "status_update" events[2].described_state.should == "waiting_response" events[2].calculated_state.should == "waiting_response" @@ -807,6 +807,53 @@ describe InfoRequest do events[1].described_state.should == "successful" events[1].calculated_state.should == "successful" end + + it "should have sensible event states" do + # An initial request is sent + request.log_event('sent', {}) + request.set_described_state('waiting_response') + + # A response is received + request.awaiting_description = true + request.log_event("response", {}) + + # The user marks the request as successful + request.log_event("status_update", {}) + request.set_described_state("successful") + + events = request.info_request_events + events.count.should == 3 + events[0].event_type.should == "sent" + events[0].described_state.should == "waiting_response" + events[0].calculated_state.should == "waiting_response" + events[1].event_type.should == "response" + events[1].described_state.should be_nil + events[1].calculated_state.should == "successful" + events[2].event_type.should == "status_update" + events[2].described_state.should == "successful" + events[2].calculated_state.should == "successful" + end + end + + context "another series of events on a request", :focus => true do + it "should have sensible event states" do + # An initial request is sent + request.log_event('sent', {}) + request.set_described_state('waiting_response') + # An admin sets the status of the request to 'gone postal' using + # the admin interface + request.log_event("edit", {}) + request.set_described_state("gone_postal") + + events = request.info_request_events + events.count.should == 2 + events[0].event_type.should == "sent" + events[0].described_state.should == "waiting_response" + events[0].calculated_state.should == "waiting_response" + events[1].event_type.should == "edit" + events[1].described_state.should == "gone_postal" + events[1].calculated_state.should == "gone_postal" + end end end end |