Permalink
Browse files

Fixes autosave not saving the text when using visual editor.

Text was not saved because visual editor sends unified body_and_extended field. Adding a check in the content_controller did the trick.

Also fixes issue #91
  • Loading branch information...
1 parent 06335be commit 5446208df145944e721c587b892eed7c07de462e @fdv fdv committed Jan 5, 2013
Showing with 24 additions and 2 deletions.
  1. +6 −0 app/controllers/admin/content_controller.rb
  2. +5 −1 app/models/user.rb
  3. +13 −1 spec/models/user_spec.rb
@@ -91,6 +91,12 @@ def autosave
get_fresh_or_existing_draft_for_article
@article.attributes = params[:article]
+
+ # Crappy workaround to have the visual editor work.
+ if current_user.visual_editor?
+ @article.body = params[:article][:body_and_extended]
+ end
+
@article.published = false
@article.set_author(current_user)
@article.save_attachments!(params[:attachments])
View
@@ -135,7 +135,11 @@ def self.to_prefix
def simple_editor?
editor == 'simple'
end
-
+
+ def visual_editor?
+ editor == 'visual'
+ end
+
def password=(newpass)
@password = newpass
end
View
@@ -228,10 +228,22 @@ def set_password(newpass)
end
it "should be false if editor != 'simple'" do
- user = FactoryGirl.build(:user, :editor => 'other')
+ user = FactoryGirl.build(:user, :editor => 'visual')
user.simple_editor?.should be_false
end
end
+
+ describe "#visual_editor?" do
+ it "should be true if editor == 'visual'" do
+ user = FactoryGirl.build(:user, :editor => 'visual')
+ user.visual_editor?.should be_true
+ end
+
+ it "should be false if editor != 'visual" do
+ user = FactoryGirl.build(:user, :editor => 'simple')
+ user.visual_editor?.should be_false
+ end
+ end
describe "set_author" do
it "uses user given param to set author AND user of article" do

0 comments on commit 5446208

Please sign in to comment.