summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-11-04 16:22:47 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-11-04 16:22:47 +0000
commitc967899b145619080197d32d801f99484b485ed7 (patch)
treeb9944698f0e093a7a2555e631aa9d01d38684741 /test/integration
parent30dc4fec998183f8dc077a6503fed993e9e08b9e (diff)
downloadredmine-c967899b145619080197d32d801f99484b485ed7.tar.gz
redmine-c967899b145619080197d32d801f99484b485ed7.zip
Refactor: Convert the tests for Issues#index and #show APIs to shoulda. #6447
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4364 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api_test/issues_test.rb65
1 files changed, 15 insertions, 50 deletions
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb
index c51438bba..7e3b7aba3 100644
--- a/test/integration/api_test/issues_test.rb
+++ b/test/integration/api_test/issues_test.rb
@@ -46,36 +46,21 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
Setting.rest_api_enabled = '1'
end
+ # Use a private project to make sure auth is really working and not just
+ # only showing public issues.
context "/index.xml" do
- setup do
- get '/issues.xml'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/xml'
+ should_allow_api_authentication(:get, "/projects/private-child/issues.xml")
end
context "/index.json" do
- setup do
- get '/issues.json'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/json'
-
- should 'return a valid JSON string' do
- assert ActiveSupport::JSON.decode(response.body)
- end
+ should_allow_api_authentication(:get, "/projects/private-child/issues.json")
end
context "/index.xml with filter" do
- setup do
- get '/issues.xml?status_id=5'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/xml'
+ should_allow_api_authentication(:get, "/projects/private-child/issues.xml?status_id=5")
+
should "show only issues with the status_id" do
+ get '/issues.xml?status_id=5'
assert_tag :tag => 'issues',
:children => { :count => Issue.visible.count(:conditions => {:status_id => 5}),
:only => { :tag => 'issue' } }
@@ -83,18 +68,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
end
context "/index.json with filter" do
- setup do
- get '/issues.json?status_id=5'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/json'
-
- should 'return a valid JSON string' do
- assert ActiveSupport::JSON.decode(response.body)
- end
+ should_allow_api_authentication(:get, "/projects/private-child/issues.json?status_id=5")
should "show only issues with the status_id" do
+ get '/issues.json?status_id=5'
+
json = ActiveSupport::JSON.decode(response.body)
status_ids_used = json.collect {|j| j['status_id'] }
assert_equal 3, status_ids_used.length
@@ -103,26 +81,13 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
end
- context "/issues/1.xml" do
- setup do
- get '/issues/1.xml'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/xml'
+ # Issue 6 is on a private project
+ context "/issues/6.xml" do
+ should_allow_api_authentication(:get, "/issues/6.xml")
end
- context "/issues/1.json" do
- setup do
- get '/issues/1.json'
- end
-
- should_respond_with :success
- should_respond_with_content_type 'application/json'
-
- should 'return a valid JSON string' do
- assert ActiveSupport::JSON.decode(response.body)
- end
+ context "/issues/6.json" do
+ should_allow_api_authentication(:get, "/issues/6.json")
end
context "POST /issues.xml" do