]> source.dussan.org Git - redmine.git/commitdiff
Merged r5881 from trunk.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 May 2011 07:24:15 +0000 (07:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 May 2011 07:24:15 +0000 (07:24 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@5946 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/timelog_controller.rb
app/views/timelog/index.api.rsb
test/integration/api_test/time_entries_test.rb

index 2b752c674a92193ef660bebf177e30e95dd3dcc7..16e6e2457626ccec7d594a14f34905d0074f125d 100644 (file)
@@ -67,13 +67,13 @@ class TimelogController < ApplicationController
       }
       format.api  {
         @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
-        @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
+        @offset, @limit = api_offset_and_limit
         @entries = TimeEntry.visible.find(:all, 
                                   :include => [:project, :activity, :user, {:issue => :tracker}],
                                   :conditions => cond.conditions,
                                   :order => sort_clause,
-                                  :limit  =>  @entry_pages.items_per_page,
-                                  :offset =>  @entry_pages.current.offset)
+                                  :limit  => @limit,
+                                  :offset => @offset)
       }
       format.atom {
         entries = TimeEntry.visible.find(:all,
index 0367e06661961552791a66e0a000b10c5eced0c3..213dbd3627979848530f51c1181a739bf5352796 100644 (file)
@@ -1,4 +1,4 @@
-api.array :time_entries do
+api.array :time_entries, api_meta(:total_count => @entry_count, :offset => @offset, :limit => @limit) do
   @entries.each do |time_entry|
     api.time_entry do
       api.id time_entry.id
index 60a9dba6211d30f49e47d41db4f9d8e907986e5a..ce28c5dda9f56b7e4a36d6ea4860cfcecdd6190f 100644 (file)
@@ -32,6 +32,16 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
       assert_tag :tag => 'time_entries',
         :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
     end
+    
+    context "with limit" do
+      should "return limited results" do
+        get '/time_entries.xml?limit=2', {}, :authorization => credentials('jsmith')
+        assert_response :success
+        assert_equal 'application/xml', @response.content_type
+        assert_tag :tag => 'time_entries',
+          :children => {:count => 2}
+      end
+    end
   end
   
   context "GET /time_entries/2.xml" do