diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/help_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 30 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/fcgi_fixes_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/sendmail_return_path_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/info_request_event_spec.rb | 28 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 103 | ||||
-rw-r--r-- | spec/models/track_mailer_spec.rb | 89 | ||||
-rw-r--r-- | spec/models/xapian_spec.rb | 4 | ||||
-rw-r--r-- | spec/rcov.opts | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 44 |
12 files changed, 180 insertions, 141 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 632458bff..c6e9ca5bb 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AdminRequestController, "when administering requests" do integrate_views - fixtures :info_requests, :outgoing_messages, :users + fixtures :info_requests, :outgoing_messages, :users, :info_request_events it "shows the index/list page" do get :index diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index ca559a8aa..28fd08c80 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -24,6 +24,7 @@ describe HelpController, "when using help" do deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 deliveries[0].body.should include("really should know") + deliveries.clear end end diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 3bcda19b0..c31491375 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -4,7 +4,14 @@ require 'json' describe TrackController, "when making a new track on a request" do before do - @ir = mock_model(InfoRequest, :url_title => 'myrequest', :title => 'My request') + @ir = mock_model(InfoRequest, :url_title => 'myrequest', + :title => 'My request') + @track_thing = mock_model(TrackThing, :save! => true, + :params => {:list_description => 'list description'}, + :track_medium= => nil, + :tracking_user_id= => nil) + TrackThing.stub!(:create_track_for_request).and_return(@track_thing) + TrackThing.stub!(:find_by_existing_track).and_return(nil) InfoRequest.stub!(:find_by_url_title).and_return(@ir) @user = mock_model(User) @@ -17,11 +24,10 @@ describe TrackController, "when making a new track on a request" do response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token) end - it "should make track and redirect if you are logged in " do - old_count = TrackThing.count + it "should save the track and redirect if you are logged in " do session[:user_id] = @user.id + @track_thing.should_receive(:save!) get :track_request, :url_title => @ir.url_title, :feed => 'track' - TrackThing.count.should == old_count + 1 response.should redirect_to(:controller => 'request', :action => 'show', :url_title => @ir.url_title) end @@ -31,11 +37,11 @@ describe TrackController, "when sending alerts for a track" do integrate_views fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :track_things_sent_emails include LinkToHelper # for main_url - + before do rebuild_xapian_index end - + it "should send alerts" do # set the time the comment event happened at to within the last week ire = info_request_events(:silly_comment_event) @@ -52,7 +58,7 @@ describe TrackController, "when sending alerts for a track" do mail.body =~ /(http:\/\/.*\/c\/(.*))/ mail_url = $1 mail_token = $2 - + mail.body.should_not =~ /&/ mail.body.should_not include('sent a request') # request not included @@ -72,7 +78,7 @@ describe TrackController, "when sending alerts for a track" do # response.should render_template('users/show') # assigns[:display_user].should == users(:silly_name_user) - # Given we can't click the link, check the token is right instead + # Given we can't click the link, check the token is right instead post_redirect = PostRedirect.find_by_email_token(mail_token) expected_url = main_url("/user/" + users(:silly_name_user).url_name + "#email_subscriptions") # XXX can't call URL making functions here, what is correct way to do this? post_redirect.uri.should == expected_url @@ -85,7 +91,7 @@ describe TrackController, "when sending alerts for a track" do end end - + describe TrackController, "when viewing RSS feed for a track" do integrate_views fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :comments, :public_bodies @@ -100,7 +106,7 @@ describe TrackController, "when viewing RSS feed for a track" do get :track_request, :feed => 'feed', :url_title => track_thing.info_request.url_title response.should render_template('track/atom_feed') # XXX should check it is an atom.builder type being rendered, not sure how to - + assigns[:xapian_object].matches_estimated.should == 3 assigns[:xapian_object].results.size.should == 3 assigns[:xapian_object].results[0][:model].should == info_request_events(:silly_comment_event) # created_at 2008-08-12 23:05:12.500942 @@ -109,9 +115,9 @@ describe TrackController, "when viewing RSS feed for a track" do end end - + describe TrackController, "when viewing JSON version of a track feed" do - + integrate_views fixtures :info_requests, :outgoing_messages, :incoming_messages, :raw_emails, :info_request_events, :users, :track_things, :comments, :public_bodies diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 94d064a49..90f90860a 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -144,7 +144,7 @@ describe UserController, "when signing up" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', :password => 'sillypassword', :password_confirmation => 'sillypasswordtwo' } } - assigns[:user_signup].errors[:password].should_not be_nil + assigns[:user_signup].errors[:password].should == 'Please enter the same password twice' end it "should be an error to sign up with a misformatted email" do diff --git a/spec/lib/fcgi_fixes_spec.rb b/spec/lib/fcgi_fixes_spec.rb deleted file mode 100644 index edc1c9d98..000000000 --- a/spec/lib/fcgi_fixes_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -# This is a test of the monkey patches in lib/fcgi_fixes.rb - -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') - -require 'railties/lib/fcgi_handler.rb' - -describe "when doing FastCGI" do - - it "should have fixed dynamic FastCGI bug" do - RailsFCGIHandler::SIGNALS['TERM'].should == :exit - end - -end - diff --git a/spec/lib/sendmail_return_path_spec.rb b/spec/lib/sendmail_return_path_spec.rb index 0a9f60953..f1a91240b 100644 --- a/spec/lib/sendmail_return_path_spec.rb +++ b/spec/lib/sendmail_return_path_spec.rb @@ -22,7 +22,7 @@ describe "when sending email with an altered return path" do mock_smtp.should_receive(:start).once.and_yield(mock_smtp_session) # the second parameter to the SMTP session is the sender (return path) - mock_smtp_session.should_receive(:sendmail).once.with(anything(), ["test@localhost"], anything()) + mock_smtp_session.should_receive(:sendmail).once.with(anything(), "test@localhost", anything()) Net::SMTP.stub!(:new).and_return(mock_smtp) diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 9f6e466bb..666f5cb1a 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -1,47 +1,47 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -describe InfoRequestEvent do - +describe InfoRequestEvent do + describe "when storing serialized parameters" do it "should convert event parameters into YAML and back successfully" do - ire = InfoRequestEvent.new + ire = InfoRequestEvent.new example_params = { :foo => 'this is stuff', :bar => 83, :humbug => "yikes!!!" } ire.params = example_params ire.params_yaml.should == example_params.to_yaml ire.params.should == example_params end - + end - describe 'when saving' do - + describe 'after saving' do + it 'should mark the model for reindexing in xapian if there is no no_xapian_reindex flag on the object' do - event = InfoRequestEvent.new(:info_request => mock_model(InfoRequest), - :event_type => 'sent', - :params => {}) + event = InfoRequestEvent.new(:info_request => mock_model(InfoRequest), + :event_type => 'sent', + :params => {}) event.should_receive(:xapian_mark_needs_index) - event.save! + event.run_callbacks(:after_save) end - + end describe "should know" do - + it "that it's an incoming message" do event = InfoRequestEvent.new(:incoming_message => mock_model(IncomingMessage)) event.is_incoming_message?.should be_true event.is_outgoing_message?.should be_false event.is_comment?.should be_false end - + it "that it's an outgoing message" do event = InfoRequestEvent.new(:outgoing_message => mock_model(OutgoingMessage)) event.is_incoming_message?.should be_false event.is_outgoing_message?.should be_true event.is_comment?.should be_false end - + it "that it's a comment" do event = InfoRequestEvent.new(:comment => mock_model(Comment)) event.is_incoming_message?.should be_false diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index c0fb9c6b4..b9e845c1d 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -4,7 +4,7 @@ describe RequestMailer, " when receiving incoming mail" do fixtures :info_requests, :incoming_messages, :raw_emails, :users, :public_bodies it "should append it to the appropriate request" do - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.incoming_messages.size.should == 1 # in the fixture receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) ir.incoming_messages.size.should == 2 # one more arrives @@ -14,12 +14,11 @@ describe RequestMailer, " when receiving incoming mail" do deliveries.size.should == 1 mail = deliveries[0] mail.to.should == [ 'bob@localhost' ] # to the user who sent fancy_dog_request - #STDERR.puts "=====" + mail.body + "======" deliveries.clear end - + it "should store mail in holding pen and send to admin when the email is not to any information request" do - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.incoming_messages.size.should == 1 InfoRequest.holding_pen_request.incoming_messages.size.should == 0 receive_incoming_mail('incoming-request-plain.email', 'dummy@localhost') @@ -35,7 +34,7 @@ describe RequestMailer, " when receiving incoming mail" do it "should return incoming mail to sender when a request is stopped fully for spam" do # mark request as anti-spam - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.allow_new_responses_from = 'nobody' ir.handle_rejected_responses = 'bounce' ir.save! @@ -54,7 +53,7 @@ describe RequestMailer, " when receiving incoming mail" do mail.multipart?.should == true mail.parts.size.should == 2 bounced_mail = TMail::Mail.parse(mail.parts[1].body) - bounced_mail.to.should == [ ir.incoming_email ] + bounced_mail.to.should == [ ir.incoming_email ] bounced_mail.from.should == [ 'geraldinequango@localhost' ] bounced_mail.body.include?("That's so totally a rubbish question") deliveries.clear @@ -62,7 +61,7 @@ describe RequestMailer, " when receiving incoming mail" do it "should return incoming mail to sender if not authority when a request is stopped for non-authority spam" do # mark request as anti-spam - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.allow_new_responses_from = 'authority_only' ir.handle_rejected_responses = 'bounce' ir.save! @@ -94,13 +93,13 @@ describe RequestMailer, " when receiving incoming mail" do it "should send all new responses to holding pen if a request is marked to do so" do # mark request as anti-spam - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.allow_new_responses_from = 'nobody' ir.handle_rejected_responses = 'holding_pen' ir.save! # test what happens if something arrives - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.incoming_messages.size.should == 1 InfoRequest.holding_pen_request.incoming_messages.size.should == 0 receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) @@ -118,13 +117,13 @@ describe RequestMailer, " when receiving incoming mail" do it "should destroy the messages sent to a request if marked to do so" do ActionMailer::Base.deliveries.clear # mark request as anti-spam - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.allow_new_responses_from = 'nobody' ir.handle_rejected_responses = 'blackhole' ir.save! # test what happens if something arrives - should be nothing - ir = info_requests(:fancy_dog_request) + ir = info_requests(:fancy_dog_request) ir.incoming_messages.size.should == 1 InfoRequest.holding_pen_request.incoming_messages.size.should == 0 receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) @@ -150,68 +149,74 @@ And a paragraph afterwards." end -describe RequestMailer, "when sending reminders to requesters to classify a response to their request" do +describe RequestMailer, "when sending reminders to requesters to classify a response to their request" do - before do + before do Time.stub!(:now).and_return(Time.utc(2007, 11, 12, 23, 59)) @mock_event = mock_model(InfoRequestEvent) @mock_response = mock_model(IncomingMessage) @mock_user = mock_model(User) @mock_request = mock_model(InfoRequest, :get_last_response_event_id => @mock_event.id, :get_last_response => @mock_response, - :user_id => 2, + :user_id => 2, :url_title => 'test_title', :user => @mock_user) InfoRequest.stub!(:find).and_return([@mock_request]) RequestMailer.stub!(:deliver_new_response_reminder_alert) + @sent_alert = mock_model(UserInfoRequestSentAlert, :user= =>nil, + :info_request= => nil, + :alert_type= => nil, + :info_request_event_id= => nil, + :save! => true) + UserInfoRequestSentAlert.stub!(:new).and_return(@sent_alert) end - + def send_alerts RequestMailer.alert_new_response_reminders_internal(7, 'new_response_reminder_1') end - - it 'should ask for all requests that are awaiting description and whose latest response is older than the number of days given and that are not the holding pen' do - expected_params = {:conditions => [ "awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen'", - true, Time.now() - 7.days ], - :include => [ :user ], + + it 'should ask for all requests that are awaiting description and whose latest response is older than the number of days given and that are not the holding pen' do + expected_params = {:conditions => [ "awaiting_description = ? and (select created_at from info_request_events where info_request_events.info_request_id = info_requests.id and info_request_events.event_type = 'response' order by created_at desc limit 1) < ? and url_title != 'holding_pen'", + true, Time.now() - 7.days ], + :include => [ :user ], :order => "info_requests.id"} InfoRequest.should_receive(:find).with(:all, expected_params).and_return([]) send_alerts end - - it 'should raise an error if a request does not have a last response event id' do + + it 'should raise an error if a request does not have a last response event id' do @mock_request.stub!(:get_last_response_event_id).and_return(nil) expected_message = "internal error, no last response while making alert new response reminder, request id #{@mock_request.id}" lambda{ send_alerts }.should raise_error(expected_message) end - - it 'should check to see if an alert matching the attributes of the one to be sent has already been sent' do - expected_params = {:conditions => [ "alert_type = ? and user_id = ? and info_request_id = ? and info_request_event_id = ?", + + it 'should check to see if an alert matching the attributes of the one to be sent has already been sent' do + expected_params = {:conditions => [ "alert_type = ? and user_id = ? and info_request_id = ? and info_request_event_id = ?", 'new_response_reminder_1', 2, @mock_request.id, @mock_event.id]} UserInfoRequestSentAlert.should_receive(:find).with(:first, expected_params) send_alerts end - - describe 'if an alert matching the attributes of the reminder to be sent has already been sent' do - - before do + + describe 'if an alert matching the attributes of the reminder to be sent has already been sent' do + + before do UserInfoRequestSentAlert.stub!(:find).and_return(mock_model(UserInfoRequestSentAlert)) end - - it 'should not send the reminder' do + + it 'should not send the reminder' do RequestMailer.should_not_receive(:deliver_new_response_reminder_alert) send_alerts end - + end - - describe 'if no alert matching the attributes of the reminder to be sent has already been sent' do - - before do + + describe 'if no alert matching the attributes of the reminder to be sent has already been sent' do + + before do UserInfoRequestSentAlert.stub!(:find).and_return(nil) end - - it 'should store the information that the reminder has been sent' do + + it 'should store the information that the reminder has been sent' do mock_sent_alert = mock_model(UserInfoRequestSentAlert) UserInfoRequestSentAlert.stub!(:new).and_return(mock_sent_alert) mock_sent_alert.should_receive(:info_request=).with(@mock_request) @@ -221,38 +226,38 @@ describe RequestMailer, "when sending reminders to requesters to classify a resp mock_sent_alert.should_receive(:save!) send_alerts end - - it 'should send the reminder' do + + it 'should send the reminder' do RequestMailer.should_receive(:deliver_new_response_reminder_alert) send_alerts end end - + end describe RequestMailer, 'when sending mail when someone has updated an old unclassified request' do - before do + before do @user = mock_model(User, :name_and_email => 'test name and email') @public_body = mock_model(PublicBody, :name => 'Test public body') @info_request = mock_model(InfoRequest, :user => @user, - :law_used_full => 'Freedom of Information', - :title => 'Test request', - :public_body => @public_body, + :law_used_full => 'Freedom of Information', + :title => 'Test request', + :public_body => @public_body, :display_status => 'Refused.', :url_title => 'test_request') - @mail = RequestMailer.create_old_unclassified_updated(@info_request) + @mail = RequestMailer.create_old_unclassified_updated(@info_request) end - it 'should have the subject "Someone has updated the status of your request"' do + it 'should have the subject "Someone has updated the status of your request"' do @mail.subject.should == 'Someone has updated the status of your request' end - it 'should tell them what status was picked' do + it 'should tell them what status was picked' do @mail.body.should match(/"refused."/) end - it 'should contain the request path' do + it 'should contain the request path' do @mail.body.should match(/request\/test_request/) end diff --git a/spec/models/track_mailer_spec.rb b/spec/models/track_mailer_spec.rb index 67e6507b6..4649c4def 100644 --- a/spec/models/track_mailer_spec.rb +++ b/spec/models/track_mailer_spec.rb @@ -2,96 +2,100 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe TrackMailer do - describe 'when sending email alerts for tracked things' do - - before do + describe 'when sending email alerts for tracked things' do + + before do TrackMailer.stub!(:deliver_event_digest) Time.stub!(:now).and_return(Time.utc(2007, 11, 12, 23, 59)) end - - it 'should ask for all the users whose last daily track email was sent more than a day ago' do + + it 'should ask for all the users whose last daily track email was sent more than a day ago' do expected_conditions = [ "last_daily_track_email < ?", Time.utc(2007, 11, 11, 23, 59)] User.should_receive(:find).with(:all, :conditions => expected_conditions).and_return([]) - TrackMailer.alert_tracks + TrackMailer.alert_tracks end - - describe 'for each user' do - - before do + + describe 'for each user' do + + before do @user = mock_model(User, :no_xapian_reindex= => false, - :last_daily_track_email= => true, + :last_daily_track_email= => true, :save! => true, :url_name => 'test-name') User.stub!(:find).and_return([@user]) @user.stub!(:no_xapian_reindex=) end - - it 'should ask for any daily track things for the user' do + + it 'should ask for any daily track things for the user' do expected_conditions = [ "tracking_user_id = ? and track_medium = ?", @user.id, 'email_daily' ] TrackThing.should_receive(:find).with(:all, :conditions => expected_conditions).and_return([]) TrackMailer.alert_tracks end - - - it 'should set the no_xapian_reindex flag on the user' do + + + it 'should set the no_xapian_reindex flag on the user' do @user.should_receive(:no_xapian_reindex=).with(true) TrackMailer.alert_tracks end - - it 'should update the time of the user\'s last daily tracking email' do + + it 'should update the time of the user\'s last daily tracking email' do @user.should_receive(:last_daily_track_email=).with(Time.now) @user.should_receive(:save!) TrackMailer.alert_tracks end - - - describe 'for each tracked thing' do - - before do + + + describe 'for each tracked thing' do + + before do @track_things_sent_emails_array = [] @track_things_sent_emails_array.stub!(:find).and_return([]) # this is for the date range find (created in last 14 days) - @track_thing = mock_model(TrackThing, :track_query => 'test query', - :track_things_sent_emails => @track_things_sent_emails_array, + @track_thing = mock_model(TrackThing, :track_query => 'test query', + :track_things_sent_emails => @track_things_sent_emails_array, :created_at => Time.utc(2007, 11, 9, 23, 59)) TrackThing.stub!(:find).and_return([@track_thing]) + @track_things_sent_email = mock_model(TrackThingsSentEmail, :save! => true, + :track_thing_id= => true, + :info_request_event_id= => true) + TrackThingsSentEmail.stub!(:new).and_return(@track_things_sent_email) @xapian_search = mock('xapian search', :results => []) @found_event = mock_model(InfoRequestEvent, :described_at => @track_thing.created_at + 1.day) @search_result = {:model => @found_event} InfoRequest.stub!(:full_search).and_return(@xapian_search) end - - it 'should ask for the events returned by the tracking query' do + + it 'should ask for the events returned by the tracking query' do InfoRequest.should_receive(:full_search).with([InfoRequestEvent], 'test query', 'described_at', true, nil, 100, 1).and_return(@xapian_search) - TrackMailer.alert_tracks + TrackMailer.alert_tracks end - - it 'should not include in the email any events that the user has already been sent a tracking email about' do + + it 'should not include in the email any events that the user has already been sent a tracking email about' do sent_email = mock_model(TrackThingsSentEmail, :info_request_event_id => @found_event.id) @track_things_sent_emails_array.stub!(:find).and_return([sent_email]) # this is for the date range find (created in last 14 days) @xapian_search.stub!(:results).and_return([@search_result]) TrackMailer.should_not_receive(:deliver_event_digest) TrackMailer.alert_tracks end - - it 'should not include in the email any events not sent in a previous tracking email that were described before the track was set up' do + + it 'should not include in the email any events not sent in a previous tracking email that were described before the track was set up' do @found_event.stub!(:described_at).and_return(@track_thing.created_at - 1.day) @xapian_search.stub!(:results).and_return([@search_result]) TrackMailer.should_not_receive(:deliver_event_digest) TrackMailer.alert_tracks end - - it 'should include in the email any events that the user has not been sent a tracking email on that have been described since the track was set up' do + + it 'should include in the email any events that the user has not been sent a tracking email on that have been described since the track was set up' do @found_event.stub!(:described_at).and_return(@track_thing.created_at + 1.day) @xapian_search.stub!(:results).and_return([@search_result]) TrackMailer.should_receive(:deliver_event_digest) TrackMailer.alert_tracks end - + it 'should raise an error if a non-event class is returned by the tracking query' do @xapian_search.stub!(:results).and_return([{:model => 'string class'}]) lambda{ TrackMailer.alert_tracks }.should raise_error('need to add other types to TrackMailer.alert_tracks (unalerted)') end - + it 'should record that a tracking email has been sent for each event that has been included in the email' do @xapian_search.stub!(:results).and_return([@search_result]) sent_email = mock_model(TrackThingsSentEmail) @@ -102,14 +106,21 @@ describe TrackMailer do TrackMailer.alert_tracks end end - + end - + end describe 'delivering the email' do + + before do + @post_redirect = mock_model(PostRedirect, :save! => true, + :email_token => "token") + PostRedirect.stub!(:new).and_return(@post_redirect) + end + it 'should deliver one email, with right headers' do - @user = mock_model(User, + @user = mock_model(User, :name_and_email => TMail::Address.address_from_name_and_email('Tippy Test', 'tippy@localhost'), :url_name => 'tippy_test' ) diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index cc319c2d7..36836d95b 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -52,14 +52,14 @@ describe PublicBody, " when indexing public bodies with Xapian" do xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body) end - it "should delete public bodies from the index when they are deleted" do + it "should delete public bodies from the index when they are destroyed" do rebuild_xapian_index xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1) xapian_object.results.size.should == 1 xapian_object.results[0][:model].should == public_bodies(:humpadink_public_body) - public_bodies(:humpadink_public_body).delete + public_bodies(:humpadink_public_body).destroy update_xapian_index xapian_object = InfoRequest.full_search([PublicBody], "albatross", 'created_at', true, nil, 100, 1) diff --git a/spec/rcov.opts b/spec/rcov.opts index baf694c9c..274ed51ad 100644 --- a/spec/rcov.opts +++ b/spec/rcov.opts @@ -1,2 +1,2 @@ ---exclude "spec/*,gems/*" +--exclude "spec/*,gems/*" --rails
\ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 25bdb229a..c6e894584 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,26 +1,57 @@ # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. -ENV["RAILS_ENV"] = "test" +ENV["RAILS_ENV"] ||= 'test' RAILS_ENV = "test" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) +require 'spec/autorun' require 'spec/rails' +# Uncomment the next line to use webrat's matchers +#require 'webrat/integrations/rspec-rails' + +# Requires supporting files with custom matchers and macros, etc, +# in ./support/ and its subdirectories. +Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} + Spec::Runner.configure do |config| + # If you're not using ActiveRecord you should remove these + # lines, delete config/database.yml and disable :active_record + # in your config/boot.rb config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures/' - # You can declare fixtures for each behaviour like this: + # == Fixtures + # + # You can declare fixtures for each example_group like this: # describe "...." do # fixtures :table_a, :table_b # # Alternatively, if you prefer to declare them only once, you can - # do so here, like so ... + # do so right here. Just uncomment the next line and replace the fixture + # names with your fixtures. # - # config.global_fixtures = :table_a, :table_b + # config.global_fixtures = :table_a, :table_b # # If you declare global fixtures, be aware that they will be declared # for all of your examples, even those that don't use them. + # + # You can also declare which fixtures to use (for example fixtures for test/fixtures): + # + # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' + # + # == Mock Framework + # + # RSpec uses its own mocking framework by default. If you prefer to + # use mocha, flexmock or RR, uncomment the appropriate line: + # + # config.mock_with :mocha + # config.mock_with :flexmock + # config.mock_with :rr + # + # == Notes + # + # For more information take a look at Spec::Runner::Configuration and Spec::Runner end # XXX No idea what namespace/class/module to put this in @@ -102,5 +133,4 @@ if $tempfilecount.nil? else puts "WARNING: HTML validation script " + $html_validation_script + " not found" end -end - +end
\ No newline at end of file |