Permalink
Browse files

add test on insert_editor action on admin page_controller

  • Loading branch information...
Yannick Francois
Yannick Francois committed Nov 8, 2011
1 parent a0b9612 commit db9416a5dee0f31deb450699f85fefa4c491cfed
@@ -62,12 +62,14 @@ def set_shortened_url
@page.redirects << red
end
+ # TODO Duplicate with Admin::ContentController
def insert_editor
- editor = (params[:editor].to_s =~ /simple|visual/) ? params[:editor].to_s : "visual"
+ editor = 'visual'
+ editor = 'simple' if params[:editor].to_s == 'simple'
current_user.editor = editor
current_user.save!
- render :partial => "#{params[:editor].to_s}_editor"
+ render :partial => "#{editor}_editor"
end
end
@@ -125,8 +125,6 @@
before do
Factory(:blog)
- #TODO delete this after remove fixture
- Profile.delete_all
@user = Factory(:user, :profile => Factory(:profile_admin, :label => Profile::ADMIN))
request.session = { :user => @user.id }
end
@@ -159,5 +159,23 @@ def base_page(options={})
assigns(:page).redirects.count.should == 0
end
+ describe 'insert_editor action' do
+ it 'should render _simple_editor' do
+ get(:insert_editor, :editor => 'simple')
+ response.should render_template('_simple_editor')
+ end
+
+ it 'should render _visual_editor' do
+ get(:insert_editor, :editor => 'visual')
+ response.should render_template('_visual_editor')
+ end
+
+ it 'should render _visual_editor even if editor param is set to unknow editor' do
+ get(:insert_editor, :editor => 'unknow')
+ response.should render_template('_visual_editor')
+ end
+ end
+
+
end

0 comments on commit db9416a

Please sign in to comment.