From 835b51c1de0d49e652fe9c9a60f0974275de070c Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Wed, 27 Feb 2013 10:34:47 +1100 Subject: Rename ALL THE TEMPLATES!!1!!!one!!1!! .rhtml is deprecated in favour of .erb in Rails 3 --- spec/views/public_body/show.html.erb_spec.rb | 119 ++++++++++++++ spec/views/public_body/show.rhtml_spec.rb | 119 -------------- spec/views/request/_after_actions.html.erb_spec.rb | 93 +++++++++++ spec/views/request/_after_actions.rhtml_spec.rb | 93 ----------- .../views/request/_describe_state.html.erb_spec.rb | 173 +++++++++++++++++++++ spec/views/request/_describe_state.rhtml_spec.rb | 173 --------------------- spec/views/request/list.html.erb_spec.rb | 49 ++++++ spec/views/request/list.rhtml_spec.rb | 49 ------ spec/views/request/show.html.erb_spec.rb | 109 +++++++++++++ spec/views/request/show.rhtml_spec.rb | 109 ------------- spec/views/request_game/play.html.erb_spec.rb | 37 +++++ spec/views/request_game/play.rhtml_spec.rb | 37 ----- 12 files changed, 580 insertions(+), 580 deletions(-) create mode 100644 spec/views/public_body/show.html.erb_spec.rb delete mode 100644 spec/views/public_body/show.rhtml_spec.rb create mode 100644 spec/views/request/_after_actions.html.erb_spec.rb delete mode 100644 spec/views/request/_after_actions.rhtml_spec.rb create mode 100644 spec/views/request/_describe_state.html.erb_spec.rb delete mode 100644 spec/views/request/_describe_state.rhtml_spec.rb create mode 100644 spec/views/request/list.html.erb_spec.rb delete mode 100644 spec/views/request/list.rhtml_spec.rb create mode 100644 spec/views/request/show.html.erb_spec.rb delete mode 100644 spec/views/request/show.rhtml_spec.rb create mode 100644 spec/views/request_game/play.html.erb_spec.rb delete mode 100644 spec/views/request_game/play.rhtml_spec.rb (limited to 'spec/views') diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb new file mode 100644 index 000000000..1a972a661 --- /dev/null +++ b/spec/views/public_body/show.html.erb_spec.rb @@ -0,0 +1,119 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +describe "public_body/show" do + before do + @pb = mock_model(PublicBody, + :name => 'Test Quango', + :short_name => 'tq', + :url_name => 'testquango', + :notes => '', + :type_of_authority => 'A public body', + :eir_only? => nil, + :info_requests => [1, 2, 3, 4], # out of sync with Xapian + :publication_scheme => '', + :disclosure_log => '', + :calculated_home_page => '') + @pb.stub!(:override_request_email).and_return(nil) + @pb.stub!(:is_requestable?).and_return(true) + @pb.stub!(:has_notes?).and_return(false) + @pb.stub!(:has_tag?).and_return(false) + @xap = mock(ActsAsXapian::Search, :matches_estimated => 2) + @xap.stub!(:results).and_return([ + { :model => mock_event }, + { :model => mock_event } + ]) + + assign(:public_body, @pb) + assign(:track_thing, mock_model(TrackThing, + :track_type => 'public_body_updates', :public_body => @pb, :params => {})) + assign(:xapian_requests, @xap) + assign(:page, 1) + assign(:per_page, 10) + end + + it "should be successful" do + render + controller.response.should be_success + end + + it "should be valid HTML" do + render + validate_as_body response.body + end + + it "should show the body's name" do + render + response.should have_selector('h1', :content => "Test Quango") + end + + it "should tell total number of requests" do + render + response.should match "4 Freedom of Information requests" + end + + it "should cope with no results" do + @pb.stub!(:info_requests).and_return([]) + render + response.should have_selector('p', :content => "Nobody has made any Freedom of Information requests") + end + + it "should cope with Xapian being down" do + assign(:xapian_requests, nil) + render + response.should match "The search index is currently offline" + end + + it "should link to Charity Commission site if we have numbers to do so" do + @pb.stub!(:has_tag?).and_return(true) + @pb.stub!(:get_tag_values).and_return(['98765', '12345']) + + render + response.should have_selector("div#header_right") do + have_selector "a", :href => /charity-commission.gov.uk.*RegisteredCharityNumber=98765$/ + end + response.should have_selector("div#header_right") do + have_selector "a", :href => /www.charity-commission.gov.uk.*RegisteredCharityNumber=12345$/ + end + end + + it "should link to Scottish Charity Regulator site if we have an SC number" do + @pb.stub!(:has_tag?).and_return(true) + @pb.stub!(:get_tag_values).and_return(['SC1234']) + + render + response.should have_selector("div#header_right") do + have_selector "a", :href => /www.oscr.org.uk.*id=SC1234$/ + end + end + + + it "should not link to Charity Commission site if we don't have number" do + render + response.should have_selector("div#header_right") do + have_selector "a", :href => /charity-commission.gov.uk/ + end + end + + +end + +def mock_event + return mock_model(InfoRequestEvent, + :info_request => mock_model(InfoRequest, + :title => 'Title', + :url_title => 'title', + :display_status => 'waiting_response', + :calculate_status => 'waiting_response', + :public_body => @pb, + :is_external? => false, + :user => mock_model(User, :name => 'Test User', :url_name => 'testuser') + ), + :incoming_message => nil, :is_incoming_message? => false, + :outgoing_message => nil, :is_outgoing_message? => false, + :comment => nil, :is_comment? => false, + :event_type => 'sent', + :created_at => Time.now - 4.days, + :search_text_main => '' + ) +end + diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb deleted file mode 100644 index 1a972a661..000000000 --- a/spec/views/public_body/show.rhtml_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) - -describe "public_body/show" do - before do - @pb = mock_model(PublicBody, - :name => 'Test Quango', - :short_name => 'tq', - :url_name => 'testquango', - :notes => '', - :type_of_authority => 'A public body', - :eir_only? => nil, - :info_requests => [1, 2, 3, 4], # out of sync with Xapian - :publication_scheme => '', - :disclosure_log => '', - :calculated_home_page => '') - @pb.stub!(:override_request_email).and_return(nil) - @pb.stub!(:is_requestable?).and_return(true) - @pb.stub!(:has_notes?).and_return(false) - @pb.stub!(:has_tag?).and_return(false) - @xap = mock(ActsAsXapian::Search, :matches_estimated => 2) - @xap.stub!(:results).and_return([ - { :model => mock_event }, - { :model => mock_event } - ]) - - assign(:public_body, @pb) - assign(:track_thing, mock_model(TrackThing, - :track_type => 'public_body_updates', :public_body => @pb, :params => {})) - assign(:xapian_requests, @xap) - assign(:page, 1) - assign(:per_page, 10) - end - - it "should be successful" do - render - controller.response.should be_success - end - - it "should be valid HTML" do - render - validate_as_body response.body - end - - it "should show the body's name" do - render - response.should have_selector('h1', :content => "Test Quango") - end - - it "should tell total number of requests" do - render - response.should match "4 Freedom of Information requests" - end - - it "should cope with no results" do - @pb.stub!(:info_requests).and_return([]) - render - response.should have_selector('p', :content => "Nobody has made any Freedom of Information requests") - end - - it "should cope with Xapian being down" do - assign(:xapian_requests, nil) - render - response.should match "The search index is currently offline" - end - - it "should link to Charity Commission site if we have numbers to do so" do - @pb.stub!(:has_tag?).and_return(true) - @pb.stub!(:get_tag_values).and_return(['98765', '12345']) - - render - response.should have_selector("div#header_right") do - have_selector "a", :href => /charity-commission.gov.uk.*RegisteredCharityNumber=98765$/ - end - response.should have_selector("div#header_right") do - have_selector "a", :href => /www.charity-commission.gov.uk.*RegisteredCharityNumber=12345$/ - end - end - - it "should link to Scottish Charity Regulator site if we have an SC number" do - @pb.stub!(:has_tag?).and_return(true) - @pb.stub!(:get_tag_values).and_return(['SC1234']) - - render - response.should have_selector("div#header_right") do - have_selector "a", :href => /www.oscr.org.uk.*id=SC1234$/ - end - end - - - it "should not link to Charity Commission site if we don't have number" do - render - response.should have_selector("div#header_right") do - have_selector "a", :href => /charity-commission.gov.uk/ - end - end - - -end - -def mock_event - return mock_model(InfoRequestEvent, - :info_request => mock_model(InfoRequest, - :title => 'Title', - :url_title => 'title', - :display_status => 'waiting_response', - :calculate_status => 'waiting_response', - :public_body => @pb, - :is_external? => false, - :user => mock_model(User, :name => 'Test User', :url_name => 'testuser') - ), - :incoming_message => nil, :is_incoming_message? => false, - :outgoing_message => nil, :is_outgoing_message? => false, - :comment => nil, :is_comment? => false, - :event_type => 'sent', - :created_at => Time.now - 4.days, - :search_text_main => '' - ) -end - diff --git a/spec/views/request/_after_actions.html.erb_spec.rb b/spec/views/request/_after_actions.html.erb_spec.rb new file mode 100644 index 000000000..ae398f4ce --- /dev/null +++ b/spec/views/request/_after_actions.html.erb_spec.rb @@ -0,0 +1,93 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +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, + :user_name => @mock_user.name, + :is_external? => false, + :public_body => @mock_body, + :comments_allowed? => true, + :url_title => 'test_request', + :all_can_view? => true) + assign :info_request, @mock_request + end + + describe 'if the request is old and unclassified' do + + before do + assign :old_unclassified, true + end + + it 'should not display a link for the request owner to update the status of the request' do + render :partial => 'request/after_actions' + response.should have_selector('div#owner_actions') do |div| + div.should_not have_selector('a', :content => 'Update the status of this request') + end + end + + it 'should display a link for anyone to update the status of the request' do + render :partial => 'request/after_actions' + response.should have_selector('div#anyone_actions') do |div| + div.should have_selector('a', :content => 'Update the status of this request') + end + end + + end + + describe 'if the request is not old and unclassified' do + + before do + assign :old_unclassified, false + end + + it 'should display a link for the request owner to update the status of the request' do + render :partial => 'request/after_actions' + response.should have_selector('div#owner_actions') do |div| + div.should have_selector('a', :content => 'Update the status of this request') + end + end + + it 'should not display a link for anyone to update the status of the request' do + render :partial => 'request/after_actions' + response.should have_selector('div#anyone_actions') do |div| + div.should_not have_selector('a', :content => 'Update the status of this request') + end + end + + end + + it 'should display a link for the request owner to request a review' do + render :partial => 'request/after_actions' + response.should have_selector('div#owner_actions') do |div| + div.should have_selector('a', :content => 'Request an internal review') + end + end + + describe 'if the request is viewable by all' do + + it 'should display the link to download the entire request' do + render :partial => 'request/after_actions' + response.should have_selector('div#anyone_actions') do |div| + div.should have_selector('a', :content => 'Download a zip file of all correspondence') + end + end + end + + describe 'if the request is not viewable by all' do + + it 'should not display the link to download the entire request' do + @mock_request.stub!(:all_can_view?).and_return(false) + render :partial => 'request/after_actions' + response.should have_selector('div#anyone_actions') do |div| + div.should_not have_selector('a', :content => 'Download a zip file of all correspondence') + end + end + end + +end diff --git a/spec/views/request/_after_actions.rhtml_spec.rb b/spec/views/request/_after_actions.rhtml_spec.rb deleted file mode 100644 index ae398f4ce..000000000 --- a/spec/views/request/_after_actions.rhtml_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) - -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, - :user_name => @mock_user.name, - :is_external? => false, - :public_body => @mock_body, - :comments_allowed? => true, - :url_title => 'test_request', - :all_can_view? => true) - assign :info_request, @mock_request - end - - describe 'if the request is old and unclassified' do - - before do - assign :old_unclassified, true - end - - it 'should not display a link for the request owner to update the status of the request' do - render :partial => 'request/after_actions' - response.should have_selector('div#owner_actions') do |div| - div.should_not have_selector('a', :content => 'Update the status of this request') - end - end - - it 'should display a link for anyone to update the status of the request' do - render :partial => 'request/after_actions' - response.should have_selector('div#anyone_actions') do |div| - div.should have_selector('a', :content => 'Update the status of this request') - end - end - - end - - describe 'if the request is not old and unclassified' do - - before do - assign :old_unclassified, false - end - - it 'should display a link for the request owner to update the status of the request' do - render :partial => 'request/after_actions' - response.should have_selector('div#owner_actions') do |div| - div.should have_selector('a', :content => 'Update the status of this request') - end - end - - it 'should not display a link for anyone to update the status of the request' do - render :partial => 'request/after_actions' - response.should have_selector('div#anyone_actions') do |div| - div.should_not have_selector('a', :content => 'Update the status of this request') - end - end - - end - - it 'should display a link for the request owner to request a review' do - render :partial => 'request/after_actions' - response.should have_selector('div#owner_actions') do |div| - div.should have_selector('a', :content => 'Request an internal review') - end - end - - describe 'if the request is viewable by all' do - - it 'should display the link to download the entire request' do - render :partial => 'request/after_actions' - response.should have_selector('div#anyone_actions') do |div| - div.should have_selector('a', :content => 'Download a zip file of all correspondence') - end - end - end - - describe 'if the request is not viewable by all' do - - it 'should not display the link to download the entire request' do - @mock_request.stub!(:all_can_view?).and_return(false) - render :partial => 'request/after_actions' - response.should have_selector('div#anyone_actions') do |div| - div.should_not have_selector('a', :content => 'Download a zip file of all correspondence') - end - end - end - -end diff --git a/spec/views/request/_describe_state.html.erb_spec.rb b/spec/views/request/_describe_state.html.erb_spec.rb new file mode 100644 index 000000000..88dea53c5 --- /dev/null +++ b/spec/views/request/_describe_state.html.erb_spec.rb @@ -0,0 +1,173 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +describe 'when showing the form for describing the state of a request' do + + def expect_radio_button(value) + do_render + response.should have_selector('input', :type => 'radio', :value => value) + end + + def expect_no_radio_button(value) + do_render + response.should_not have_selector('input', :type => 'radio', :value => value) + end + + def do_render + render :partial => 'request/describe_state', :locals => {:id_suffix => '1'} + end + + before do + @mock_user = mock_model(User, :name => 'test user', :url_name => 'test_user') + @mock_request = mock_model(InfoRequest, + :described_state => '', + :user => @mock_user, + :user_name => @mock_user.name, + :is_external? => false + ) + assign :info_request, @mock_request + end + + describe 'if the user is a regular user (not the request owner)' do + + before do + assign :is_owning_user, false + end + + describe 'if the request is not old and unclassified' do + + it 'should not show the form' do + do_render + response.should_not have_selector('h2', :content => 'What best describes the status of this request now?') + end + + it 'should give a link to login' do + do_render + response.should have_selector('a', :content => 'sign in') + end + + end + + describe 'if the request is old and unclassified' do + + before do + assign :old_unclassified, true + end + + it 'should not show the form' do + do_render + response.should_not have_selector('h2', :content => 'What best describes the status of this request now?') + end + + it 'should show the form for someone else to classify the request' do + do_render + response.should have_selector('h2', :content => 'We need your help') + end + + it 'should not give a link to login' do + do_render + response.should_not have_selector('a', :content => 'sign in') + end + end + + end + + describe 'if showing the form to the user owning the request' do + + before do + assign :is_owning_user, true + end + + describe 'when the request is not in internal review' do + + before do + @mock_request.stub!(:described_state).and_return('waiting response') + end + + it 'should show a radio button to set the status to "waiting response"' do + expect_radio_button('waiting_response') + end + + 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 + assign :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 + + before do + @mock_request.stub!(:described_state).and_return('internal_review') + end + + it 'should show a radio button to set the status to "internal review"' do + expect_radio_button('internal_review') + end + + it 'should show the text "The review has finished and overall:"' do + do_render + response.should have_selector('p', :content => 'The review has finished and overall:') + 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') + end + + it 'should show a radio button to set the status to "not held"' do + expect_radio_button('not_held') + end + + it 'should show a radio button to set the status to "partially successful"' do + expect_radio_button('partially_successful') + end + + it 'should show a radio button to set the status to "successful"' do + expect_radio_button('successful') + end + + it 'should show a radio button to set the status to "rejected"' do + expect_radio_button('rejected') + end + + it 'should show a radio button to set the status to "error_message"' 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 diff --git a/spec/views/request/_describe_state.rhtml_spec.rb b/spec/views/request/_describe_state.rhtml_spec.rb deleted file mode 100644 index 88dea53c5..000000000 --- a/spec/views/request/_describe_state.rhtml_spec.rb +++ /dev/null @@ -1,173 +0,0 @@ -require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) - -describe 'when showing the form for describing the state of a request' do - - def expect_radio_button(value) - do_render - response.should have_selector('input', :type => 'radio', :value => value) - end - - def expect_no_radio_button(value) - do_render - response.should_not have_selector('input', :type => 'radio', :value => value) - end - - def do_render - render :partial => 'request/describe_state', :locals => {:id_suffix => '1'} - end - - before do - @mock_user = mock_model(User, :name => 'test user', :url_name => 'test_user') - @mock_request = mock_model(InfoRequest, - :described_state => '', - :user => @mock_user, - :user_name => @mock_user.name, - :is_external? => false - ) - assign :info_request, @mock_request - end - - describe 'if the user is a regular user (not the request owner)' do - - before do - assign :is_owning_user, false - end - - describe 'if the request is not old and unclassified' do - - it 'should not show the form' do - do_render - response.should_not have_selector('h2', :content => 'What best describes the status of this request now?') - end - - it 'should give a link to login' do - do_render - response.should have_selector('a', :content => 'sign in') - end - - end - - describe 'if the request is old and unclassified' do - - before do - assign :old_unclassified, true - end - - it 'should not show the form' do - do_render - response.should_not have_selector('h2', :content => 'What best describes the status of this request now?') - end - - it 'should show the form for someone else to classify the request' do - do_render - response.should have_selector('h2', :content => 'We need your help') - end - - it 'should not give a link to login' do - do_render - response.should_not have_selector('a', :content => 'sign in') - end - end - - end - - describe 'if showing the form to the user owning the request' do - - before do - assign :is_owning_user, true - end - - describe 'when the request is not in internal review' do - - before do - @mock_request.stub!(:described_state).and_return('waiting response') - end - - it 'should show a radio button to set the status to "waiting response"' do - expect_radio_button('waiting_response') - end - - 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 - assign :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 - - before do - @mock_request.stub!(:described_state).and_return('internal_review') - end - - it 'should show a radio button to set the status to "internal review"' do - expect_radio_button('internal_review') - end - - it 'should show the text "The review has finished and overall:"' do - do_render - response.should have_selector('p', :content => 'The review has finished and overall:') - 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') - end - - it 'should show a radio button to set the status to "not held"' do - expect_radio_button('not_held') - end - - it 'should show a radio button to set the status to "partially successful"' do - expect_radio_button('partially_successful') - end - - it 'should show a radio button to set the status to "successful"' do - expect_radio_button('successful') - end - - it 'should show a radio button to set the status to "rejected"' do - expect_radio_button('rejected') - end - - it 'should show a radio button to set the status to "error_message"' 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 diff --git a/spec/views/request/list.html.erb_spec.rb b/spec/views/request/list.html.erb_spec.rb new file mode 100644 index 000000000..521d946bc --- /dev/null +++ b/spec/views/request/list.html.erb_spec.rb @@ -0,0 +1,49 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +describe "request/list" do + + before do + assign :page, 1 + assign :per_page, 10 + end + + def make_mock_event + return mock_model(InfoRequestEvent, + :info_request => mock_model(InfoRequest, + :title => 'Title', + :url_title => 'title', + :display_status => 'awaiting_response', + :calculate_status => 'awaiting_response', + :public_body => mock_model(PublicBody, :name => 'Test Quango', :url_name => 'testquango'), + :user => mock_model(User, :name => 'Test User', :url_name => 'testuser'), + :is_external? => false + ), + :incoming_message => nil, :is_incoming_message? => false, + :outgoing_message => nil, :is_outgoing_message? => false, + :comment => nil, :is_comment? => false, + :event_type => 'sent', + :created_at => Time.now - 4.days, + :search_text_main => '' + ) + end + + it "should be successful" do + assign :list_results, [ make_mock_event, make_mock_event ] + assign :matches_estimated, 2 + assign :show_no_more_than, 100 + render + response.should have_selector("div.request_listing") + response.should_not have_selector("p", :content => "No requests of this sort yet") + end + + it "should cope with no results" do + assign :list_results, [ ] + assign :matches_estimated, 0 + assign :show_no_more_than, 0 + render + response.should have_selector("p", :content => "No requests of this sort yet") + response.should_not have_selector("div.request_listing") + end + +end + diff --git a/spec/views/request/list.rhtml_spec.rb b/spec/views/request/list.rhtml_spec.rb deleted file mode 100644 index 521d946bc..000000000 --- a/spec/views/request/list.rhtml_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) - -describe "request/list" do - - before do - assign :page, 1 - assign :per_page, 10 - end - - def make_mock_event - return mock_model(InfoRequestEvent, - :info_request => mock_model(InfoRequest, - :title => 'Title', - :url_title => 'title', - :display_status => 'awaiting_response', - :calculate_status => 'awaiting_response', - :public_body => mock_model(PublicBody, :name => 'Test Quango', :url_name => 'testquango'), - :user => mock_model(User, :name => 'Test User', :url_name => 'testuser'), - :is_external? => false - ), - :incoming_message => nil, :is_incoming_message? => false, - :outgoing_message => nil, :is_outgoing_message? => false, - :comment => nil, :is_comment? => false, - :event_type => 'sent', - :created_at => Time.now - 4.days, - :search_text_main => '' - ) - end - - it "should be successful" do - assign :list_results, [ make_mock_event, make_mock_event ] - assign :matches_estimated, 2 - assign :show_no_more_than, 100 - render - response.should have_selector("div.request_listing") - response.should_not have_selector("p", :content => "No requests of this sort yet") - end - - it "should cope with no results" do - assign :list_results, [ ] - assign :matches_estimated, 0 - assign :show_no_more_than, 0 - render - response.should have_selector("p", :content => "No requests of this sort yet") - response.should_not have_selector("div.request_listing") - end - -end - 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 diff --git a/spec/views/request/show.rhtml_spec.rb b/spec/views/request/show.rhtml_spec.rb deleted file mode 100644 index cc5226847..000000000 --- a/spec/views/request/show.rhtml_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -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 diff --git a/spec/views/request_game/play.html.erb_spec.rb b/spec/views/request_game/play.html.erb_spec.rb new file mode 100644 index 000000000..b5cf57c23 --- /dev/null +++ b/spec/views/request_game/play.html.erb_spec.rb @@ -0,0 +1,37 @@ +require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) + +describe 'request_game/play' 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, + :url_title => 'a_test_request', + :user => @mock_user, + :calculate_status => 'waiting_response', + :date_response_required_by => Date.today, + :prominence => 'normal', + :initial_request_text => 'hi there', + :display_status => 'Awaiting categorisation', + :created_at => Time.now) + assign :league_table_28_days, [] + assign :league_table_all_time, [] + assign :requests, [@mock_request] + assign :play_urls, true + end + + it 'should show the correct url for a request' do + render + response.should include("/categorise/request/a_test_request") + end + + +end diff --git a/spec/views/request_game/play.rhtml_spec.rb b/spec/views/request_game/play.rhtml_spec.rb deleted file mode 100644 index b5cf57c23..000000000 --- a/spec/views/request_game/play.rhtml_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__) - -describe 'request_game/play' 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, - :url_title => 'a_test_request', - :user => @mock_user, - :calculate_status => 'waiting_response', - :date_response_required_by => Date.today, - :prominence => 'normal', - :initial_request_text => 'hi there', - :display_status => 'Awaiting categorisation', - :created_at => Time.now) - assign :league_table_28_days, [] - assign :league_table_all_time, [] - assign :requests, [@mock_request] - assign :play_urls, true - end - - it 'should show the correct url for a request' do - render - response.should include("/categorise/request/a_test_request") - end - - -end -- cgit v1.2.3