diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-08-07 14:32:40 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-08-15 10:11:47 +0100 |
commit | e2154bdf9f5b4e389da50e6a073772aa3f59d11d (patch) | |
tree | c50002cfb4f3b838e81b1d8fd9c9da5077829fe0 /spec/models/info_request_spec.rb | |
parent | be201cae650d21182b920c1766316a97f2bd1915 (diff) |
Allow 'edit' and 'status_update' calculated states to propagate.
Update test expectations and add further test to explicitly show that we
want the described status from a status update to be propagated to a
preceding response, as well as being filled in in the status update
itself (which is mostly to deal with the case where there isn't a
preceding response). Make those changes to calculate_event_states
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r-- | spec/models/info_request_spec.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index c9ee57c74..a63da01db 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,32 @@ 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 end end |