@@ -625,54 +625,33 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
625 | 625 | {:issue => {:subject => 'API update', :notes => 'A new note'}}, |
|
626 | 626 | {:success_code => :ok}) |
|
627 | 627 | |
|
628 |
should " |
|
|
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 | |
|
633 | ||
|
634 | should "create a new journal" do | |
|
635 | 630 | assert_difference('Journal.count') do |
|
636 | 631 | put '/issues/6.json', @parameters, credentials('jsmith') |
|
637 | end | |
|
638 | end | |
|
639 | 632 | |
|
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 | |
|
633 | assert_response :ok | |
|
634 | assert_equal '', response.body | |
|
635 | end | |
|
645 | 636 | 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 | |
|
666 | ||
|
667 | should "not create a new journal" do | |
|
668 | 648 | assert_no_difference('Journal.count') do |
|
669 |
put '/issues/6.json', |
|
|
649 | put '/issues/6.json', {:issue => {:subject => ''}}, credentials('jsmith') | |
|
650 | ||
|
651 | assert_response :unprocessable_entity | |
|
670 | 652 | end |
|
671 | 653 | end |
|
672 | 654 | |
|
673 | should "have an errors attribute" do | |
|
674 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
675 | ||
|
676 | 655 | json = ActiveSupport::JSON.decode(response.body) |
|
677 | 656 | assert json['errors'].include?("Subject can't be blank") |
|
678 | 657 | end |
@@ -687,6 +666,9 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
687 | 666 | should "delete the issue" do |
|
688 | 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) |
@@ -702,6 +684,9 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
702 | 684 | should "delete the issue" do |
|
703 | 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