summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/timelog_controller.rb6
-rw-r--r--app/views/timelog/index.api.rsb2
-rw-r--r--test/integration/api_test/time_entries_test.rb10
3 files changed, 14 insertions, 4 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 2b752c674..16e6e2457 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -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,
diff --git a/app/views/timelog/index.api.rsb b/app/views/timelog/index.api.rsb
index 0367e0666..213dbd362 100644
--- a/app/views/timelog/index.api.rsb
+++ b/app/views/timelog/index.api.rsb
@@ -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
diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb
index 60a9dba62..ce28c5dda 100644
--- a/test/integration/api_test/time_entries_test.rb
+++ b/test/integration/api_test/time_entries_test.rb
@@ -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