diff test/.svn/text-base/test_helper.rb.svn-base @ 119:8661b858af72

* Update to Redmine trunk rev 4705
author Chris Cannam
date Thu, 13 Jan 2011 14:12:06 +0000
parents 94944d00e43c
children cd2282d2aa55 cbce1fd3b1b7
line wrap: on
line diff
--- a/test/.svn/text-base/test_helper.rb.svn-base	Fri Nov 19 14:05:24 2010 +0000
+++ b/test/.svn/text-base/test_helper.rb.svn-base	Thu Jan 13 14:12:06 2011 +0000
@@ -59,7 +59,7 @@
   end
   
   def uploaded_test_file(name, mime)
-    ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime)
+    ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
   end
 
   # Mock out a file
@@ -115,7 +115,7 @@
   end
   
   def assert_error_tag(options={})
-    assert_tag({:tag => 'p', :attributes => { :id => 'errorExplanation' }}.merge(options))
+    assert_tag({:attributes => { :id => 'errorExplanation' }}.merge(options))
   end
 
   # Shoulda macros
@@ -361,6 +361,20 @@
       end
     end
     
+    context "should allow key based auth using X-Redmine-API-Key header for #{http_method} #{url}" do
+      setup do
+        @user = User.generate_with_protected!(:admin => true)
+        @token = Token.generate!(:user => @user, :action => 'api')
+        send(http_method, url, parameters, {'X-Redmine-API-Key' => @token.value.to_s})
+      end
+      
+      should_respond_with success_code
+      should_respond_with_content_type_based_on_url(url)
+      should_be_a_valid_response_string_based_on_url(url)
+      should "login as the user" do
+        assert_equal @user, User.current
+      end
+    end
   end
 
   # Uses should_respond_with_content_type based on what's in the url: