diff options
author | Henare Degan <henare.degan@gmail.com> | 2013-02-27 10:34:47 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2013-02-27 10:34:47 +1100 |
commit | 835b51c1de0d49e652fe9c9a60f0974275de070c (patch) | |
tree | 0d64a841f28654a66556bcc0c0bb1153bae645a2 /spec/views/request/show.html.erb_spec.rb | |
parent | 77a284d6d088f7aa6d40810d46a39658fc6cf2cd (diff) |
Rename ALL THE TEMPLATES!!1!!!one!!1!!
.rhtml is deprecated in favour of .erb in Rails 3
Diffstat (limited to 'spec/views/request/show.html.erb_spec.rb')
-rw-r--r-- | spec/views/request/show.html.erb_spec.rb | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/spec/views/request/show.html.erb_spec.rb b/spec/views/request/show.html.erb_spec.rb new file mode 100644 index 000000000..cc5226847 --- /dev/null +++ b/spec/views/request/show.html.erb_spec.rb @@ -0,0 +1,109 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +describe 'when viewing an information request' do + + before do + @mock_body = mock_model(PublicBody, :name => 'test body', + :url_name => 'test_body', + :is_school? => false) + @mock_user = mock_model(User, :name => 'test user', + :url_name => 'test_user', + :profile_photo => nil) + @mock_request = mock_model(InfoRequest, :title => 'test request', + :awaiting_description => false, + :law_used_with_a => 'A Freedom of Information request', + :law_used_full => 'Freedom of Information', + :public_body => @mock_body, + :user => @mock_user, + :user_name => @mock_user.name, + :is_external? => false, + :calculate_status => 'waiting_response', + :date_response_required_by => Date.today, + :prominence => 'normal') + end + + def request_page + assign :info_request, @mock_request + assign :info_request_events, [] + assign :status, @mock_request.calculate_status + # This is so icky! + view.stub!(:_render_partial) + render :template => 'request/show' + end + + describe 'when a status update has been requested' do + + before do + assign :update_status, true + end + + it 'should show the first form for describing the state of the request' do + request_page + response.should have_selector("div.describe_state_form#describe_state_form_1") + end + + end + + describe 'when it is awaiting a description' do + + before do + @mock_request.stub!(:awaiting_description).and_return(true) + end + + it 'should show the first form for describing the state of the request' do + request_page + response.should have_selector("div.describe_state_form#describe_state_form_1") + end + + it 'should show the second form for describing the state of the request' do + request_page + response.should have_selector("div.describe_state_form#describe_state_form_2") + end + + end + + describe 'when the user is the request owner' do + + before do + assign :is_owning_user, true + end + + describe 'when the request status is "waiting clarification"' do + + before do + @mock_request.stub!(:calculate_status).and_return('waiting_clarification') + end + + describe 'when there is a last response' do + + before do + @mock_response = mock_model(IncomingMessage) + @mock_request.stub!(:get_last_response).and_return(@mock_response) + end + + + it 'should show a link to follow up the last response with clarification' do + request_page + expected_url = "http://test.host/en/request/#{@mock_request.id}/response/#{@mock_response.id}#followup" + response.should have_selector("a", :href => expected_url, :content => 'send a follow up message') + end + + end + + describe 'when there is no last response' do + + before do + @mock_request.stub!(:get_last_response).and_return(nil) + end + + + it 'should show a link to follow up the request without reference to a specific response' do + request_page + expected_url = "http://test.host/en/request/#{@mock_request.id}/response#followup" + response.should have_selector("a", :href => expected_url, :content => 'send a follow up message') + end + end + end + + end +end |