diff options
Diffstat (limited to 'test/controllers/revisions_controller_test.rb')
| -rw-r--r-- | test/controllers/revisions_controller_test.rb | 39 |
1 files changed, 39 insertions, 0 deletions
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 |
