From 9e4f2aa418a4d76d210fa63e5d9481de6614ec31 Mon Sep 17 00:00:00 2001 From: Marcelo JĂșnior Date: Tue, 21 Oct 2014 18:14:08 -0300 Subject: [PATCH] comment_paragraph: add functional tests --- plugins/comment_paragraph/test/functional/comment_paragraph_plugin_test.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+), 0 deletions(-) create mode 100644 plugins/comment_paragraph/test/functional/comment_paragraph_plugin_test.rb diff --git a/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_test.rb b/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_test.rb new file mode 100644 index 0000000..4bc077c --- /dev/null +++ b/plugins/comment_paragraph/test/functional/comment_paragraph_plugin_test.rb @@ -0,0 +1,38 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../../controllers/comment_paragraph_plugin_admin_controller' + +# Re-raise errors caught by the controller. +class CommentParagraphPluginAdminController; def rescue_action(e) raise e end; end + +class CommentParagraphPluginAdminControllerTest < ActionController::TestCase + + def setup + @environment = Environment.default + user_login = create_admin_user(@environment) + login_as(user_login) + @environment.enabled_plugins = ['CommentParagraphPlugin'] + @environment.save! + @plugin_settings = Noosfero::Plugin::Settings.new(@environment, CommentParagraphPlugin) + end + + should 'access index action' do + get :index + assert_template 'index' + assert_response :success + end + + should 'update comment paragraph plugin settings' do + assert_nil @plugin_settings.get_setting(:auto_marking_article_types) + post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle'] } + @environment.reload + assert_not_nil @plugin_settings.get_setting(:auto_marking_article_types) + end + + should 'get article types previously selected' do + post :index, :settings => { :auto_marking_article_types => ['TinyMceArticle', 'TextileArticle'] } + get :index + assert_tag :input, :attributes => { :value => 'TinyMceArticle' } + assert_tag :input, :attributes => { :value => 'TextileArticle' } + end + +end -- libgit2 0.21.2