aboutsummaryrefslogtreecommitdiffstats
path: root/spec/views
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/request/_after_actions.rhtml_spec.rb61
-rw-r--r--spec/views/request/_describe_state.rhtml_spec.rb49
-rw-r--r--spec/views/request/show.rhtml_spec.rb111
3 files changed, 219 insertions, 2 deletions
diff --git a/spec/views/request/_after_actions.rhtml_spec.rb b/spec/views/request/_after_actions.rhtml_spec.rb
new file mode 100644
index 000000000..7893d2e49
--- /dev/null
+++ b/spec/views/request/_after_actions.rhtml_spec.rb
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe 'when displaying actions that can be taken with regard to a request' do
+
+ before do
+ @mock_body = mock_model(PublicBody, :name => 'test public body',
+ :url_name => 'test_public_body')
+ @mock_user = mock_model(User, :name => 'test user',
+ :url_name => 'test_user')
+ @mock_request = mock_model(InfoRequest, :title => 'test request',
+ :user => @mock_user,
+ :public_body => @mock_body,
+ :url_title => 'test_request')
+ assigns[:info_request] = @mock_request
+ end
+
+ def do_render
+ render :partial => 'request/after_actions'
+ end
+
+ def expect_owner_link(text)
+ do_render
+ response.should have_tag('div#owner_actions') do
+ with_tag('a', :text => text)
+ end
+ end
+
+ it 'should display a link for the request owner to update the status of the request' do
+ expect_owner_link('Update the status of this request')
+ end
+
+ it 'should display a link for the request owner to request a review' do
+ expect_owner_link('Request an internal review')
+ end
+
+ describe 'when there is no last response' do
+
+ before do
+ assigns[:last_response] = nil
+ end
+
+ it 'should display a link for the request owner to send a follow up' do
+ expect_owner_link('Send follow up to test public body')
+ end
+
+ end
+
+ describe 'when there is a last response' do
+
+ before do
+ assigns[:last_response] = mock_model(IncomingMessage,
+ :valid_to_reply_to? => false)
+ end
+
+ it 'should display a link for the request owner to reply to the last response' do
+ expect_owner_link('Reply to test public body')
+ end
+
+ end
+
+end \ No newline at end of file
diff --git a/spec/views/request/_describe_state.rhtml_spec.rb b/spec/views/request/_describe_state.rhtml_spec.rb
index 306f70060..ebb1d5a91 100644
--- a/spec/views/request/_describe_state.rhtml_spec.rb
+++ b/spec/views/request/_describe_state.rhtml_spec.rb
@@ -6,6 +6,11 @@ describe 'when showing the form for describing the state of a request' do
do_render
response.should have_tag("input[type=radio][value=#{value}]")
end
+
+ def expect_no_radio_button(value)
+ do_render
+ response.should_not have_tag("input[type=radio][value=#{value}]")
+ end
def do_render
render :partial => 'request/describe_state', :locals => {:id_suffix => '1'}
@@ -17,17 +22,22 @@ describe 'when showing the form for describing the state of a request' do
assigns[:info_request] = @mock_request
end
- describe 'if showing the form to a regular user' do
+ describe 'if the user is a regular user' do
before do
assigns[:is_owning_user] = false
end
+ it 'should not show the form' do
+ do_render
+ response.should_not have_tag('form')
+ end
+
it 'should give a link to login' do
do_render
response.should have_tag('a', :text => 'sign in')
end
-
+
end
describe 'if showing the form to the user owning the request' do
@@ -49,7 +59,31 @@ describe 'when showing the form for describing the state of a request' do
it 'should show a radio button to set the status to "waiting clarification"' do
expect_radio_button('waiting_clarification')
end
+
+ it 'should not show a radio button to set the status to "internal_review"' do
+ expect_no_radio_button('internal_review')
+ end
+
+ end
+ describe 'when the user has asked to update the status of the request' do
+
+ before do
+ assigns[:update_status] = true
+ end
+
+ it 'should show a radio button to set the status to "internal_review"' do
+ expect_radio_button('internal_review')
+ end
+
+ it 'should show a radio button to set the status to "requires_admin"' do
+ expect_radio_button('requires_admin')
+ end
+
+ it 'should show a radio button to set the status to "user_withdrawn"' do
+ expect_radio_button('user_withdrawn')
+ end
+
end
describe 'when the request is in internal review' do
@@ -68,6 +102,9 @@ describe 'when showing the form for describing the state of a request' do
end
end
+
+ describe 'when request is awaiting a description and the user has not asked to update the status' do
+ end
it 'should show a radio button to set the status to "gone postal"' do
expect_radio_button('gone_postal')
@@ -93,5 +130,13 @@ describe 'when showing the form for describing the state of a request' do
expect_radio_button('error_message')
end
+ it 'should not show a radio button to set the status to "requires_admin"' do
+ expect_no_radio_button('requires_admin')
+ end
+
+ it 'should not show a radio button to set the status to "user_withdrawn"' do
+ expect_no_radio_button('user_withdrawn')
+ end
+
end
end \ No newline at end of file
diff --git a/spec/views/request/show.rhtml_spec.rb b/spec/views/request/show.rhtml_spec.rb
new file mode 100644
index 000000000..f4222e354
--- /dev/null
+++ b/spec/views/request/show.rhtml_spec.rb
@@ -0,0 +1,111 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe 'when viewing an information request' do
+
+ before do
+ @mock_body = mock_model(PublicBody, :name => 'test body',
+ :url_name => 'test_body')
+ @mock_user = mock_model(User, :name => 'test user',
+ :url_name => 'test_user')
+ @mock_request = mock_model(InfoRequest, :title => 'test request',
+ :awaiting_description => false,
+ :law_used_with_a => '',
+ :public_body => @mock_body,
+ :user => @mock_user,
+ :calculate_status => 'waiting_response',
+ :date_response_required_by => Date.today)
+ end
+
+ def do_render
+ assigns[:info_request] = @mock_request
+ assigns[:info_request_events] = []
+ assigns[:status] = @mock_request.calculate_status
+ template.stub!(:render)
+ render 'request/show'
+ end
+
+ it 'should show the sidebar' do
+ template.should_receive(:render).with(:partial => 'sidebar')
+ do_render
+ end
+
+ it 'should show the actions people can take' do
+ template.should_receive(:render).with(:partial => 'after_actions')
+ do_render
+ end
+
+ describe 'when a status update has been requested' do
+
+ before do
+ assigns[:update_status] = true
+ end
+
+ it 'should show the first form for describing the state of the request' do
+ do_render
+ response.should have_tag("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
+ do_render
+ response.should have_tag("div.describe_state_form#describe_state_form_1")
+ end
+
+ it 'should show the second form for describing the state of the request' do
+ do_render
+ response.should have_tag("div.describe_state_form#describe_state_form_2")
+ end
+
+ end
+
+ describe 'when the user is the request owner' do
+
+ before do
+ assigns[: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
+ do_render
+ expected_url = "http://test.host/request/#{@mock_request.id}/response/#{@mock_response.id}#followup"
+ puts response.body
+ response.should have_tag("a[href=#{expected_url}]", :text => '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
+ do_render
+ expected_url = "http://test.host/request/#{@mock_request.id}/response#followup"
+ response.should have_tag("a[href=#{expected_url}]", :text => 'send a follow up message')
+ end
+ end
+ end
+
+ end
+end \ No newline at end of file