##// END OF EJS Templates
Fixed: GET /time_entries.xml ignores limit/offset parameters (#8356)....
Jean-Philippe Lang -
r5761:12801ca031c0
parent child
Show More
@@ -67,13 +67,13 class TimelogController < ApplicationController
67 }
67 }
68 format.api {
68 format.api {
69 @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
69 @entry_count = TimeEntry.visible.count(:include => [:project, :issue], :conditions => cond.conditions)
70 @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
70 @offset, @limit = api_offset_and_limit
71 @entries = TimeEntry.visible.find(:all,
71 @entries = TimeEntry.visible.find(:all,
72 :include => [:project, :activity, :user, {:issue => :tracker}],
72 :include => [:project, :activity, :user, {:issue => :tracker}],
73 :conditions => cond.conditions,
73 :conditions => cond.conditions,
74 :order => sort_clause,
74 :order => sort_clause,
75 :limit => @entry_pages.items_per_page,
75 :limit => @limit,
76 :offset => @entry_pages.current.offset)
76 :offset => @offset)
77 }
77 }
78 format.atom {
78 format.atom {
79 entries = TimeEntry.visible.find(:all,
79 entries = TimeEntry.visible.find(:all,
@@ -1,4 +1,4
1 api.array :time_entries do
1 api.array :time_entries, api_meta(:total_count => @entry_count, :offset => @offset, :limit => @limit) do
2 @entries.each do |time_entry|
2 @entries.each do |time_entry|
3 api.time_entry do
3 api.time_entry do
4 api.id time_entry.id
4 api.id time_entry.id
@@ -32,6 +32,16 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
32 assert_tag :tag => 'time_entries',
32 assert_tag :tag => 'time_entries',
33 :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
33 :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
34 end
34 end
35
36 context "with limit" do
37 should "return limited results" do
38 get '/time_entries.xml?limit=2', {}, :authorization => credentials('jsmith')
39 assert_response :success
40 assert_equal 'application/xml', @response.content_type
41 assert_tag :tag => 'time_entries',
42 :children => {:count => 2}
43 end
44 end
35 end
45 end
36
46
37 context "GET /time_entries/2.xml" do
47 context "GET /time_entries/2.xml" do
General Comments 0
You need to be logged in to leave comments. Login now