diff options
Diffstat (limited to 'test/controllers')
| -rw-r--r-- | test/controllers/admin_controller_test.rb | 15 | ||||
| -rw-r--r-- | test/controllers/revisions_controller_test.rb | 39 |
2 files changed, 51 insertions, 3 deletions
diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb index 9bbf29b..d6005ba 100644 --- a/test/controllers/admin_controller_test.rb +++ b/test/controllers/admin_controller_test.rb | |||
| @@ -1,8 +1,17 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class AdminControllerTest < ActionController::TestCase | 3 | class AdminControllerTest < ActionController::TestCase |
| 4 | # Replace this with your real tests. | 4 | test "current drafts includes nodes with only an autosave" do |
| 5 | test "the truth" do | 5 | node = Node.root.children.create!(:slug => "admin_autosave_only") |
| 6 | assert true | 6 | node.lock_for_editing!(User.find_by_login("aaron")) |
| 7 | node.autosave!({title: "in progress"}, User.find_by_login("aaron")) | ||
| 8 | node.save_draft!(User.find_by_login("aaron")) | ||
| 9 | node.publish_draft! | ||
| 10 | node.lock_for_editing!(User.find_by_login("aaron")) | ||
| 11 | node.autosave!({title: "editing again"}, User.find_by_login("aaron")) | ||
| 12 | |||
| 13 | login_as :quentin | ||
| 14 | get :index | ||
| 15 | assert_includes assigns(:drafts), node | ||
| 7 | end | 16 | end |
| 8 | end | 17 | end |
diff --git a/test/controllers/revisions_controller_test.rb b/test/controllers/revisions_controller_test.rb index caca6bf..162e6f1 100644 --- a/test/controllers/revisions_controller_test.rb +++ b/test/controllers/revisions_controller_test.rb | |||
| @@ -100,4 +100,43 @@ class RevisionsControllerTest < ActionController::TestCase | |||
| 100 | assert_response :success | 100 | assert_response :success |
| 101 | assert_select ".diff_column", 2 | 101 | assert_select ".diff_column", 2 |
| 102 | end | 102 | end |
| 103 | |||
| 104 | test "diffing head against draft by name" do | ||
| 105 | login_as :quentin | ||
| 106 | @node.find_or_create_draft(@user) | ||
| 107 | @node.draft.update(:body => "draft body") | ||
| 108 | |||
| 109 | post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) | ||
| 110 | assert_response :success | ||
| 111 | end | ||
| 112 | |||
| 113 | test "diffing a layer pair that no longer exists redirects with a flash" do | ||
| 114 | login_as :quentin | ||
| 115 | post(:diff, params: { :node_id => @node.id, :start_revision => "draft", :end_revision => "autosave" }) | ||
| 116 | assert_redirected_to node_path(@node) | ||
| 117 | assert flash[:error].present? | ||
| 118 | end | ||
| 119 | |||
| 120 | test "diffing by name shows a clear comparison label instead of a misleading revision picker" do | ||
| 121 | login_as :quentin | ||
| 122 | @node.find_or_create_draft(@user) | ||
| 123 | |||
| 124 | post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) | ||
| 125 | assert_response :success | ||
| 126 | assert_select "strong", "Head" | ||
| 127 | assert_select "strong", "Draft" | ||
| 128 | assert_select "select[name=?]", "start_revision", :count => 0 | ||
| 129 | end | ||
| 130 | |||
| 131 | test "pair-switcher buttons carry their params as real hidden fields, not a query string" do | ||
| 132 | login_as :quentin | ||
| 133 | @node.find_or_create_draft(@user) | ||
| 134 | @node.lock_for_editing!(@user) | ||
| 135 | @node.autosave!({ :body => "unsaved" }, @user) | ||
| 136 | |||
| 137 | post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) | ||
| 138 | assert_response :success | ||
| 139 | assert_select "form.computation input[type=hidden][name=start_revision]" | ||
| 140 | assert_select "form.computation input[type=hidden][name=end_revision]" | ||
| 141 | end | ||
| 103 | end | 142 | end |
