diff --git a/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb b/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb index 0929d83..2d854fc 100644 --- a/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb +++ b/plugins/email_article/controllers/email_article_plugin_myprofile_controller.rb @@ -6,9 +6,9 @@ class EmailArticlePluginMyprofileController < MyProfileController if user.is_admin?(profile) article = Article.find(params[:id]) EmailArticlePluginMyprofileController::Sender.deliver_mail(article) - render :action => 'success' + render :text => "Email sent to queue" else - render :action => 'fail' + render :status => :forbidden, :text => "Forbidden user" end end diff --git a/plugins/email_article/test/functional/email_article_plugin_myprofile_controller_test.rb b/plugins/email_article/test/functional/email_article_plugin_myprofile_controller_test.rb new file mode 100644 index 0000000..4f1d1c4 --- /dev/null +++ b/plugins/email_article/test/functional/email_article_plugin_myprofile_controller_test.rb @@ -0,0 +1,39 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class EmailArticlePluginMyprofileControllerTest < ActionController::TestCase + + def setup + Environment.delete_all + @environment = Environment.new(:name => 'testenv', :is_default => true) + @environment.enabled_plugins = ['EmailArticlePlugin'] + @environment.save! + end + + should 'be able to deliver mail as profile admin' do + @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community') + @user = create_user('testinguser') + login_as(@user.login) + @profile.add_admin(@user.person) + @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) + @article.save + get :send_email, :profile => @profile.identifier, :id => @article.id + assert_response :success + end + + should 'deny access to email article unless if profile admin' do + @profile = Community.create!(:name => 'Another community', :identifier => 'another-community') + @user = create_user('user-out-of-the-community') + login_as(@user.login) + @article = @profile.articles.create!(:name => 'a test article', :last_changed_by => @user.person) + @article.save + get :send_email, :profile => @profile.identifier, :id => @article.id + assert_response 403 + end + +end + + + + + + -- libgit2 0.21.2