diff options
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/user_controller_spec.rb | 70 | ||||
-rw-r--r-- | spec/integration/search_request_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/xapian_spec.rb | 22 |
7 files changed, 67 insertions, 67 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 935f8eab6..830486493 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -144,7 +144,7 @@ describe GeneralController, "when showing the front page with fixture data" do describe 'when constructing the list of recent requests' do before(:each) do - rebuild_xapian_index + get_fixtures_xapian_index end describe 'when there are fewer than five successful requests' do @@ -189,8 +189,8 @@ describe GeneralController, 'when using xapian search' do # rebuild xapian index after fixtures loaded before(:each) do - load_raw_emails_data - rebuild_xapian_index + load_raw_emails_data + get_fixtures_xapian_index end it "should redirect from search query URL to pretty URL" do diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index d12818a1c..29ece18cb 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -6,7 +6,7 @@ describe PublicBodyController, "when showing a body" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should be successful" do @@ -29,14 +29,14 @@ describe PublicBodyController, "when showing a body" do assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all( :conditions => ["public_body_id = ?", public_bodies(:geraldine_public_body).id]) end - + it "should assign the requests (2)" do get :show, :url_name => "tgq", :view => 'successful' assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all( :conditions => ["described_state = ? and public_body_id = ?", "successful", public_bodies(:geraldine_public_body).id]) end - + it "should assign the requests (3)" do get :show, :url_name => "dfh", :view => 'all' assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all( @@ -66,7 +66,7 @@ describe PublicBodyController, "when showing a body" do ActionController::Routing::Routes.filters = old_filters end - + it "should redirect to newest name if you use historic name of public body in URL" do get :show, :url_name => "hdink", :view => 'all' response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") @@ -148,7 +148,7 @@ describe PublicBodyController, "when listing bodies" do get :list, :tag => "other" response.should render_template('list') assigns[:public_bodies].should =~ PublicBody.all(:conditions => "id not in (#{public_bodies(:humpadink_public_body).id}, #{PublicBody.internal_admin_body.id})") - + get :list response.should render_template('list') assigns[:public_bodies].should =~ PublicBody.all(:conditions => "id <> #{PublicBody.internal_admin_body.id}") @@ -194,10 +194,10 @@ end describe PublicBodyController, "when doing type ahead searches" do integrate_views - + before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should return nothing for the empty query string" do @@ -205,7 +205,7 @@ describe PublicBodyController, "when doing type ahead searches" do response.should render_template('public_body/_search_ahead') assigns[:xapian_requests].should be_nil end - + it "should return a body matching the given keyword, but not users with a matching description" do get :search_typeahead, :query => "Geraldine" response.should render_template('public_body/_search_ahead') @@ -230,7 +230,7 @@ describe PublicBodyController, "when doing type ahead searches" do end it "should not return matches for short words" do - get :search_typeahead, :query => "b" + get :search_typeahead, :query => "b" response.should render_template('public_body/_search_ahead') assigns[:xapian_requests].should be_nil end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index b0223588e..e898fb91b 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -5,7 +5,7 @@ describe RequestController, "when listing recent requests" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should be successful" do diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 7daa23769..c785960b5 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -38,7 +38,7 @@ describe TrackController, "when making a new track on a request" do get :track_request, :url_title => @ir.url_title, :feed => 'track' response.should redirect_to(:controller => 'request', :action => 'show', :url_title => @ir.url_title) end - + it "should 404 for non-existent requests" do session[:user_id] = @user.id lambda { @@ -61,9 +61,9 @@ describe TrackController, "when sending alerts for a track" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end - + it "should send alerts" do # Don't do clever locale-insertion-unto-URL stuff old_filters = ActionController::Routing::Routes.filters @@ -138,7 +138,7 @@ describe TrackController, "when viewing RSS feed for a track" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should get the RSS feed" do @@ -168,7 +168,7 @@ describe TrackController, "when viewing JSON version of a track feed" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should get the feed" do @@ -210,9 +210,9 @@ describe TrackController, "when tracking a public body" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end - + it "should work" do geraldine = public_bodies(:geraldine_public_body) get :track_public_body, :feed => 'feed', :url_name => geraldine.url_name diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 386d1b04b..23006803b 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -8,9 +8,9 @@ describe UserController, "when showing a user" do integrate_views before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end - + it "should be successful" do get :show, :url_name => "bob_smith" response.should be_success @@ -45,7 +45,7 @@ describe UserController, "when showing a user" do get :show, :url_name => "bob_smith" assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ InfoRequest.all( :conditions => "user_id = #{users(:bob_smith_user).id}") - + get :show, :url_name => "bob_smith", :user_query => "money" assigns[:xapian_requests].results.map{|x|x[:model].info_request}.should =~ [ info_requests(:naughty_chicken_request), @@ -218,7 +218,7 @@ describe UserController, "when signing in" do # Get the confirmation URL, and check we’re still Joe get :confirm, :email_token => post_redirect.email_token session[:user_id].should == users(:admin_user).id - + # And the redirect should still work, of course response.should redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) @@ -232,21 +232,21 @@ describe UserController, "when signing up" do it "should be an error if you type the password differently each time" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', - :password => 'sillypassword', :password_confirmation => 'sillypasswordtwo' } + :password => 'sillypassword', :password_confirmation => 'sillypasswordtwo' } } 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 post :signup, { :user_signup => { :email => 'malformed-email', :name => 'Mr Malformed', - :password => 'sillypassword', :password_confirmation => 'sillypassword' } + :password => 'sillypassword', :password_confirmation => 'sillypassword' } } assigns[:user_signup].errors[:email].should_not be_nil end it "should send confirmation mail if you fill in the form right" do post :signup, { :user_signup => { :email => 'new@localhost', :name => 'New Person', - :password => 'sillypassword', :password_confirmation => 'sillypassword' } + :password => 'sillypassword', :password_confirmation => 'sillypassword' } } response.should render_template('confirm') @@ -270,13 +270,13 @@ describe UserController, "when signing up" do it "should send special 'already signed up' mail if you fill the form in with existing registered email" do post :signup, { :user_signup => { :email => 'silly@localhost', :name => 'New Person', - :password => 'sillypassword', :password_confirmation => 'sillypassword' } + :password => 'sillypassword', :password_confirmation => 'sillypassword' } } response.should render_template('confirm') deliveries = ActionMailer::Base.deliveries deliveries.size.should == 1 - + # This text may span a line break, depending on the length of the SITE_NAME deliveries[0].body.should match(/when\s+you\s+already\s+have\s+an/) end @@ -377,7 +377,7 @@ describe UserController, "when changing password" do get :signchangepassword response.should render_template('signchangepassword') end - + it "should change the password, if you have right to do so" do session[:user_id] = users(:bob_smith_user).id session[:user_circumstance] = "change_password" @@ -437,8 +437,8 @@ describe UserController, "when changing email address" do it "should be an error if the password is wrong, everything else right" do @user = users(:bob_smith_user) session[:user_id] = @user.id - - post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', + + post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', :password => 'donotknowpassword', :new_email => 'newbob@localhost' }, :submitted_signchangeemail_do => 1 } @@ -455,8 +455,8 @@ describe UserController, "when changing email address" do it "should be an error if old email is wrong, everything else right" do @user = users(:bob_smith_user) session[:user_id] = @user.id - - post :signchangeemail, { :signchangeemail => { :old_email => 'bob@moo', + + post :signchangeemail, { :signchangeemail => { :old_email => 'bob@moo', :password => 'jonespassword', :new_email => 'newbob@localhost' }, :submitted_signchangeemail_do => 1 } @@ -473,8 +473,8 @@ describe UserController, "when changing email address" do it "should work even if the old email had a case difference" do @user = users(:bob_smith_user) session[:user_id] = @user.id - - post :signchangeemail, { :signchangeemail => { :old_email => 'BOB@localhost', + + post :signchangeemail, { :signchangeemail => { :old_email => 'BOB@localhost', :password => 'jonespassword', :new_email => 'newbob@localhost' }, :submitted_signchangeemail_do => 1 } @@ -485,8 +485,8 @@ describe UserController, "when changing email address" do it "should send confirmation email if you get all the details right" do @user = users(:bob_smith_user) session[:user_id] = @user.id - - post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', + + post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', :password => 'jonespassword', :new_email => 'newbob@localhost' }, :submitted_signchangeemail_do => 1 } @@ -521,16 +521,16 @@ describe UserController, "when changing email address" do post_redirect = PostRedirect.find_by_email_token(mail_token) post_redirect.circumstance.should == 'change_email' post_redirect.user.should == users(:bob_smith_user) - post_redirect.post_params.should == {"submitted_signchangeemail_do"=>"1", - "action"=>"signchangeemail", + post_redirect.post_params.should == {"submitted_signchangeemail_do"=>"1", + "action"=>"signchangeemail", "signchangeemail"=>{ - "old_email"=>"bob@localhost", - "new_email"=>"newbob@localhost"}, + "old_email"=>"bob@localhost", + "new_email"=>"newbob@localhost"}, "controller"=>"user"} post :signchangeemail, post_redirect.post_params response.should redirect_to(:controller => 'user', :action => 'show', :url_name => 'bob_smith') - flash[:notice].should match(/You have now changed your email address/) + flash[:notice].should match(/You have now changed your email address/) @user.reload @user.email.should == 'newbob@localhost' @user.email_confirmed.should == true @@ -539,8 +539,8 @@ describe UserController, "when changing email address" do it "should send special 'already signed up' mail if you try to change your email to one already used" do @user = users(:bob_smith_user) session[:user_id] = @user.id - - post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', + + post :signchangeemail, { :signchangeemail => { :old_email => 'bob@localhost', :password => 'jonespassword', :new_email => 'silly@localhost' }, :submitted_signchangeemail_do => 1 } @@ -572,9 +572,9 @@ describe UserController, "when using profile photos" do @uploadedfile_2 = File.open(file_fixture_name("parrot.jpg")) @uploadedfile_2.stub!(:original_filename).and_return('parrot.jpg') end - + it "should not let you change profile photo if you're not logged in as the user" do - post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } + post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } end it "should return a 404 not a 500 when a profile photo has not been set" do @@ -588,10 +588,10 @@ describe UserController, "when using profile photos" do @user.profile_photo.should be_nil session[:user_id] = @user.id - post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } + post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } response.should redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") - flash[:notice].should match(/Thank you for updating your profile photo/) + flash[:notice].should match(/Thank you for updating your profile photo/) @user.reload @user.profile_photo.should_not be_nil @@ -601,13 +601,13 @@ describe UserController, "when using profile photos" do @user.profile_photo.should be_nil session[:user_id] = @user.id - post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } + post :set_profile_photo, { :id => @user.id, :file => @uploadedfile, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } response.should redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") - flash[:notice].should match(/Thank you for updating your profile photo/) + flash[:notice].should match(/Thank you for updating your profile photo/) - post :set_profile_photo, { :id => @user.id, :file => @uploadedfile_2, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } + post :set_profile_photo, { :id => @user.id, :file => @uploadedfile_2, :submitted_draft_profile_photo => 1, :automatically_crop => 1 } response.should redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") - flash[:notice].should match(/Thank you for updating your profile photo/) + flash[:notice].should match(/Thank you for updating your profile photo/) @user.reload @user.profile_photo.should_not be_nil @@ -617,7 +617,7 @@ describe UserController, "when using profile photos" do end describe UserController, "when showing JSON version for API" do - + it "should be successful" do get :show, :url_name => "bob_smith", :format => "json" @@ -634,7 +634,7 @@ describe UserController, "when viewing the wall" do integrate_views before(:each) do - rebuild_xapian_index + get_fixtures_xapian_index end it "should show users stuff on their wall, most recent first" do diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 17a7b4aaa..c564032a6 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -4,7 +4,7 @@ describe "When searching" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should not strip quotes from quoted query" do diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 195b39eee..8c99d550f 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -4,9 +4,9 @@ describe User, " when indexing users with Xapian" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end - + it "should search by name" do # def InfoRequest.full_search(models, query, order, ascending, collapse, per_page, page) xapian_object = InfoRequest.full_search([User], "Silly", 'created_at', true, nil, 100, 1) @@ -21,7 +21,7 @@ describe User, " when indexing users with Xapian" do xapian_object = InfoRequest.full_search([User], "stuff", 'created_at', true, nil, 100, 1) xapian_object.results.size.should == 1 xapian_object.results[0][:model].should == user - + user.about_me = "I am really an aardvark, true story." user.save! update_xapian_index @@ -38,7 +38,7 @@ end describe PublicBody, " when indexing public bodies with Xapian" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should search index the main name field" do @@ -71,7 +71,7 @@ describe PublicBody, " when indexing requests by body they are to" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find requests to the body" do @@ -126,7 +126,7 @@ end describe User, " when indexing requests by user they are from" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find requests from the user" do @@ -204,7 +204,7 @@ end describe User, " when indexing comments by user they are by" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find requests from the user" do @@ -239,7 +239,7 @@ end describe InfoRequest, " when indexing requests by their title" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find events for the request" do @@ -268,7 +268,7 @@ end describe InfoRequest, " when indexing requests by tag" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find request by tag, even when changes" do @@ -289,7 +289,7 @@ end describe PublicBody, " when indexing authorities by tag" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should find request by tag, even when changes" do @@ -313,7 +313,7 @@ end describe PublicBody, " when only indexing selected things on a rebuild" do before(:each) do load_raw_emails_data - rebuild_xapian_index + get_fixtures_xapian_index end it "should only index what we ask it to" do |