]> source.dussan.org Git - redmine.git/commitdiff
Test cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jan 2012 19:59:52 +0000 (19:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 2 Jan 2012 19:59:52 +0000 (19:59 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8477 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/api_test/attachments_test.rb
test/integration/api_test/disabled_rest_api_test.rb
test/integration/api_test/issue_categories_test.rb
test/integration/api_test/issue_relations_test.rb
test/integration/api_test/issues_test.rb
test/integration/api_test/projects_test.rb
test/integration/api_test/time_entries_test.rb
test/integration/api_test/users_test.rb
test/integration/api_test/versions_test.rb
test/test_helper.rb

index 9beb8b09aa2de7b4880f284202be29417eecf854..1f8d67cf3cfba8f3ff9af59221f24877a9e53c6d 100644 (file)
@@ -40,7 +40,7 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
   context "/attachments/:id" do
     context "GET" do
       should "return the attachment" do
-        get '/attachments/7.xml', {}, :authorization => credentials('jsmith')
+        get '/attachments/7.xml', {}, credentials('jsmith')
         assert_response :success
         assert_equal 'application/xml', @response.content_type
         assert_tag :tag => 'attachment',
@@ -69,8 +69,7 @@ class ApiTest::AttachmentsTest < ActionController::IntegrationTest
   context "/attachments/download/:id/:filename" do
     context "GET" do
       should "return the attachment content" do
-        get '/attachments/download/7/archive.zip',
-            {}, :authorization => credentials('jsmith')
+        get '/attachments/download/7/archive.zip', {}, credentials('jsmith')
         assert_response :success
         assert_equal 'application/octet-stream', @response.content_type
         set_tmp_attachments_directory
index 22029b9a46e24ecb3a431ffb3dbfdd144fb59e9c..23e78ce2caf43808578f4135875cef1b6348e21b 100644 (file)
@@ -41,7 +41,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
-          get "/news.xml", nil, :authorization => credentials(@user.login, 'my_password')
+          get "/news.xml", nil, credentials(@user.login, 'my_password')
         end
 
         should_respond_with :unauthorized
@@ -55,7 +55,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'api')
-          get "/news.xml", nil, :authorization => credentials(@token.value, 'X')
+          get "/news.xml", nil, credentials(@token.value, 'X')
         end
 
         should_respond_with :unauthorized
@@ -84,7 +84,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
-          get "/news.json", nil, :authorization => credentials(@user.login, 'my_password')
+          get "/news.json", nil, credentials(@user.login, 'my_password')
         end
 
         should_respond_with :unauthorized
@@ -98,7 +98,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'api')
-          get "/news.json", nil, :authorization => credentials(@token.value, 'DoesNotMatter')
+          get "/news.json", nil, credentials(@token.value, 'DoesNotMatter')
         end
 
         should_respond_with :unauthorized
index af20a80ae3119a0d803b641fd7379f6f8dccc7ba..920a3901cab6a5f17f0ab631141a460c51149a96 100644 (file)
@@ -30,7 +30,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
 
   context "GET /projects/:project_id/issue_categories.xml" do
     should "return issue categories" do
-      get '/projects/1/issue_categories.xml', {}, :authorization => credentials('jsmith')
+      get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
       assert_response :success
       assert_equal 'application/xml', @response.content_type
       assert_tag :tag => 'issue_categories',
@@ -40,7 +40,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
 
   context "GET /issue_categories/2.xml" do
     should "return requested issue category" do
-      get '/issue_categories/2.xml', {}, :authorization => credentials('jsmith')
+      get '/issue_categories/2.xml', {}, credentials('jsmith')
       assert_response :success
       assert_equal 'application/xml', @response.content_type
       assert_tag :tag => 'issue_category',
@@ -51,7 +51,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
   context "POST /projects/:project_id/issue_categories.xml" do
     should "return create issue category" do
       assert_difference 'IssueCategory.count' do
-        post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, :authorization => credentials('jsmith')
+        post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith')
       end
       assert_response :created
       assert_equal 'application/xml', @response.content_type
@@ -64,7 +64,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
     context "with invalid parameters" do
       should "return errors" do
         assert_no_difference 'IssueCategory.count' do
-          post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, :authorization => credentials('jsmith')
+          post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
         end
         assert_response :unprocessable_entity
         assert_equal 'application/xml', @response.content_type
@@ -78,7 +78,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
     context "with valid parameters" do
       should "update issue category" do
         assert_no_difference 'IssueCategory.count' do
-          put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, :authorization => credentials('jsmith')
+          put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith')
         end
         assert_response :ok
         assert_equal 'API Update', IssueCategory.find(2).name
@@ -88,7 +88,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
     context "with invalid parameters" do
       should "return errors" do
         assert_no_difference 'IssueCategory.count' do
-          put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, :authorization => credentials('jsmith')
+          put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
         end
         assert_response :unprocessable_entity
         assert_equal 'application/xml', @response.content_type
@@ -101,7 +101,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
   context "DELETE /issue_categories/1.xml" do
     should "destroy issue categories" do
       assert_difference 'IssueCategory.count', -1 do
-        delete '/issue_categories/1.xml', {}, :authorization => credentials('jsmith')
+        delete '/issue_categories/1.xml', {}, credentials('jsmith')
       end
       assert_response :ok
       assert_nil IssueCategory.find_by_id(1)
@@ -113,7 +113,7 @@ class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest
 
       assert_difference 'IssueCategory.count', -1 do
         assert_difference 'Issue.count(:conditions => {:category_id => 2})', 3 do
-          delete '/issue_categories/1.xml', {:reassign_to_id => 2}, :authorization => credentials('jsmith')
+          delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith')
         end
       end
       assert_response :ok
index 01dbe3da9caa7c41fe10034ca70c83090619cf65..55fd761a9bfada0695d1b23c63138cf9c2cfcd25 100644 (file)
@@ -35,7 +35,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
   context "/issues/:issue_id/relations" do
     context "GET" do
       should "return issue relations" do
-        get '/issues/9/relations.xml', {}, :authorization => credentials('jsmith')
+        get '/issues/9/relations.xml', {}, credentials('jsmith')
 
         assert_response :success
         assert_equal 'application/xml', @response.content_type
@@ -55,7 +55,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
     context "POST" do
       should "create a relation" do
         assert_difference('IssueRelation.count') do
-          post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, :authorization => credentials('jsmith')
+          post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, credentials('jsmith')
         end
 
         relation = IssueRelation.first(:order => 'id DESC')
@@ -71,7 +71,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
       context "with failure" do
         should "return the errors" do
           assert_no_difference('IssueRelation.count') do
-            post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, :authorization => credentials('jsmith')
+            post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, credentials('jsmith')
           end
 
           assert_response :unprocessable_entity
@@ -84,7 +84,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
   context "/relations/:id" do
     context "GET" do
       should "return the relation" do
-        get '/relations/2.xml', {}, :authorization => credentials('jsmith')
+        get '/relations/2.xml', {}, credentials('jsmith')
 
         assert_response :success
         assert_equal 'application/xml', @response.content_type
@@ -95,7 +95,7 @@ class ApiTest::IssueRelationsTest < ActionController::IntegrationTest
     context "DELETE" do
       should "delete the relation" do
         assert_difference('IssueRelation.count', -1) do
-          delete '/relations/2.xml', {}, :authorization => credentials('jsmith')
+          delete '/relations/2.xml', {}, credentials('jsmith')
         end
 
         assert_response :ok
index 1b8a2d80f575567af4630569a8097cf9f9b7619c..9244ba5b57a05d792c89858741b0c8cedada1f65 100644 (file)
@@ -344,7 +344,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "create an issue with the attributes" do
       assert_difference('Issue.count') do
-        post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
+        post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith')
       end
 
       issue = Issue.first(:order => 'id DESC')
@@ -362,7 +362,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "POST /issues.xml with failure" do
     should "have an errors tag" do
       assert_no_difference('Issue.count') do
-        post '/issues.xml', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith')
+        post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith')
       end
 
       assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
@@ -377,7 +377,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "create an issue with the attributes" do
       assert_difference('Issue.count') do
-        post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
+        post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith')
       end
 
       issue = Issue.first(:order => 'id DESC')
@@ -392,7 +392,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "POST /issues.json with failure" do
     should "have an errors element" do
       assert_no_difference('Issue.count') do
-        post '/issues.json', {:issue => {:project_id => 1}}, :authorization => credentials('jsmith')
+        post '/issues.json', {:issue => {:project_id => 1}}, credentials('jsmith')
       end
 
       json = ActiveSupport::JSON.decode(response.body)
@@ -404,7 +404,6 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "PUT /issues/6.xml" do
     setup do
       @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
-      @headers = { :authorization => credentials('jsmith') }
     end
 
     should_allow_api_authentication(:put,
@@ -414,25 +413,25 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "not create a new issue" do
       assert_no_difference('Issue.count') do
-        put '/issues/6.xml', @parameters, @headers
+        put '/issues/6.xml', @parameters, credentials('jsmith')
       end
     end
 
     should "create a new journal" do
       assert_difference('Journal.count') do
-        put '/issues/6.xml', @parameters, @headers
+        put '/issues/6.xml', @parameters, credentials('jsmith')
       end
     end
 
     should "add the note to the journal" do
-      put '/issues/6.xml', @parameters, @headers
+      put '/issues/6.xml', @parameters, credentials('jsmith')
 
       journal = Journal.last
       assert_equal "A new note", journal.notes
     end
 
     should "update the issue" do
-      put '/issues/6.xml', @parameters, @headers
+      put '/issues/6.xml', @parameters, credentials('jsmith')
 
       issue = Issue.find(6)
       assert_equal "API update", issue.subject
@@ -443,12 +442,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "PUT /issues/3.xml with custom fields" do
     setup do
       @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}}
-      @headers = { :authorization => credentials('jsmith') }
     end
 
     should "update custom fields" do
       assert_no_difference('Issue.count') do
-        put '/issues/3.xml', @parameters, @headers
+        put '/issues/3.xml', @parameters, credentials('jsmith')
       end
 
       issue = Issue.find(3)
@@ -460,23 +458,22 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "PUT /issues/6.xml with failed update" do
     setup do
       @parameters = {:issue => {:subject => ''}}
-      @headers = { :authorization => credentials('jsmith') }
     end
 
     should "not create a new issue" do
       assert_no_difference('Issue.count') do
-        put '/issues/6.xml', @parameters, @headers
+        put '/issues/6.xml', @parameters, credentials('jsmith')
       end
     end
 
     should "not create a new journal" do
       assert_no_difference('Journal.count') do
-        put '/issues/6.xml', @parameters, @headers
+        put '/issues/6.xml', @parameters, credentials('jsmith')
       end
     end
 
     should "have an errors tag" do
-      put '/issues/6.xml', @parameters, @headers
+      put '/issues/6.xml', @parameters, credentials('jsmith')
 
       assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
     end
@@ -485,7 +482,6 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "PUT /issues/6.json" do
     setup do
       @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
-      @headers = { :authorization => credentials('jsmith') }
     end
 
     should_allow_api_authentication(:put,
@@ -495,25 +491,25 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "not create a new issue" do
       assert_no_difference('Issue.count') do
-        put '/issues/6.json', @parameters, @headers
+        put '/issues/6.json', @parameters, credentials('jsmith')
       end
     end
 
     should "create a new journal" do
       assert_difference('Journal.count') do
-        put '/issues/6.json', @parameters, @headers
+        put '/issues/6.json', @parameters, credentials('jsmith')
       end
     end
 
     should "add the note to the journal" do
-      put '/issues/6.json', @parameters, @headers
+      put '/issues/6.json', @parameters, credentials('jsmith')
 
       journal = Journal.last
       assert_equal "A new note", journal.notes
     end
 
     should "update the issue" do
-      put '/issues/6.json', @parameters, @headers
+      put '/issues/6.json', @parameters, credentials('jsmith')
 
       issue = Issue.find(6)
       assert_equal "API update", issue.subject
@@ -524,23 +520,22 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
   context "PUT /issues/6.json with failed update" do
     setup do
       @parameters = {:issue => {:subject => ''}}
-      @headers = { :authorization => credentials('jsmith') }
     end
 
     should "not create a new issue" do
       assert_no_difference('Issue.count') do
-        put '/issues/6.json', @parameters, @headers
+        put '/issues/6.json', @parameters, credentials('jsmith')
       end
     end
 
     should "not create a new journal" do
       assert_no_difference('Journal.count') do
-        put '/issues/6.json', @parameters, @headers
+        put '/issues/6.json', @parameters, credentials('jsmith')
       end
     end
 
     should "have an errors attribute" do
-      put '/issues/6.json', @parameters, @headers
+      put '/issues/6.json', @parameters, credentials('jsmith')
 
       json = ActiveSupport::JSON.decode(response.body)
       assert json['errors'].include?(['subject', "can't be blank"])
@@ -555,7 +550,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "delete the issue" do
       assert_difference('Issue.count',-1) do
-        delete '/issues/6.xml', {}, :authorization => credentials('jsmith')
+        delete '/issues/6.xml', {}, credentials('jsmith')
       end
 
       assert_nil Issue.find_by_id(6)
@@ -570,7 +565,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
 
     should "delete the issue" do
       assert_difference('Issue.count',-1) do
-        delete '/issues/6.json', {}, :authorization => credentials('jsmith')
+        delete '/issues/6.json', {}, credentials('jsmith')
       end
 
       assert_nil Issue.find_by_id(6)
index beef58e47cc8b2e4dbd4bd4bb6c1cf0ee0203136..fe3cee41cca78efa9e1fc0b5d56245d25a0f92f0 100644 (file)
@@ -152,7 +152,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
 
         should "create a project with the attributes" do
           assert_difference('Project.count') do
-            post '/projects.xml', @parameters, :authorization => credentials('admin')
+            post '/projects.xml', @parameters, credentials('admin')
           end
 
           project = Project.first(:order => 'id DESC')
@@ -170,7 +170,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
           @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']})
 
           assert_difference('Project.count') do
-            post '/projects.xml', @parameters, :authorization => credentials('admin')
+            post '/projects.xml', @parameters, credentials('admin')
           end
 
           project = Project.first(:order => 'id DESC')
@@ -181,7 +181,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
           @parameters[:project].merge!({:tracker_ids => [1, 3]})
 
           assert_difference('Project.count') do
-            post '/projects.xml', @parameters, :authorization => credentials('admin')
+            post '/projects.xml', @parameters, credentials('admin')
           end
 
           project = Project.first(:order => 'id DESC')
@@ -198,7 +198,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
       context ".xml" do
         should "return errors" do
           assert_no_difference('Project.count') do
-            post '/projects.xml', @parameters, :authorization => credentials('admin')
+            post '/projects.xml', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -223,7 +223,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
 
         should "update the project" do
           assert_no_difference 'Project.count' do
-            put '/projects/2.xml', @parameters, :authorization => credentials('jsmith')
+            put '/projects/2.xml', @parameters, credentials('jsmith')
           end
           assert_response :ok
           assert_equal 'application/xml', @response.content_type
@@ -235,7 +235,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
           @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']})
 
           assert_no_difference 'Project.count' do
-            put '/projects/2.xml', @parameters, :authorization => credentials('admin')
+            put '/projects/2.xml', @parameters, credentials('admin')
           end
           assert_response :ok
           project = Project.find(2)
@@ -246,7 +246,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
           @parameters[:project].merge!({:tracker_ids => [1, 3]})
 
           assert_no_difference 'Project.count' do
-            put '/projects/2.xml', @parameters, :authorization => credentials('admin')
+            put '/projects/2.xml', @parameters, credentials('admin')
           end
           assert_response :ok
           project = Project.find(2)
@@ -263,7 +263,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
       context ".xml" do
         should "return errors" do
           assert_no_difference('Project.count') do
-            put '/projects/2.xml', @parameters, :authorization => credentials('admin')
+            put '/projects/2.xml', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -283,7 +283,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
 
       should "delete the project" do
         assert_difference('Project.count',-1) do
-          delete '/projects/2.xml', {}, :authorization => credentials('admin')
+          delete '/projects/2.xml', {}, credentials('admin')
         end
         assert_response :ok
         assert_nil Project.find_by_id(2)
index 1cfa02088a7fee98033b7fb27e5e409c90c9c66c..b2d591f1ff090aabaaf71365e78e4602ed9b307d 100644 (file)
@@ -34,7 +34,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
 
   context "GET /time_entries.xml" do
     should "return time entries" do
-      get '/time_entries.xml', {}, :authorization => credentials('jsmith')
+      get '/time_entries.xml', {}, credentials('jsmith')
       assert_response :success
       assert_equal 'application/xml', @response.content_type
       assert_tag :tag => 'time_entries',
@@ -43,7 +43,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
 
     context "with limit" do
       should "return limited results" do
-        get '/time_entries.xml?limit=2', {}, :authorization => credentials('jsmith')
+        get '/time_entries.xml?limit=2', {}, credentials('jsmith')
         assert_response :success
         assert_equal 'application/xml', @response.content_type
         assert_tag :tag => 'time_entries',
@@ -54,7 +54,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
 
   context "GET /time_entries/2.xml" do
     should "return requested time entry" do
-      get '/time_entries/2.xml', {}, :authorization => credentials('jsmith')
+      get '/time_entries/2.xml', {}, credentials('jsmith')
       assert_response :success
       assert_equal 'application/xml', @response.content_type
       assert_tag :tag => 'time_entry',
@@ -66,7 +66,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
     context "with issue_id" do
       should "return create time entry" do
         assert_difference 'TimeEntry.count' do
-          post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, :authorization => credentials('jsmith')
+          post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith')
         end
         assert_response :created
         assert_equal 'application/xml', @response.content_type
@@ -84,7 +84,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
     context "with project_id" do
       should "return create time entry" do
         assert_difference 'TimeEntry.count' do
-          post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, :authorization => credentials('jsmith')
+          post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith')
         end
         assert_response :created
         assert_equal 'application/xml', @response.content_type
@@ -102,7 +102,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
     context "with invalid parameters" do
       should "return errors" do
         assert_no_difference 'TimeEntry.count' do
-          post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, :authorization => credentials('jsmith')
+          post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, credentials('jsmith')
         end
         assert_response :unprocessable_entity
         assert_equal 'application/xml', @response.content_type
@@ -116,7 +116,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
     context "with valid parameters" do
       should "update time entry" do
         assert_no_difference 'TimeEntry.count' do
-          put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, :authorization => credentials('jsmith')
+          put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, credentials('jsmith')
         end
         assert_response :ok
         assert_equal 'API Update', TimeEntry.find(2).comments
@@ -126,7 +126,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
     context "with invalid parameters" do
       should "return errors" do
         assert_no_difference 'TimeEntry.count' do
-          put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, :authorization => credentials('jsmith')
+          put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, credentials('jsmith')
         end
         assert_response :unprocessable_entity
         assert_equal 'application/xml', @response.content_type
@@ -139,7 +139,7 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
   context "DELETE /time_entries/2.xml" do
     should "destroy time entry" do
       assert_difference 'TimeEntry.count', -1 do
-        delete '/time_entries/2.xml', {}, :authorization => credentials('jsmith')
+        delete '/time_entries/2.xml', {}, credentials('jsmith')
       end
       assert_response :ok
       assert_nil TimeEntry.find_by_id(2)
index ab301fe182be720b9a37d4709dc79f01a28ef58e..744a09ee40e973820c1edecb0f10b1df590c3ab5 100644 (file)
@@ -60,7 +60,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
       end
 
       should "return current user" do
-        get '/users/current.xml', {}, :authorization => credentials('jsmith')
+        get '/users/current.xml', {}, credentials('jsmith')
 
         assert_tag :tag => 'user',
           :child => {:tag => 'id', :content => '2'}
@@ -91,7 +91,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
         should "create a user with the attributes" do
           assert_difference('User.count') do
-            post '/users.xml', @parameters, :authorization => credentials('admin')
+            post '/users.xml', @parameters, credentials('admin')
           end
 
           user = User.first(:order => 'id DESC')
@@ -120,7 +120,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
         should "create a user with the attributes" do
           assert_difference('User.count') do
-            post '/users.json', @parameters, :authorization => credentials('admin')
+            post '/users.json', @parameters, credentials('admin')
           end
 
           user = User.first(:order => 'id DESC')
@@ -148,7 +148,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
       context ".xml" do
         should "return errors" do
           assert_no_difference('User.count') do
-            post '/users.xml', @parameters, :authorization => credentials('admin')
+            post '/users.xml', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -163,7 +163,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
       context ".json" do
         should "return errors" do
           assert_no_difference('User.count') do
-            post '/users.json', @parameters, :authorization => credentials('admin')
+            post '/users.json', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -199,7 +199,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
         should "update user with the attributes" do
           assert_no_difference('User.count') do
-            put '/users/2.xml', @parameters, :authorization => credentials('admin')
+            put '/users/2.xml', @parameters, credentials('admin')
           end
 
           user = User.find(2)
@@ -224,7 +224,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
         should "update user with the attributes" do
           assert_no_difference('User.count') do
-            put '/users/2.json', @parameters, :authorization => credentials('admin')
+            put '/users/2.json', @parameters, credentials('admin')
           end
 
           user = User.find(2)
@@ -252,7 +252,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
       context ".xml" do
         should "return errors" do
           assert_no_difference('User.count') do
-            put '/users/2.xml', @parameters, :authorization => credentials('admin')
+            put '/users/2.xml', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -267,7 +267,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
       context ".json" do
         should "return errors" do
           assert_no_difference('User.count') do
-            put '/users/2.json', @parameters, :authorization => credentials('admin')
+            put '/users/2.json', @parameters, credentials('admin')
           end
 
           assert_response :unprocessable_entity
@@ -290,7 +290,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
       should "delete user" do
         assert_difference('User.count', -1) do
-          delete '/users/2.xml', {}, :authorization => credentials('admin')
+          delete '/users/2.xml', {}, credentials('admin')
         end
 
         assert_response :ok
@@ -305,7 +305,7 @@ class ApiTest::UsersTest < ActionController::IntegrationTest
 
       should "delete user" do
         assert_difference('User.count', -1) do
-          delete '/users/2.json', {}, :authorization => credentials('admin')
+          delete '/users/2.json', {}, credentials('admin')
         end
 
         assert_response :ok
index 34416b68cf22d932ecc646b09197bab73f87a350..e250dcd50a830a34f439c41727e5ff81dbcb4295 100644 (file)
@@ -58,7 +58,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
     context "POST" do
       should "create the version" do
         assert_difference 'Version.count' do
-          post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, :authorization => credentials('jsmith')
+          post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, credentials('jsmith')
         end
 
         version = Version.first(:order => 'id DESC')
@@ -72,7 +72,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
       context "with failure" do
         should "return the errors" do
           assert_no_difference('Version.count') do
-            post '/projects/1/versions.xml', {:version => {:name => ''}}, :authorization => credentials('jsmith')
+            post '/projects/1/versions.xml', {:version => {:name => ''}}, credentials('jsmith')
           end
 
           assert_response :unprocessable_entity
@@ -103,7 +103,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
 
     context "PUT" do
       should "update the version" do
-        put '/versions/2.xml', {:version => {:name => 'API update'}}, :authorization => credentials('jsmith')
+        put '/versions/2.xml', {:version => {:name => 'API update'}}, credentials('jsmith')
 
         assert_response :ok
         assert_equal 'API update', Version.find(2).name
@@ -113,7 +113,7 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
     context "DELETE" do
       should "destroy the version" do
         assert_difference 'Version.count', -1 do
-          delete '/versions/3.xml', {}, :authorization => credentials('jsmith')
+          delete '/versions/3.xml', {}, credentials('jsmith')
         end
 
         assert_response :ok
index 16afd6a79b844f7bb7a3f28295b9a3646583b7d4..bf6d5b366d7e62a078c01d02cb748b2961d4c9e9 100644 (file)
@@ -63,7 +63,7 @@ class ActiveSupport::TestCase
   end
 
   def credentials(user, password=nil)
-    ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
+    {:authorization => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)}
   end
 
   # Mock out a file
@@ -244,7 +244,7 @@ class ActiveSupport::TestCase
       context "with a valid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password', :admin => true) # Admin so they can access the project
-          send(http_method, url, parameters, {:authorization => credentials(@user.login, 'my_password')})
+          send(http_method, url, parameters, credentials(@user.login, 'my_password'))
         end
 
         should_respond_with success_code
@@ -257,7 +257,7 @@ class ActiveSupport::TestCase
       context "with an invalid HTTP authentication" do
         setup do
           @user = User.generate_with_protected!
-          send(http_method, url, parameters, {:authorization => credentials(@user.login, 'wrong_password')})
+          send(http_method, url, parameters, credentials(@user.login, 'wrong_password'))
         end
 
         should_respond_with failure_code
@@ -269,7 +269,7 @@ class ActiveSupport::TestCase
 
       context "without credentials" do
         setup do
-          send(http_method, url, parameters, {:authorization => ''})
+          send(http_method, url, parameters)
         end
 
         should_respond_with failure_code
@@ -299,7 +299,7 @@ class ActiveSupport::TestCase
         setup do
           @user = User.generate_with_protected!(:admin => true)
           @token = Token.generate!(:user => @user, :action => 'api')
-          send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
+          send(http_method, url, parameters, credentials(@token.value, 'X'))
         end
 
         should_respond_with success_code
@@ -314,7 +314,7 @@ class ActiveSupport::TestCase
         setup do
           @user = User.generate_with_protected!
           @token = Token.generate!(:user => @user, :action => 'feeds')
-          send(http_method, url, parameters, {:authorization => credentials(@token.value, 'X')})
+          send(http_method, url, parameters, credentials(@token.value, 'X'))
         end
 
         should_respond_with failure_code