##// END OF EJS Templates
Adds assertions on response status and body....
Jean-Philippe Lang -
r9793:54d55a360a21
parent child
Show More
@@ -625,53 +625,32 class ApiTest::IssuesTest < ActionController::IntegrationTest
625 625 {:issue => {:subject => 'API update', :notes => 'A new note'}},
626 626 {:success_code => :ok})
627 627
628 should "not create a new issue" do
628 should "update the issue" do
629 629 assert_no_difference('Issue.count') do
630 put '/issues/6.json', @parameters, credentials('jsmith')
631 end
632 end
630 assert_difference('Journal.count') do
631 put '/issues/6.json', @parameters, credentials('jsmith')
633 632
634 should "create a new journal" do
635 assert_difference('Journal.count') do
636 put '/issues/6.json', @parameters, credentials('jsmith')
633 assert_response :ok
634 assert_equal '', response.body
635 end
637 636 end
638 end
639
640 should "add the note to the journal" do
641 put '/issues/6.json', @parameters, credentials('jsmith')
642
643 journal = Journal.last
644 assert_equal "A new note", journal.notes
645 end
646
647 should "update the issue" do
648 put '/issues/6.json', @parameters, credentials('jsmith')
649 637
650 638 issue = Issue.find(6)
651 639 assert_equal "API update", issue.subject
640 journal = Journal.last
641 assert_equal "A new note", journal.notes
652 642 end
653
654 643 end
655 644
656 645 context "PUT /issues/6.json with failed update" do
657 setup do
658 @parameters = {:issue => {:subject => ''}}
659 end
660
661 should "not create a new issue" do
646 should "return errors" do
662 647 assert_no_difference('Issue.count') do
663 put '/issues/6.json', @parameters, credentials('jsmith')
664 end
665 end
648 assert_no_difference('Journal.count') do
649 put '/issues/6.json', {:issue => {:subject => ''}}, credentials('jsmith')
666 650
667 should "not create a new journal" do
668 assert_no_difference('Journal.count') do
669 put '/issues/6.json', @parameters, credentials('jsmith')
651 assert_response :unprocessable_entity
652 end
670 653 end
671 end
672
673 should "have an errors attribute" do
674 put '/issues/6.json', @parameters, credentials('jsmith')
675 654
676 655 json = ActiveSupport::JSON.decode(response.body)
677 656 assert json['errors'].include?("Subject can't be blank")
@@ -685,8 +664,11 class ApiTest::IssuesTest < ActionController::IntegrationTest
685 664 {:success_code => :ok})
686 665
687 666 should "delete the issue" do
688 assert_difference('Issue.count',-1) do
667 assert_difference('Issue.count', -1) do
689 668 delete '/issues/6.xml', {}, credentials('jsmith')
669
670 assert_response :ok
671 assert_equal '', response.body
690 672 end
691 673
692 674 assert_nil Issue.find_by_id(6)
@@ -700,8 +682,11 class ApiTest::IssuesTest < ActionController::IntegrationTest
700 682 {:success_code => :ok})
701 683
702 684 should "delete the issue" do
703 assert_difference('Issue.count',-1) do
685 assert_difference('Issue.count', -1) do
704 686 delete '/issues/6.json', {}, credentials('jsmith')
687
688 assert_response :ok
689 assert_equal '', response.body
705 690 end
706 691
707 692 assert_nil Issue.find_by_id(6)
General Comments 0
You need to be logged in to leave comments. Login now