diff options
Diffstat (limited to 'test/controllers')
| -rw-r--r-- | test/controllers/page_translations_controller_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/controllers/page_translations_controller_test.rb b/test/controllers/page_translations_controller_test.rb index d84ac45..8c899fd 100644 --- a/test/controllers/page_translations_controller_test.rb +++ b/test/controllers/page_translations_controller_test.rb | |||
| @@ -18,6 +18,7 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 18 | node = Node.root.children.create!(:slug => "translations_create_test") | 18 | node = Node.root.children.create!(:slug => "translations_create_test") |
| 19 | Globalize.with_locale(:de) { node.draft.update!(:title => "Deutscher Titel") } | 19 | Globalize.with_locale(:de) { node.draft.update!(:title => "Deutscher Titel") } |
| 20 | node.publish_draft! | 20 | node.publish_draft! |
| 21 | node.lock_for_editing!(users(:quentin)) | ||
| 21 | 22 | ||
| 22 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "English Title" } } | 23 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "English Title" } } |
| 23 | 24 | ||
| @@ -39,6 +40,7 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 39 | test "update with Save + Unlock + Exit unlocks the node and redirects to nodes#show" do | 40 | test "update with Save + Unlock + Exit unlocks the node and redirects to nodes#show" do |
| 40 | login_as :quentin | 41 | login_as :quentin |
| 41 | node = Node.root.children.create!(:slug => "translations_exit_test") | 42 | node = Node.root.children.create!(:slug => "translations_exit_test") |
| 43 | node.lock_for_editing!(users(:quentin)) | ||
| 42 | 44 | ||
| 43 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "x" }, :commit => "Save + Unlock + Exit" } | 45 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "x" }, :commit => "Save + Unlock + Exit" } |
| 44 | 46 | ||
| @@ -50,6 +52,7 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 50 | login_as :quentin | 52 | login_as :quentin |
| 51 | node = Node.root.children.create!(:slug => "translations_update_test") | 53 | node = Node.root.children.create!(:slug => "translations_update_test") |
| 52 | Globalize.with_locale(:en) { node.draft.update!(:title => "Original") } | 54 | Globalize.with_locale(:en) { node.draft.update!(:title => "Original") } |
| 55 | node.lock_for_editing!(users(:quentin)) | ||
| 53 | 56 | ||
| 54 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "Revised" } } | 57 | patch :update, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "Revised" } } |
| 55 | 58 | ||
| @@ -75,4 +78,20 @@ class PageTranslationsControllerTest < ActionController::TestCase | |||
| 75 | 78 | ||
| 76 | assert_match(/No EN translation exists/, flash[:error]) | 79 | assert_match(/No EN translation exists/, flash[:error]) |
| 77 | end | 80 | end |
| 81 | |||
| 82 | test "autosave writes the translation without creating a new revision or touching the draft" do | ||
| 83 | login_as :quentin | ||
| 84 | node = Node.root.children.create!(:slug => "translations_autosave_test") | ||
| 85 | node.publish_draft! | ||
| 86 | node.lock_for_editing!(users(:quentin)) | ||
| 87 | page_count_before = node.pages.count | ||
| 88 | |||
| 89 | put :autosave, params: { :node_id => node.id, :translation_locale => "en", :page => { :title => "in progress" } } | ||
| 90 | |||
| 91 | assert_response :success | ||
| 92 | node.reload | ||
| 93 | assert_not_nil node.autosave | ||
| 94 | assert_equal page_count_before, node.pages.count | ||
| 95 | assert_equal "in progress", Globalize.with_locale(:en) { node.autosave.title } | ||
| 96 | end | ||
| 78 | end | 97 | end |
