Mercurial > hg > soundsoftware-site
comparison test/integration/api_test/issues_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
160 end | 160 end |
161 end | 161 end |
162 end | 162 end |
163 end | 163 end |
164 | 164 |
165 def test_index_should_allow_timestamp_filtering | |
166 Issue.delete_all | |
167 Issue.generate!(:subject => '1').update_column(:updated_on, Time.parse("2014-01-02T10:25:00Z")) | |
168 Issue.generate!(:subject => '2').update_column(:updated_on, Time.parse("2014-01-02T12:13:00Z")) | |
169 | |
170 get '/issues.xml', | |
171 {:set_filter => 1, :f => ['updated_on'], :op => {:updated_on => '<='}, | |
172 :v => {:updated_on => ['2014-01-02T12:00:00Z']}} | |
173 assert_select 'issues>issue', :count => 1 | |
174 assert_select 'issues>issue>subject', :text => '1' | |
175 | |
176 get '/issues.xml', | |
177 {:set_filter => 1, :f => ['updated_on'], :op => {:updated_on => '>='}, | |
178 :v => {:updated_on => ['2014-01-02T12:00:00Z']}} | |
179 assert_select 'issues>issue', :count => 1 | |
180 assert_select 'issues>issue>subject', :text => '2' | |
181 | |
182 get '/issues.xml', | |
183 {:set_filter => 1, :f => ['updated_on'], :op => {:updated_on => '>='}, | |
184 :v => {:updated_on => ['2014-01-02T08:00:00Z']}} | |
185 assert_select 'issues>issue', :count => 2 | |
186 end | |
187 | |
165 context "/index.json" do | 188 context "/index.json" do |
166 should_allow_api_authentication(:get, "/projects/private-child/issues.json") | 189 should_allow_api_authentication(:get, "/projects/private-child/issues.json") |
167 end | 190 end |
168 | 191 |
169 context "/index.xml with filter" do | 192 context "/index.xml with filter" do |
479 assert_difference('Issue.count') do | 502 assert_difference('Issue.count') do |
480 post '/issues.xml', | 503 post '/issues.xml', |
481 {:issue => {:project_id => 1, :subject => 'API test', | 504 {:issue => {:project_id => 1, :subject => 'API test', |
482 :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | 505 :tracker_id => 2, :status_id => 3}}, credentials('jsmith') |
483 end | 506 end |
484 issue = Issue.first(:order => 'id DESC') | 507 issue = Issue.order('id DESC').first |
485 assert_equal 1, issue.project_id | 508 assert_equal 1, issue.project_id |
486 assert_equal 2, issue.tracker_id | 509 assert_equal 2, issue.tracker_id |
487 assert_equal 3, issue.status_id | 510 assert_equal 3, issue.status_id |
488 assert_equal 'API test', issue.subject | 511 assert_equal 'API test', issue.subject |
489 | 512 |
528 {:issue => {:project_id => 1, :subject => 'API test', | 551 {:issue => {:project_id => 1, :subject => 'API test', |
529 :tracker_id => 2, :status_id => 3}}, | 552 :tracker_id => 2, :status_id => 3}}, |
530 credentials('jsmith') | 553 credentials('jsmith') |
531 end | 554 end |
532 | 555 |
533 issue = Issue.first(:order => 'id DESC') | 556 issue = Issue.order('id DESC').first |
534 assert_equal 1, issue.project_id | 557 assert_equal 1, issue.project_id |
535 assert_equal 2, issue.tracker_id | 558 assert_equal 2, issue.tracker_id |
536 assert_equal 3, issue.status_id | 559 assert_equal 3, issue.status_id |
537 assert_equal 'API test', issue.subject | 560 assert_equal 'API test', issue.subject |
538 end | 561 end |
779 {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | 802 {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) |
780 assert_response :created | 803 assert_response :created |
781 end | 804 end |
782 xml = Hash.from_xml(response.body) | 805 xml = Hash.from_xml(response.body) |
783 token = xml['upload']['token'] | 806 token = xml['upload']['token'] |
784 attachment = Attachment.first(:order => 'id DESC') | 807 attachment = Attachment.order('id DESC').first |
785 | 808 |
786 # create the issue with the upload's token | 809 # create the issue with the upload's token |
787 assert_difference 'Issue.count' do | 810 assert_difference 'Issue.count' do |
788 post '/issues.xml', | 811 post '/issues.xml', |
789 {:issue => {:project_id => 1, :subject => 'Uploaded file', | 812 {:issue => {:project_id => 1, :subject => 'Uploaded file', |
790 :uploads => [{:token => token, :filename => 'test.txt', | 813 :uploads => [{:token => token, :filename => 'test.txt', |
791 :content_type => 'text/plain'}]}}, | 814 :content_type => 'text/plain'}]}}, |
792 credentials('jsmith') | 815 credentials('jsmith') |
793 assert_response :created | 816 assert_response :created |
794 end | 817 end |
795 issue = Issue.first(:order => 'id DESC') | 818 issue = Issue.order('id DESC').first |
796 assert_equal 1, issue.attachments.count | 819 assert_equal 1, issue.attachments.count |
797 assert_equal attachment, issue.attachments.first | 820 assert_equal attachment, issue.attachments.first |
798 | 821 |
799 attachment.reload | 822 attachment.reload |
800 assert_equal 'test.txt', attachment.filename | 823 assert_equal 'test.txt', attachment.filename |
825 {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | 848 {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) |
826 assert_response :created | 849 assert_response :created |
827 end | 850 end |
828 xml = Hash.from_xml(response.body) | 851 xml = Hash.from_xml(response.body) |
829 token = xml['upload']['token'] | 852 token = xml['upload']['token'] |
830 attachment = Attachment.first(:order => 'id DESC') | 853 attachment = Attachment.order('id DESC').first |
831 | 854 |
832 # update the issue with the upload's token | 855 # update the issue with the upload's token |
833 assert_difference 'Journal.count' do | 856 assert_difference 'Journal.count' do |
834 put '/issues/1.xml', | 857 put '/issues/1.xml', |
835 {:issue => {:notes => 'Attachment added', | 858 {:issue => {:notes => 'Attachment added', |