diff options
author | louise <louise> | 2009-04-06 08:34:35 +0000 |
---|---|---|
committer | louise <louise> | 2009-04-06 08:34:35 +0000 |
commit | ed6861f787408e603c238a5e1c8e7c8297a58206 (patch) | |
tree | 389a5b3570fe0f2e070d4c2970747f107583400c /spec/models/info_request_spec.rb | |
parent | 74978e4c4c79941a5f763d90e66df8fcca3bdc42 (diff) |
Adding is_owning_user? method to info request to replace logic in RequestController
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r-- | spec/models/info_request_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 41470fda4..51d2d559f 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -123,4 +123,33 @@ describe InfoRequest do @ir.calculate_status.should == 'waiting_response_overdue' end end + + describe 'when asked if a user is the owning user for this request' do + + before do + @mock_user = mock_model(User) + @info_request = InfoRequest.new(:user => @mock_user) + @other_mock_user = mock_model(User) + end + + it 'should return false if a nil object is passed to it' do + @info_request.is_owning_user?(nil).should be_false + end + + it 'should return true if the user is the request\'s user' do + @info_request.is_owning_user?(@mock_user).should be_true + end + + it 'should return false for a user that is not the owner and does not own every request' do + @other_mock_user.stub!(:owns_every_request?).and_return(false) + @info_request.is_owning_user?(@other_mock_user).should be_false + end + + it 'should return true if the user owns every request' do + @other_mock_user.stub!(:owns_every_request?).and_return(true) + @info_request.is_owning_user?(@other_mock_user).should be_true + end + + end + end
\ No newline at end of file |